Feat inference function #106
@@ -217,9 +217,6 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import os\n",
|
||||
"import pandas as pd\n",
|
||||
"import numpy as np\n",
|
||||
"from scipy.signal import hann\n",
|
||||
"import multiprocessing"
|
||||
]
|
||||
@@ -244,16 +241,6 @@
|
||||
"Fs = 1024"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Define the base directory where DAMAGE_X folders are located\n",
|
||||
"damage_base_path = 'D:/thesis/data/converted/raw'"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
@@ -304,11 +291,11 @@
|
||||
"# Import custom in-house functions\n",
|
||||
"from src.process_stft import process_damage_case\n",
|
||||
"\n",
|
||||
"num_damage_cases = 7 # DAMAGE_0 to DAMAGE_6\n",
|
||||
"num_damage_cases = 6 # DAMAGE_0 to DAMAGE_6\n",
|
||||
"\n",
|
||||
"with multiprocessing.Pool() as pool:\n",
|
||||
" # Process each DAMAGE_X case in parallel\n",
|
||||
" pool.map(process_damage_case, range(num_damage_cases), Fs, window_size, hop_size, output_dirs)"
|
||||
" pool.map(process_damage_case, range(num_damage_cases + 1))"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -665,24 +652,33 @@
|
||||
" # \"Decision Tree\": DecisionTreeClassifier(),\n",
|
||||
" # \"KNN\": KNeighborsClassifier(),\n",
|
||||
" # \"LDA\": LinearDiscriminantAnalysis(),\n",
|
||||
" # \"SVM\": make_pipeline(\n",
|
||||
" # StandardScaler(),\n",
|
||||
" # SVC(kernel='rbf', probability=True)\n",
|
||||
" # ),\n",
|
||||
" # \"SVM with StandardScaler and PCA\": make_pipeline(\n",
|
||||
" # StandardScaler(),\n",
|
||||
" # PCA(n_components=10),\n",
|
||||
" # SVC(kernel='rbf')\n",
|
||||
" # ),\n",
|
||||
" \"SVM\": make_pipeline(\n",
|
||||
" StandardScaler(),\n",
|
||||
" SVC(kernel='rbf')\n",
|
||||
" ),\n",
|
||||
" \"SVM with StandardScaler and PCA\": make_pipeline(\n",
|
||||
" StandardScaler(),\n",
|
||||
" PCA(n_components=10),\n",
|
||||
" SVC(kernel='rbf')\n",
|
||||
" ),\n",
|
||||
"\n",
|
||||
" # \"XGBoost\": XGBClassifier()\n",
|
||||
" \"MLPClassifier\": make_pipeline(\n",
|
||||
" StandardScaler(),\n",
|
||||
" MLPClassifier(hidden_layer_sizes=(1, 10), max_iter=500, random_state=42)\n",
|
||||
" )\n",
|
||||
" # \"MLPClassifier\": make_pipeline(\n",
|
||||
" # StandardScaler(),\n",
|
||||
" # MLPClassifier(hidden_layer_sizes=(1, 10), max_iter=500, random_state=42)\n",
|
||||
" # )\n",
|
||||
"}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"x_train1"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -712,9 +708,15 @@
|
||||
" # \"Decision Tree\": DecisionTreeClassifier(),\n",
|
||||
" # \"KNN\": KNeighborsClassifier(),\n",
|
||||
" # \"LDA\": LinearDiscriminantAnalysis(),\n",
|
||||
" \"SVM\": SVC(),\n",
|
||||
" # \"SVM with StandardScaler and PCA\": make_pipeline(\n",
|
||||
" # StandardScaler(),\n",
|
||||
" \"SVM\": make_pipeline(\n",
|
||||
" StandardScaler(),\n",
|
||||
" SVC(kernel='rbf')\n",
|
||||
" ),\n",
|
||||
" \"SVM with StandardScaler and PCA\": make_pipeline(\n",
|
||||
" StandardScaler(),\n",
|
||||
" PCA(n_components=10),\n",
|
||||
" SVC(kernel='rbf')\n",
|
||||
" ),\n",
|
||||
" # PCA(n_components=10),\n",
|
||||
" # SVC(kernel='rbf')\n",
|
||||
" # ),\n",
|
||||
@@ -730,8 +732,8 @@
|
||||
"source": [
|
||||
"results_sensor2 = []\n",
|
||||
"for name, model in models_sensor2.items():\n",
|
||||
" res = train_and_evaluate_model(model, name, \"sensor2\", x_train2, y_train2, x_test2, y_test2, \n",
|
||||
" export='D:/thesis/models/sensor2')\n",
|
||||
" res = train_and_evaluate_model(model, name, \"Sensor B\", x_train2, y_train2, x_test2, y_test2, \n",
|
||||
" export='D:/thesis/models/Sensor B')\n",
|
||||
" results_sensor2.append(res)\n",
|
||||
" print(f\"{name} on sensor2: Accuracy = {res['accuracy']:.2f}%\")\n",
|
||||
"\n",
|
||||
|
||||
Reference in New Issue
Block a user