Compare commits
25 Commits
feature/ch
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb9dee10de | ||
|
|
93d720b676 | ||
|
|
52dccce7e2 | ||
|
|
bf0de65fb7 | ||
|
|
7ca70fbdc3 | ||
|
|
b35944ee3e | ||
|
|
8f51963d0f | ||
|
|
5c513e4629 | ||
|
|
38ece73768 | ||
|
|
e5b9806462 | ||
|
|
8dbb448b32 | ||
|
|
033d949325 | ||
|
|
643c0ebce1 | ||
|
|
4851a9aa5d | ||
|
|
fd765b113f | ||
|
|
fe801b0a1c | ||
|
|
dbc62fea32 | ||
|
|
1ad235866e | ||
|
|
05796d0165 | ||
|
|
f8e9ac93a0 | ||
|
|
04546f8c35 | ||
|
|
26450026bb | ||
|
|
3a17cc1331 | ||
|
|
e9f953f731 | ||
|
|
2c5c78b83c |
52
.github/workflows/latex-lint.yml
vendored
Normal file
52
.github/workflows/latex-lint.yml
vendored
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
name: LaTeX Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- dev
|
||||||
|
paths:
|
||||||
|
- 'latex/**/*.tex'
|
||||||
|
- 'latex/main.tex'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install chktex
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y chktex
|
||||||
|
|
||||||
|
- name: Run chktex inside latex/
|
||||||
|
working-directory: latex
|
||||||
|
run: |
|
||||||
|
TEX_FILES=$(find . -type f -name "*.tex")
|
||||||
|
if [ -z "$TEX_FILES" ]; then
|
||||||
|
echo "No .tex files found in latex/. Skipping lint."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "🔍 Linting .tex files with chktex..."
|
||||||
|
FAIL=0
|
||||||
|
|
||||||
|
for f in $TEX_FILES; do
|
||||||
|
echo "▶ Checking $f"
|
||||||
|
# Run chktex and show output; capture error status
|
||||||
|
if ! chktex "$f"; then
|
||||||
|
echo "::warning file=$f::ChkTeX found issues in $f"
|
||||||
|
FAIL=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ $FAIL -ne 0 ]; then
|
||||||
|
echo "::error::❌ Lint errors or warnings were found in one or more .tex files above."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "✅ All files passed chktex lint."
|
||||||
|
fi
|
||||||
102
.github/workflows/latexdiff.yml
vendored
Normal file
102
.github/workflows/latexdiff.yml
vendored
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
name: LaTeX Diff
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
base_branch:
|
||||||
|
description: 'Base branch (older version)'
|
||||||
|
required: true
|
||||||
|
compare_branch:
|
||||||
|
description: 'Compare branch (new version)'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
latexdiff:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ghcr.io/xu-cheng/texlive-full:latest
|
||||||
|
options: --user root
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install latexpand (Perl script)
|
||||||
|
run: |
|
||||||
|
tlmgr init-usertree
|
||||||
|
tlmgr install latexpand
|
||||||
|
|
||||||
|
- name: Checkout base branch
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.inputs.base_branch }}
|
||||||
|
path: base
|
||||||
|
|
||||||
|
- name: Checkout compare branch
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.inputs.compare_branch }}
|
||||||
|
path: compare
|
||||||
|
|
||||||
|
|
||||||
|
- name: Create output folder
|
||||||
|
run: mkdir -p diff_output
|
||||||
|
|
||||||
|
- name: Flatten base/main.tex (with latexpand)
|
||||||
|
run: |
|
||||||
|
cd base/latex
|
||||||
|
echo "📂 Listing files in base/latex:"
|
||||||
|
ls -R
|
||||||
|
echo "🔄 Flattening with latexpand..."
|
||||||
|
latexpand --verbose --keep-comments --output=../../diff_output/base_flat.tex main.tex
|
||||||
|
echo "✅ Preview of base_flat.tex:"
|
||||||
|
head -n 50 ../../diff_output/base_flat.tex
|
||||||
|
|
||||||
|
|
||||||
|
- name: Flatten compare/main.tex (with latexpand)
|
||||||
|
run: |
|
||||||
|
cd compare/latex
|
||||||
|
echo "📂 Listing files in compare/latex:"
|
||||||
|
ls -R
|
||||||
|
echo "🔄 Flattening with latexpand..."
|
||||||
|
latexpand --verbose --keep-comments --output=../../diff_output/compare_flat.tex main.tex
|
||||||
|
echo "✅ Preview of compare_flat.tex:"
|
||||||
|
head -n 50 ../../diff_output/compare_flat.tex
|
||||||
|
|
||||||
|
- name: Generate diff.tex using latexdiff
|
||||||
|
run: |
|
||||||
|
latexdiff diff_output/base_flat.tex diff_output/compare_flat.tex > diff_output/diff.tex
|
||||||
|
|
||||||
|
- name: Copy thesis.cls to diff_output
|
||||||
|
run: cp compare/latex/thesis.cls diff_output/
|
||||||
|
|
||||||
|
- name: Copy chapters/img into diff_output
|
||||||
|
run: |
|
||||||
|
# Create the same chapters/img path inside diff_output
|
||||||
|
mkdir -p diff_output/chapters/img
|
||||||
|
# Copy all images from compare branch into diff_output
|
||||||
|
cp -R compare/latex/chapters/img/* diff_output/chapters/img/
|
||||||
|
|
||||||
|
- name: Copy .bib files into diff_output
|
||||||
|
run: |
|
||||||
|
mkdir -p diff_output
|
||||||
|
cp compare/latex/*.bib diff_output/
|
||||||
|
|
||||||
|
- name: Override “\input{preamble/fonts}” in diff.tex
|
||||||
|
run: |
|
||||||
|
sed -i "/\\input{preamble\/fonts}/c % — replaced by CI: use TeX Gyre fonts instead of Times New Roman\/Arial\n\\\setmainfont{TeX Gyre Termes}\n\\\setsansfont{TeX Gyre Heros}\n\\\setmonofont{TeX Gyre Cursor}" diff_output/diff.tex
|
||||||
|
|
||||||
|
- name: Print preview of diff.tex (after font override)
|
||||||
|
run: |
|
||||||
|
echo "📄 Preview of diff_output/diff.tex after font override:"
|
||||||
|
head -n 50 diff_output/diff.tex
|
||||||
|
|
||||||
|
- name: Compile diff.tex to PDF
|
||||||
|
working-directory: diff_output
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
xelatex -interaction=nonstopmode diff.tex
|
||||||
|
xelatex -interaction=nonstopmode diff.tex
|
||||||
|
|
||||||
|
- name: Upload diff output files
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: latex-diff-output
|
||||||
|
path: diff_output/
|
||||||
29
.github/workflows/latexmk.yml
vendored
Normal file
29
.github/workflows/latexmk.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
name: Render XeLaTeX on PR to dev
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- dev
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-pdf:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Compile XeLaTeX
|
||||||
|
uses: dante-ev/latex-action@2021-A
|
||||||
|
with:
|
||||||
|
root_file: main.tex
|
||||||
|
working_directory: latex
|
||||||
|
compiler: xelatex
|
||||||
|
args: -interaction=nonstopmode -halt-on-error -file-line-error
|
||||||
|
extra_system_packages: "fonts-freefont-otf"
|
||||||
|
|
||||||
|
- name: Upload compiled PDF
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: compiled-pdf
|
||||||
|
path: latex/main.pdf
|
||||||
@@ -4,20 +4,14 @@ This repository contains the work related to my thesis, which focuses on damage
|
|||||||
|
|
||||||
**Note:** This repository does not contain the secondary data used in the analysis. The code is designed to work with data from the [QUGS (Qatar University Grandstand Simulator)](https://www.structuralvibration.com/benchmark/qugs/) dataset, which is not included here.
|
**Note:** This repository does not contain the secondary data used in the analysis. The code is designed to work with data from the [QUGS (Qatar University Grandstand Simulator)](https://www.structuralvibration.com/benchmark/qugs/) dataset, which is not included here.
|
||||||
|
|
||||||
The repository is private and access is restricted only to those who have been given explicit permission by the owner. Access is provided solely for the purpose of brief review or seeking technical guidance.
|
|
||||||
|
|
||||||
## Restrictions
|
## Restrictions
|
||||||
|
|
||||||
- **No Derivative Works or Cloning:** Any form of copying, cloning, or creating derivative works based on this repository is strictly prohibited.
|
- **No Derivative Works or Cloning:** Any form of copying, cloning, or creating derivative works based on this repository is strictly prohibited.
|
||||||
- **Limited Access:** Use beyond brief review or collaboration is not allowed without prior permission from the owner.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
All contents of this repository, including the thesis idea, code, and associated data, are copyrighted © 2024 by Rifqi Panuluh. Unauthorized use or duplication is prohibited.
|
|
||||||
|
|
||||||
[LICENSE](https://github.com/nuluh/thesis?tab=License-1-ov-file#readme)
|
[LICENSE](https://github.com/nuluh/thesis?tab=License-1-ov-file#readme)
|
||||||
|
|
||||||
## How to Run `stft.ipynb`
|
## How to Run `stft.ipynb`
|
||||||
|
|
||||||
1. run `pip install -e .` in root project first
|
1. run `pip install -e .` in root project first
|
||||||
|
|
||||||
2. run the notebook
|
2. run the notebook
|
||||||
@@ -334,9 +334,8 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# len(ready_data1a)\n",
|
"len(ready_data1a)\n",
|
||||||
"# plt.pcolormesh(ready_data1[0])\n",
|
"# plt.pcolormesh(ready_data1[0])"
|
||||||
"ready_data1a[0].max().max()"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -346,8 +345,7 @@
|
|||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"for i in range(6):\n",
|
"for i in range(6):\n",
|
||||||
" plt.pcolormesh(ready_data1a[i], cmap=\"jet\", vmax=0.03, vmin=0.0)\n",
|
" plt.pcolormesh(ready_data1a[i])\n",
|
||||||
" plt.colorbar() \n",
|
|
||||||
" plt.title(f'STFT Magnitude for case {i} sensor 1')\n",
|
" plt.title(f'STFT Magnitude for case {i} sensor 1')\n",
|
||||||
" plt.xlabel(f'Frequency [Hz]')\n",
|
" plt.xlabel(f'Frequency [Hz]')\n",
|
||||||
" plt.ylabel(f'Time [sec]')\n",
|
" plt.ylabel(f'Time [sec]')\n",
|
||||||
@@ -537,8 +535,8 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"len(y_data[0])\n",
|
"# len(y_data[0])\n",
|
||||||
"# y_data"
|
"y_data"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -621,15 +619,137 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"def train_and_evaluate_model(model, model_name, sensor_label, x_train, y_train, x_test, y_test):\n",
|
"accuracies1 = []\n",
|
||||||
" model.fit(x_train, y_train)\n",
|
"accuracies2 = []\n",
|
||||||
" y_pred = model.predict(x_test)\n",
|
"\n",
|
||||||
" accuracy = accuracy_score(y_test, y_pred) * 100\n",
|
"\n",
|
||||||
" return {\n",
|
"# 1. Random Forest\n",
|
||||||
" \"model\": model_name,\n",
|
"rf_model1 = RandomForestClassifier()\n",
|
||||||
" \"sensor\": sensor_label,\n",
|
"rf_model1.fit(x_train1, y_train)\n",
|
||||||
" \"accuracy\": accuracy\n",
|
"rf_pred1 = rf_model1.predict(x_test1)\n",
|
||||||
" }"
|
"acc1 = accuracy_score(y_test, rf_pred1) * 100\n",
|
||||||
|
"accuracies1.append(acc1)\n",
|
||||||
|
"# format with color coded if acc1 > 90\n",
|
||||||
|
"acc1 = f\"\\033[92m{acc1:.2f}\\033[00m\" if acc1 > 90 else f\"{acc1:.2f}\"\n",
|
||||||
|
"print(\"Random Forest Accuracy for sensor 1:\", acc1)\n",
|
||||||
|
"rf_model2 = RandomForestClassifier()\n",
|
||||||
|
"rf_model2.fit(x_train2, y_train)\n",
|
||||||
|
"rf_pred2 = rf_model2.predict(x_test2)\n",
|
||||||
|
"acc2 = accuracy_score(y_test, rf_pred2) * 100\n",
|
||||||
|
"accuracies2.append(acc2)\n",
|
||||||
|
"# format with color coded if acc2 > 90\n",
|
||||||
|
"acc2 = f\"\\033[92m{acc2:.2f}\\033[00m\" if acc2 > 90 else f\"{acc2:.2f}\"\n",
|
||||||
|
"print(\"Random Forest Accuracy for sensor 2:\", acc2)\n",
|
||||||
|
"# print(rf_pred)\n",
|
||||||
|
"# print(y_test)\n",
|
||||||
|
"\n",
|
||||||
|
"# 2. Bagged Trees\n",
|
||||||
|
"bagged_model1 = BaggingClassifier(estimator=DecisionTreeClassifier(), n_estimators=10)\n",
|
||||||
|
"bagged_model1.fit(x_train1, y_train)\n",
|
||||||
|
"bagged_pred1 = bagged_model1.predict(x_test1)\n",
|
||||||
|
"acc1 = accuracy_score(y_test, bagged_pred1) * 100\n",
|
||||||
|
"accuracies1.append(acc1)\n",
|
||||||
|
"# format with color coded if acc1 > 90\n",
|
||||||
|
"acc1 = f\"\\033[92m{acc1:.2f}\\033[00m\" if acc1 > 90 else f\"{acc1:.2f}\"\n",
|
||||||
|
"print(\"Bagged Trees Accuracy for sensor 1:\", acc1)\n",
|
||||||
|
"bagged_model2 = BaggingClassifier(estimator=DecisionTreeClassifier(), n_estimators=10)\n",
|
||||||
|
"bagged_model2.fit(x_train2, y_train)\n",
|
||||||
|
"bagged_pred2 = bagged_model2.predict(x_test2)\n",
|
||||||
|
"acc2 = accuracy_score(y_test, bagged_pred2) * 100\n",
|
||||||
|
"accuracies2.append(acc2)\n",
|
||||||
|
"# format with color coded if acc2 > 90\n",
|
||||||
|
"acc2 = f\"\\033[92m{acc2:.2f}\\033[00m\" if acc2 > 90 else f\"{acc2:.2f}\"\n",
|
||||||
|
"print(\"Bagged Trees Accuracy for sensor 2:\", acc2)\n",
|
||||||
|
"\n",
|
||||||
|
"# 3. Decision Tree\n",
|
||||||
|
"dt_model = DecisionTreeClassifier()\n",
|
||||||
|
"dt_model.fit(x_train1, y_train)\n",
|
||||||
|
"dt_pred1 = dt_model.predict(x_test1)\n",
|
||||||
|
"acc1 = accuracy_score(y_test, dt_pred1) * 100\n",
|
||||||
|
"accuracies1.append(acc1)\n",
|
||||||
|
"# format with color coded if acc1 > 90\n",
|
||||||
|
"acc1 = f\"\\033[92m{acc1:.2f}\\033[00m\" if acc1 > 90 else f\"{acc1:.2f}\"\n",
|
||||||
|
"print(\"Decision Tree Accuracy for sensor 1:\", acc1)\n",
|
||||||
|
"dt_model2 = DecisionTreeClassifier()\n",
|
||||||
|
"dt_model2.fit(x_train2, y_train)\n",
|
||||||
|
"dt_pred2 = dt_model2.predict(x_test2)\n",
|
||||||
|
"acc2 = accuracy_score(y_test, dt_pred2) * 100\n",
|
||||||
|
"accuracies2.append(acc2)\n",
|
||||||
|
"# format with color coded if acc2 > 90\n",
|
||||||
|
"acc2 = f\"\\033[92m{acc2:.2f}\\033[00m\" if acc2 > 90 else f\"{acc2:.2f}\"\n",
|
||||||
|
"print(\"Decision Tree Accuracy for sensor 2:\", acc2)\n",
|
||||||
|
"\n",
|
||||||
|
"# 4. KNeighbors\n",
|
||||||
|
"knn_model = KNeighborsClassifier()\n",
|
||||||
|
"knn_model.fit(x_train1, y_train)\n",
|
||||||
|
"knn_pred1 = knn_model.predict(x_test1)\n",
|
||||||
|
"acc1 = accuracy_score(y_test, knn_pred1) * 100\n",
|
||||||
|
"accuracies1.append(acc1)\n",
|
||||||
|
"# format with color coded if acc1 > 90\n",
|
||||||
|
"acc1 = f\"\\033[92m{acc1:.2f}\\033[00m\" if acc1 > 90 else f\"{acc1:.2f}\"\n",
|
||||||
|
"print(\"KNeighbors Accuracy for sensor 1:\", acc1)\n",
|
||||||
|
"knn_model2 = KNeighborsClassifier()\n",
|
||||||
|
"knn_model2.fit(x_train2, y_train)\n",
|
||||||
|
"knn_pred2 = knn_model2.predict(x_test2)\n",
|
||||||
|
"acc2 = accuracy_score(y_test, knn_pred2) * 100\n",
|
||||||
|
"accuracies2.append(acc2)\n",
|
||||||
|
"# format with color coded if acc2 > 90\n",
|
||||||
|
"acc2 = f\"\\033[92m{acc2:.2f}\\033[00m\" if acc2 > 90 else f\"{acc2:.2f}\"\n",
|
||||||
|
"print(\"KNeighbors Accuracy for sensor 2:\", acc2)\n",
|
||||||
|
"\n",
|
||||||
|
"# 5. Linear Discriminant Analysis\n",
|
||||||
|
"lda_model = LinearDiscriminantAnalysis()\n",
|
||||||
|
"lda_model.fit(x_train1, y_train)\n",
|
||||||
|
"lda_pred1 = lda_model.predict(x_test1)\n",
|
||||||
|
"acc1 = accuracy_score(y_test, lda_pred1) * 100\n",
|
||||||
|
"accuracies1.append(acc1)\n",
|
||||||
|
"# format with color coded if acc1 > 90\n",
|
||||||
|
"acc1 = f\"\\033[92m{acc1:.2f}\\033[00m\" if acc1 > 90 else f\"{acc1:.2f}\"\n",
|
||||||
|
"print(\"Linear Discriminant Analysis Accuracy for sensor 1:\", acc1)\n",
|
||||||
|
"lda_model2 = LinearDiscriminantAnalysis()\n",
|
||||||
|
"lda_model2.fit(x_train2, y_train)\n",
|
||||||
|
"lda_pred2 = lda_model2.predict(x_test2)\n",
|
||||||
|
"acc2 = accuracy_score(y_test, lda_pred2) * 100\n",
|
||||||
|
"accuracies2.append(acc2)\n",
|
||||||
|
"# format with color coded if acc2 > 90\n",
|
||||||
|
"acc2 = f\"\\033[92m{acc2:.2f}\\033[00m\" if acc2 > 90 else f\"{acc2:.2f}\"\n",
|
||||||
|
"print(\"Linear Discriminant Analysis Accuracy for sensor 2:\", acc2)\n",
|
||||||
|
"\n",
|
||||||
|
"# 6. Support Vector Machine\n",
|
||||||
|
"svm_model = SVC()\n",
|
||||||
|
"svm_model.fit(x_train1, y_train)\n",
|
||||||
|
"svm_pred1 = svm_model.predict(x_test1)\n",
|
||||||
|
"acc1 = accuracy_score(y_test, svm_pred1) * 100\n",
|
||||||
|
"accuracies1.append(acc1)\n",
|
||||||
|
"# format with color coded if acc1 > 90\n",
|
||||||
|
"acc1 = f\"\\033[92m{acc1:.2f}\\033[00m\" if acc1 > 90 else f\"{acc1:.2f}\"\n",
|
||||||
|
"print(\"Support Vector Machine Accuracy for sensor 1:\", acc1)\n",
|
||||||
|
"svm_model2 = SVC()\n",
|
||||||
|
"svm_model2.fit(x_train2, y_train)\n",
|
||||||
|
"svm_pred2 = svm_model2.predict(x_test2)\n",
|
||||||
|
"acc2 = accuracy_score(y_test, svm_pred2) * 100\n",
|
||||||
|
"accuracies2.append(acc2)\n",
|
||||||
|
"# format with color coded if acc2 > 90\n",
|
||||||
|
"acc2 = f\"\\033[92m{acc2:.2f}\\033[00m\" if acc2 > 90 else f\"{acc2:.2f}\"\n",
|
||||||
|
"print(\"Support Vector Machine Accuracy for sensor 2:\", acc2)\n",
|
||||||
|
"\n",
|
||||||
|
"# 7. XGBoost\n",
|
||||||
|
"xgboost_model = XGBClassifier()\n",
|
||||||
|
"xgboost_model.fit(x_train1, y_train)\n",
|
||||||
|
"xgboost_pred1 = xgboost_model.predict(x_test1)\n",
|
||||||
|
"acc1 = accuracy_score(y_test, xgboost_pred1) * 100\n",
|
||||||
|
"accuracies1.append(acc1)\n",
|
||||||
|
"# format with color coded if acc1 > 90\n",
|
||||||
|
"acc1 = f\"\\033[92m{acc1:.2f}\\033[00m\" if acc1 > 90 else f\"{acc1:.2f}\"\n",
|
||||||
|
"print(\"XGBoost Accuracy:\", acc1)\n",
|
||||||
|
"xgboost_model2 = XGBClassifier()\n",
|
||||||
|
"xgboost_model2.fit(x_train2, y_train)\n",
|
||||||
|
"xgboost_pred2 = xgboost_model2.predict(x_test2)\n",
|
||||||
|
"acc2 = accuracy_score(y_test, xgboost_pred2) * 100\n",
|
||||||
|
"accuracies2.append(acc2)\n",
|
||||||
|
"# format with color coded if acc2 > 90\n",
|
||||||
|
"acc2 = f\"\\033[92m{acc2:.2f}\\033[00m\" if acc2 > 90 else f\"{acc2:.2f}\"\n",
|
||||||
|
"print(\"XGBoost Accuracy:\", acc2)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -638,59 +758,8 @@
|
|||||||
"metadata": {},
|
"metadata": {},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
"# Define models for sensor1\n",
|
"print(accuracies1)\n",
|
||||||
"models_sensor1 = {\n",
|
"print(accuracies2)"
|
||||||
" # \"Random Forest\": RandomForestClassifier(),\n",
|
|
||||||
" # \"Bagged Trees\": BaggingClassifier(estimator=DecisionTreeClassifier(), n_estimators=10),\n",
|
|
||||||
" # \"Decision Tree\": DecisionTreeClassifier(),\n",
|
|
||||||
" # \"KNN\": KNeighborsClassifier(),\n",
|
|
||||||
" # \"LDA\": LinearDiscriminantAnalysis(),\n",
|
|
||||||
" \"SVM\": SVC(),\n",
|
|
||||||
" \"XGBoost\": XGBClassifier()\n",
|
|
||||||
"}\n",
|
|
||||||
"\n",
|
|
||||||
"results_sensor1 = []\n",
|
|
||||||
"for name, model in models_sensor1.items():\n",
|
|
||||||
" res = train_and_evaluate_model(model, name, \"sensor1\", x_train1, y_train, x_test1, y_test)\n",
|
|
||||||
" results_sensor1.append(res)\n",
|
|
||||||
" print(f\"{name} on sensor1: Accuracy = {res['accuracy']:.2f}%\")\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"models_sensor2 = {\n",
|
|
||||||
" # \"Random Forest\": RandomForestClassifier(),\n",
|
|
||||||
" # \"Bagged Trees\": BaggingClassifier(estimator=DecisionTreeClassifier(), n_estimators=10),\n",
|
|
||||||
" # \"Decision Tree\": DecisionTreeClassifier(),\n",
|
|
||||||
" # \"KNN\": KNeighborsClassifier(),\n",
|
|
||||||
" # \"LDA\": LinearDiscriminantAnalysis(),\n",
|
|
||||||
" \"SVM\": SVC(),\n",
|
|
||||||
" \"XGBoost\": XGBClassifier()\n",
|
|
||||||
"}\n",
|
|
||||||
"\n",
|
|
||||||
"results_sensor2 = []\n",
|
|
||||||
"for name, model in models_sensor2.items():\n",
|
|
||||||
" res = train_and_evaluate_model(model, name, \"sensor2\", x_train2, y_train, x_test2, y_test)\n",
|
|
||||||
" results_sensor2.append(res)\n",
|
|
||||||
" print(f\"{name} on sensor2: Accuracy = {res['accuracy']:.2f}%\")\n"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": null,
|
|
||||||
"metadata": {},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"all_results = {\n",
|
|
||||||
" \"sensor1\": results_sensor1,\n",
|
|
||||||
" \"sensor2\": results_sensor2\n",
|
|
||||||
"}\n",
|
|
||||||
"\n",
|
|
||||||
"print(all_results)"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -702,48 +771,36 @@
|
|||||||
"import numpy as np\n",
|
"import numpy as np\n",
|
||||||
"import matplotlib.pyplot as plt\n",
|
"import matplotlib.pyplot as plt\n",
|
||||||
"\n",
|
"\n",
|
||||||
"def prepare_plot_data(results_dict):\n",
|
"models = [rf_model, bagged_model, dt_model, knn_model, lda_model, svm_model, xgboost_model]\n",
|
||||||
" # Gather unique model names\n",
|
"model_names = [\"Random Forest\", \"Bagged Trees\", \"Decision Tree\", \"KNN\", \"LDA\", \"SVM\", \"XGBoost\"]\n",
|
||||||
" models_set = {entry['model'] for sensor in results_dict.values() for entry in sensor}\n",
|
|
||||||
" models = sorted(list(models_set))\n",
|
|
||||||
" \n",
|
|
||||||
" # Create dictionaries mapping sensor -> accuracy list ordered by model name\n",
|
|
||||||
" sensor_accuracies = {}\n",
|
|
||||||
" for sensor, entries in results_dict.items():\n",
|
|
||||||
" # Build a mapping: model -> accuracy for the given sensor\n",
|
|
||||||
" mapping = {entry['model']: entry['accuracy'] for entry in entries}\n",
|
|
||||||
" # Order the accuracies consistent with the sorted model names\n",
|
|
||||||
" sensor_accuracies[sensor] = [mapping.get(model, 0) for model in models]\n",
|
|
||||||
" \n",
|
|
||||||
" return models, sensor_accuracies\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"def plot_accuracies(models, sensor_accuracies):\n",
|
"bar_width = 0.35 # Width of each bar\n",
|
||||||
" bar_width = 0.35\n",
|
"index = np.arange(len(model_names)) # Index for the bars\n",
|
||||||
" x = np.arange(len(models))\n",
|
|
||||||
" sensors = list(sensor_accuracies.keys())\n",
|
|
||||||
" \n",
|
|
||||||
" plt.figure(figsize=(10, 6))\n",
|
|
||||||
" # Assume two sensors for plotting grouped bars\n",
|
|
||||||
" plt.bar(x - bar_width/2, sensor_accuracies[sensors[0]], width=bar_width, color='blue', label=sensors[0])\n",
|
|
||||||
" plt.bar(x + bar_width/2, sensor_accuracies[sensors[1]], width=bar_width, color='orange', label=sensors[1])\n",
|
|
||||||
" \n",
|
|
||||||
" # Add text labels on top of bars\n",
|
|
||||||
" for i, (a1, a2) in enumerate(zip(sensor_accuracies[sensors[0]], sensor_accuracies[sensors[1]])):\n",
|
|
||||||
" plt.text(x[i] - bar_width/2, a1 + 0.1, f\"{a1:.2f}%\", ha='center', va='bottom', color='black')\n",
|
|
||||||
" plt.text(x[i] + bar_width/2, a2 + 0.1, f\"{a2:.2f}%\", ha='center', va='bottom', color='black')\n",
|
|
||||||
" \n",
|
|
||||||
" plt.xlabel('Model Name')\n",
|
|
||||||
" plt.ylabel('Accuracy (%)')\n",
|
|
||||||
" plt.title('Accuracy of Classifiers for Each Sensor')\n",
|
|
||||||
" plt.xticks(x, models)\n",
|
|
||||||
" plt.legend()\n",
|
|
||||||
" plt.ylim(0, 105)\n",
|
|
||||||
" plt.tight_layout()\n",
|
|
||||||
" plt.show()\n",
|
|
||||||
"\n",
|
"\n",
|
||||||
"# Use the functions\n",
|
"# Plotting the bar graph\n",
|
||||||
"models, sensor_accuracies = prepare_plot_data(all_results)\n",
|
"plt.figure(figsize=(14, 8))\n",
|
||||||
"plot_accuracies(models, sensor_accuracies)\n"
|
"\n",
|
||||||
|
"# Bar plot for Sensor 1\n",
|
||||||
|
"plt.bar(index, accuracies1, width=bar_width, color='blue', label='Sensor 1')\n",
|
||||||
|
"\n",
|
||||||
|
"# Bar plot for Sensor 2\n",
|
||||||
|
"plt.bar(index + bar_width, accuracies2, width=bar_width, color='orange', label='Sensor 2')\n",
|
||||||
|
"\n",
|
||||||
|
"# Add values on top of each bar\n",
|
||||||
|
"for i, acc1, acc2 in zip(index, accuracies1, accuracies2):\n",
|
||||||
|
" plt.text(i, acc1 + .1, f'{acc1:.2f}%', ha='center', va='bottom', color='black')\n",
|
||||||
|
" plt.text(i + bar_width, acc2 + 1, f'{acc2:.2f}%', ha='center', va='bottom', color='black')\n",
|
||||||
|
"\n",
|
||||||
|
"# Customize the plot\n",
|
||||||
|
"plt.xlabel('Model Name →')\n",
|
||||||
|
"plt.ylabel('Accuracy →')\n",
|
||||||
|
"plt.title('Accuracy of classifiers for Sensors 1 and 2 with 513 features')\n",
|
||||||
|
"plt.xticks(index + bar_width / 2, model_names) # Set x-tick positions\n",
|
||||||
|
"plt.legend()\n",
|
||||||
|
"plt.ylim(0, 100)\n",
|
||||||
|
"\n",
|
||||||
|
"# Show the plot\n",
|
||||||
|
"plt.show()\n"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
% % A new command that enables us to enter bi-lingual (Slovene and English) terms
|
|
||||||
% % syntax: \addterm[options]{label}{Slovene}{Slovene first use}{English}{Slovene
|
|
||||||
% % description}
|
|
||||||
% \newcommand{\addterm}[6][]{
|
|
||||||
% \newglossaryentry{#2}{
|
|
||||||
% name={#3 (angl.\ #5)},
|
|
||||||
% first={#4 (\emph{#5})},
|
|
||||||
% text={#3},
|
|
||||||
% sort={#3},
|
|
||||||
% description={#6},
|
|
||||||
% #1 % pass additional options to \newglossaryentry
|
|
||||||
% }
|
|
||||||
% }
|
|
||||||
|
|
||||||
% % A new command that enables us to enter (English) acronyms with bi-lingual
|
|
||||||
% % (Slovene and English) long versions
|
|
||||||
% % syntax: \addacronym[options]{label}{abbreviation}{Slovene long}{Slovene first
|
|
||||||
% % use long}{English long}{Slovene description}
|
|
||||||
% \newcommand{\addacronym}[7][]{
|
|
||||||
% % Create the main glossary entry with \newacronym
|
|
||||||
% % \newacronym[key-val list]{label}{abbrv}{long}
|
|
||||||
% \newacronym[
|
|
||||||
% name={#4 (angl.\ #6,\ #3)},
|
|
||||||
% first={\emph{#5} (angl.\ \emph{#6},\ \emph{#3})},
|
|
||||||
% sort={#4},
|
|
||||||
% description={#7},
|
|
||||||
% #1 % pass additional options to \newglossaryentry
|
|
||||||
% ]
|
|
||||||
% {#2}{#3}{#4}
|
|
||||||
% % Create a cross-reference from the abbreviation to the main glossary entry by
|
|
||||||
% % creating an auxiliary glossary entry (note: we set the label of this entry
|
|
||||||
% % to '<original label>_auxiliary' to avoid clashes)
|
|
||||||
% \newglossaryentry{#2_auxiliary}{
|
|
||||||
% name={#3},
|
|
||||||
% sort={#3},
|
|
||||||
% description={\makefirstuc{#6}},
|
|
||||||
% see=[See:]{#2}
|
|
||||||
% }
|
|
||||||
% }
|
|
||||||
|
|
||||||
% % Change the text of the cross-reference links to the Slovene long version.
|
|
||||||
% \renewcommand*{\glsseeitemformat}[1]{\emph{\acrlong{#1}}.}
|
|
||||||
|
|
||||||
% Define the Indonesian term and link it to the English term
|
|
||||||
\newglossaryentry{jaringansaraf}{
|
|
||||||
name=Jaringan Saraf,
|
|
||||||
description={The Indonesian term for \gls{nn}}
|
|
||||||
}
|
|
||||||
% \newglossaryentry{pemelajaranmesin}{
|
|
||||||
% name=Pemelajaran Mesin,
|
|
||||||
% description={Lihat \gls{machinelearning}}
|
|
||||||
% }
|
|
||||||
|
|
||||||
% Define the English term and link it to its acronym
|
|
||||||
\newglossaryentry{neuralnetwork}{
|
|
||||||
name=Neural Network,
|
|
||||||
description={A computational model inspired by the human brain, see \gls{nn}}
|
|
||||||
}
|
|
||||||
|
|
||||||
% \newglossaryentry{machinelearning}{
|
|
||||||
% name=Machine Learning,
|
|
||||||
% description={A program or system that trains a model from input data. The trained model can make useful predictions from new (never-before-seen) data drawn from the same distribution as the one used to train the model.}}
|
|
||||||
% \newglossaryentry{pemelajaranmesin}{
|
|
||||||
% name={pemelajaran mesin (angl.\ #5)},
|
|
||||||
% first={pemelajaran mesin (\emph{machine learning})},
|
|
||||||
% text={pemelajaran mesin},
|
|
||||||
% sort={ },
|
|
||||||
% description={#6},
|
|
||||||
% #1 % pass additional options to \newglossaryentry
|
|
||||||
% }
|
|
||||||
\longnewglossaryentry{machinelearning}{name={machine learning}}
|
|
||||||
{A program or system that trains a model from input data. The trained model can make useful predictions from new (never-before-seen) data drawn from the same distribution as the one used to train the model.}
|
|
||||||
\newterm[see={machinelearning}]{pemelajaranmesin}
|
|
||||||
% \newglossaryentry{pemelajaran mesin}{}
|
|
||||||
% \addterm{machinelearning}{pemelajaran mesin}{pemelajaran mesin}{machine learning}{A program or system that trains a model from input data. The trained model can make useful predictions from new (never-before-seen) data drawn from the same distribution as the one used to train the model.}
|
|
||||||
\newacronym
|
|
||||||
[description={statistical pattern recognition technique}]
|
|
||||||
{svm}{SVM}{support vector machine}
|
|
||||||
@@ -16,19 +16,22 @@
|
|||||||
\input{preamble/macros}
|
\input{preamble/macros}
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
\input{frontmatter/maketitle}
|
|
||||||
\input{frontmatter/maketitle_secondary}
|
\maketitle
|
||||||
\frontmatter
|
\frontmatter
|
||||||
% \input{frontmatter/approval}\clearpage
|
\input{frontmatter/approval}\clearpage
|
||||||
% \input{frontmatter/originality}\clearpage
|
\input{frontmatter/originality}\clearpage
|
||||||
% \input{frontmatter/acknowledgement}\clearpage
|
\input{frontmatter/acknowledgement}\clearpage
|
||||||
\tableofcontents
|
\tableofcontents
|
||||||
\clearpage
|
\clearpage
|
||||||
\mainmatter
|
\mainmatter
|
||||||
\pagestyle{fancyplain}
|
\pagestyle{fancyplain}
|
||||||
|
% Include content
|
||||||
|
\include{content/abstract}
|
||||||
|
\include{content/introduction}
|
||||||
\include{chapters/01_introduction}
|
\include{chapters/01_introduction}
|
||||||
\include{chapters/id/02_literature_review/index}
|
\include{content/chapter2}
|
||||||
\include{chapters/id/03_methodology/index}
|
\include{content/conclusion}
|
||||||
|
|
||||||
% Bibliography
|
% Bibliography
|
||||||
% \bibliographystyle{IEEEtran}
|
% \bibliographystyle{IEEEtran}
|
||||||
|
|||||||
@@ -24,14 +24,15 @@
|
|||||||
\RequirePackage{svg} % Allows including SVG images directly
|
\RequirePackage{svg} % Allows including SVG images directly
|
||||||
\RequirePackage{indentfirst} % Makes first paragraph after headings indented
|
\RequirePackage{indentfirst} % Makes first paragraph after headings indented
|
||||||
\RequirePackage{float} % Provides [H] option to force figure/table placement
|
\RequirePackage{float} % Provides [H] option to force figure/table placement
|
||||||
\RequirePackage[style=apa, backend=biber, language=indonesian]{biblatex}
|
|
||||||
% Polyglossia set language
|
% Polyglossia set language
|
||||||
\setdefaultlanguage[variant=indonesian]{malay} % Proper Indonesian language setup
|
+ \setdefaultlanguage[variant=indonesian]{malay} % Proper Indonesian language setup
|
||||||
\setotherlanguage{english} % Enables English as secondary language
|
+ \setotherlanguage{english} % Enables English as secondary language
|
||||||
\DefineBibliographyStrings{english}{% % Customizes bibliography text
|
|
||||||
andothers={dkk\adddot}, % Changes "et al." to "dkk."
|
+ \DefineBibliographyStrings{english}{% % Customizes bibliography text
|
||||||
pages={hlm\adddot}, % Changes "pp." to "hlm."
|
+ andothers={dkk\adddot}, % Changes "et al." to "dkk."
|
||||||
}
|
+ pages={hlm\adddot}, % Changes "pp." to "hlm."
|
||||||
|
+ }
|
||||||
|
|
||||||
% Conditionally load the watermark package and settings
|
% Conditionally load the watermark package and settings
|
||||||
\if@draftmark
|
\if@draftmark
|
||||||
@@ -55,6 +56,8 @@
|
|||||||
\setsansfont{Arial}
|
\setsansfont{Arial}
|
||||||
\setmonofont{Courier New}
|
\setmonofont{Courier New}
|
||||||
|
|
||||||
|
% Metadata commands
|
||||||
|
\input{metadata}
|
||||||
|
|
||||||
\newcommand{\setthesisinfo}[7]{%
|
\newcommand{\setthesisinfo}[7]{%
|
||||||
\renewcommand{\thesistitle}{#1}%
|
\renewcommand{\thesistitle}{#1}%
|
||||||
@@ -109,6 +112,9 @@
|
|||||||
|
|
||||||
% \titlespacing*{\chapter}{0pt}{-10pt}{20pt}
|
% \titlespacing*{\chapter}{0pt}{-10pt}{20pt}
|
||||||
|
|
||||||
|
% Redefine \maketitle
|
||||||
|
\renewcommand{\maketitle}{\input{frontmatter/maketitle}}
|
||||||
|
|
||||||
% Chapter & Section format
|
% Chapter & Section format
|
||||||
\renewcommand{\cftchapfont}{\normalsize\MakeUppercase}
|
\renewcommand{\cftchapfont}{\normalsize\MakeUppercase}
|
||||||
% \renewcommand{\cftsecfont}{}
|
% \renewcommand{\cftsecfont}{}
|
||||||
|
|||||||
Reference in New Issue
Block a user