Skip to content
Snippets Groups Projects
Commit aeed9d1f authored by Desi's avatar Desi
Browse files
parents bf40ab5b b9968950
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ from src.run_model_wrapper import main
#optimal hyperparameters from autors: 'POLY': {'periodicity': 1, 'power': 4}
params = {
'periodicity': [1, 2, 3],
'power': [1, 2, 3, 4,5,7]
'power': [1, 2, 3, 4,5]
}
def run_POLY(data, periodicity=1, power=3, n_jobs=1):
......@@ -22,4 +22,7 @@ model = 'POLY'
output_path = '../../../docs/evaluation/'
#writes results in .csv
main(run_POLY,params,model,data_folders = '../../../data/', model_type='unsupervised',output_dir = output_path)
\ No newline at end of file
main(run_POLY,params,model,data_folders = '../../../data/', model_type='unsupervised',output_dir = output_path)
#pip3 install -r requirements.txt
# python src/models/desi/call_poly.py
\ No newline at end of file
......@@ -261,11 +261,11 @@ def main(run_model, hyperparams, model_name, data_folders = '../../../data/', mo
#go through all files in train data and store additionally informations about group and anomaly types
grid_List = []
print(f"Start Processing files")
# print(f"Start Processing files")
#reutrns [{file_name:str,train_data:list,data:list, label:list, sliding_window:int}]
file_data_dict_list = preprocess_data(path_data_all)
print('Start Hyperparameter Tuning')
# print('Start Hyperparameter Tuning')
# Creates combinations of all hyperparameters
param_combinations = list(itertools.product(*hyperparams.values()))
#find hyperparametrs for each file:
......@@ -278,21 +278,21 @@ def main(run_model, hyperparams, model_name, data_folders = '../../../data/', mo
# Hyperparameter-Optimierung
best_params = hyperparameter_optimization(run_model, data,label,train_data, hyperparams,sliding_window,param_combinations,model_type)
print(f"File: {filename}, best hyperparameter: {best_params}")
# print(f"File: {filename}, best hyperparameter: {best_params}")
#grid_list looks like this: [{ params: {key:value}, file_name:str,train_data:list,data:list, label:list, sliding_window:int}]
grid_List.append({'file_name':filename,'params':best_params,'train_data':train_data,'data':data,'label':label,'sliding_window':sliding_window})
print('Start Training and evaluation')
# print('Start Training and evaluation')
results_list = train_test_model(run_model,grid_List,path_to_folder, model_type)
#convert list of dicts to a dict with lists
results = create_dict_from_array(results_list)
#check duration time
duration = sum(results['duration'])
print(f'Job done. Duration: {duration:.3f} seconds')
# print(f'Job done. Duration: {duration:.3f} seconds')
#store results for each model by folder
results_df = pd.DataFrame(results)
output_csv = os.path.join(output_dir,model_name + '.csv')
results_df.to_csv(output_csv, index=False)
print(f"Ergebnisse gespeichert in: {output_csv}")
# print(f"Ergebnisse gespeichert in: {output_csv}")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment