Skip to content

Commit

Permalink
updated to include regression models
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-schwoebel authored Aug 14, 2020
1 parent 2d79d49 commit bbe7e8f
Showing 1 changed file with 41 additions and 10 deletions.
51 changes: 41 additions & 10 deletions models/model2csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,51 @@ def id_folder():

return metrics_list, model_names

curdir=os.getcwd()
metrics_list, model_names=id_folder()

# regression models
meanabsolute_errors=list()
meansquared_errors=list()
median_errors=list()
r2_scores=list()
regression_models=list()

for i in range(len(model_names)):
try:
meanabsolute_errors.append(metrics_list[i]['mean_absolute_error'])
meansquared_errors.append(metrics_list[i]['mean_squared_error'])
median_errors.append(metrics_list[i]['median_absolute_error'])
r2_scores.append(metrics_list[i]['r2_score'])
regression_models.append(model_names[i])
except:
pass

# classification models
accuracies=list()
roc_curve=list()
classification_models=list()

for i in range(len(model_names)):
accuracies.append(metrics_list[i]['accuracy'])
roc_curve.append(metrics_list[i]['roc_auc'])
try:
accuracies.append(metrics_list[i]['accuracy'])
roc_curve.append(metrics_list[i]['roc_auc'])
classification_models.append(model_names[i])
except:
pass

classification_data={'model names': classification_models,
'accuracies': accuracies,
'roc_auc': roc_curve}

data={'model names': model_names,
'accuracies': accuracies,
'roc_auc': roc_curve}
regression_data={'model_names': regression_models,
'mean_absolute_errors': meanabsolute_errors,
'mean_squared_errors': meansquared_errors,
'r2_scores': r2_scores}

print(model_names)
print(accuracies)
print(roc_curve)
os.chdir(curdir)
df=pd.DataFrame.from_dict(classification_data)
df.to_csv('classification_models.csv', index=False)

df=pd.DataFrame.from_dict(data)
df.to_csv('models.csv')
df=pd.DataFrame.from_dict(regression_data)
df.to_csv('regression_models.csv', index=False)

0 comments on commit bbe7e8f

Please sign in to comment.