Skip to content

Commit a96ec6e

Browse files
committed
Minor refactor + renaming
1 parent 15eb23c commit a96ec6e

File tree

4 files changed

+20
-18
lines changed

4 files changed

+20
-18
lines changed

model/feature_selection_complete.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1) A ranking of all the features and the predicted model accuracy for using n-features - saved in the data_files_path.
1010
2) A plot of "# of features used" vs "Model Performance" - saved in the data_files_path.
1111
3) A .csv file containing a list of the features selected for optimal model performance - saved in the data_files_path.
12-
4) Two exported trained models, one classifier and one normalizer - saved in the Trained_Models directory.
12+
4) Two exported trained models, one classifier and one normalizer - saved in the Trained Models directory.
1313
5) Option to import this module and begin testing the pre-trained models (set TESTING = True - in model_config.py)
1414
1515
- The results have proved that the model has the highest accuracy when trained on all 51 features.
@@ -33,9 +33,12 @@
3333
from sklearn.model_selection import StratifiedKFold
3434
from sklearn.metrics import confusion_matrix, accuracy_score, precision_score, f1_score, recall_score, \
3535
roc_auc_score, classification_report
36-
from config import data_files_path, Path
36+
from config import data_files_path
3737
from model_config import *
3838

39+
# list of all feature labels + StepLabel
40+
cols = pd.read_csv(f'{new_sensor_paths[0]}/{os.listdir(new_sensor_paths[0])[0]}', sep='\t', index_col=0).columns
41+
3942
# Configuration Variables
4043
# Test on a separate dataset_operations
4144
DISJOINT_TESTING = False

model/feature_selection_voting.py

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
from model.feature_selection_complete import normalize
1616
from model_config import *
1717

18+
# list of all feature labels + StepLabel
19+
cols = pd.read_csv(f'{new_sensor_paths[0]}/{os.listdir(new_sensor_paths[0])[0]}', sep='\t', index_col=0).columns
20+
1821
# Global configurations
1922
# no. of best features to select
2023
n_features = 15

model_config.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
44
Attributes
55
----------
6-
cols : list of str
7-
List of all feature labels + StepLabel
86
row_count : int
97
No. of rows of dataset_operations to be used
108
RF_ESTIMATORS : int
@@ -34,9 +32,9 @@
3432
3533
DATA_PATH : str
3634
loading in the actual dataset_operations for one sensor (Data under test)
37-
NEW_DATASET : str
35+
PROCESSED_DATASET : str
3836
Directory name for new data set which contains the training/testing data for the classifier
39-
NEW_DATASET_PATH : str
37+
PROCESSED_DATASET_PATH : str
4038
Directory path for new data set which contains the training/testing data for the classifier
4139
TRAINED_MODEL_DIR : str
4240
Trained Model directory name
@@ -60,15 +58,13 @@
6058
from sklearn.preprocessing import MinMaxScaler
6159
from sklearn.ensemble import RandomForestClassifier
6260
from sklearn.model_selection import train_test_split
63-
from config import new_sensor_paths, ROOT, Path
61+
from config import new_sensor_paths, ROOT, Path, DATASETS
6462

6563
# Configuring locale for datetime purposes
66-
lang = 'de_DE'
67-
locale.setlocale(locale.LC_ALL, lang)
64+
lang = 'de_DE.UTF-8'
65+
locale.setlocale(locale.LC_TIME, lang)
6866

6967
# Model Configuration Variables
70-
# list of all feature labels + StepLabel
71-
cols = pd.read_csv(f'{new_sensor_paths[0]}/{os.listdir(new_sensor_paths[0])[0]}', sep='\t', index_col=0).columns
7268
# Setting numpy print precision
7369
np.set_printoptions(precision=5)
7470
# no. of rows of dataset_operations to be used
@@ -99,14 +95,14 @@
9995
EXPORT_MODEL = False
10096

10197
# Paths
102-
# loading in the actual dataset_operations for the ML classifier
103-
DATA_PATH = Path(f"{ROOT}/Features_Dataset/ds_all.csv")
10498
# Directory name for new data set which contains the training/testing data for the classifier
105-
NEW_DATASET = "Features_Dataset"
99+
PROCESSED_DATASET = "Processed_Dataset"
106100
# Directory path for new data set which contains the training/testing data for the classifier
107-
NEW_DATASET_PATH = Path(f'{ROOT}/{NEW_DATASET}')
101+
PROCESSED_DATASET_PATH = Path(f'{DATASETS}/{PROCESSED_DATASET}')
102+
# loading in the actual dataset for the ML classifier
103+
DATA_PATH = Path(f"{PROCESSED_DATASET_PATH}/ds_all.csv")
108104
# Trained Model directory name
109-
TRAINED_MODEL_DIR = 'Trained_Models'
105+
TRAINED_MODEL_DIR = 'Trained Models'
110106
# Trained Model directory path
111107
TRAINED_MODEL_PATH = Path(f'{ROOT}/{TRAINED_MODEL_DIR}')
112108
# Trained Model name

visualization/feature_plot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from dash.dependencies import Input, Output
1010
import plotly.graph_objs as go
1111
import numpy as np
12-
from config import Fs
12+
from config import Fs, DEBUGGER
1313
from itertools import compress
1414

1515
# Global variables
@@ -204,7 +204,7 @@ def feature_plot(sub, features_list, features, updated_step_positions, updated_s
204204
FEATURES = features
205205
STEP_POSITIONS = updated_step_positions
206206
STEP_POSITIONS_BOOL = updated_step_positions_bool
207-
app.run_server(debug=False, port=5001)
207+
app.run_server(debug=DEBUGGER, host="0.0.0.0", port=5001)
208208

209209

210210
if __name__ == '__main__':

0 commit comments

Comments
 (0)