saving work
This commit is contained in:
parent
a1631ea54b
commit
e28a296d98
8 changed files with 153 additions and 212 deletions
|
@ -7,55 +7,32 @@ Created on Fri Mar 11 11:15:50 2022
|
|||
"""
|
||||
#%%
|
||||
del(t3_res)
|
||||
t3_res = MultClassPipeSKF(input_df = numerical_features_df
|
||||
, y_targetF = target1
|
||||
# t3_res = MultClassPipeSKF(input_df = numerical_features_df
|
||||
# , y_targetF = target1
|
||||
# , var_type = 'numerical'
|
||||
# , skf_splits = 10)
|
||||
# pp.pprint(t3_res)
|
||||
# #print(t3_res)
|
||||
|
||||
t3_res = MultClassPipeSKF(input_df = num_df_wtgt[numerical_FN]
|
||||
, y_targetF = num_df_wtgt['mutation_class']
|
||||
, var_type = 'numerical'
|
||||
, skf_splits = 10)
|
||||
pp.pprint(t3_res)
|
||||
#print(t3_res)
|
||||
|
||||
#%% Manually: mean for each model, each metric
|
||||
model_name = 'Logistic Regression'
|
||||
model_name = 'Naive Bayes'
|
||||
model_name = 'K-Nearest Neighbors'
|
||||
model_name = 'SVM'
|
||||
#%%
|
||||
model_metric = 'F1_score'
|
||||
|
||||
log_reg_f1 = []
|
||||
for key in t3_res[model_name]:
|
||||
log_reg_f1.append(t3_res[model_name][key][model_metric])
|
||||
log_reg_f1M = mean(log_reg_f1)
|
||||
print('key:', key, model_metric, ':', log_reg_f1)
|
||||
print(log_reg_f1M)
|
||||
|
||||
log_reg_f1df = pd.DataFrame({model_name: [log_reg_f1M]}, index = [model_metric])
|
||||
log_reg_f1df
|
||||
|
||||
#%%
|
||||
model_metric = 'MCC'
|
||||
log_reg_mcc = []
|
||||
for key in t3_res[model_name]:
|
||||
log_reg_mcc.append(t3_res[model_name][key][model_metric])
|
||||
log_reg_mccM = mean(log_reg_mcc)
|
||||
print('key:', key, model_metric, ':', log_reg_mcc)
|
||||
print(log_reg_mccM)
|
||||
|
||||
log_reg_mccdf = pd.DataFrame({model_name: [log_reg_mccM]}, index = [model_metric])
|
||||
log_reg_mccdf
|
||||
#%%
|
||||
################################################################
|
||||
# extract items from wwithin a nested dict
|
||||
#%% Classification Metrics we need to mean()
|
||||
classification_metrics = {
|
||||
'F1_score': []
|
||||
,'MCC': []
|
||||
,'Precision': []
|
||||
,'Recall': []
|
||||
,'Accuracy': []
|
||||
}
|
||||
# classification_metrics = {
|
||||
# 'F1_score': []
|
||||
# ,'MCC': []
|
||||
# ,'Precision': []
|
||||
# ,'Recall': []
|
||||
# ,'Accuracy': []
|
||||
# ,'ROC_AUC':[]
|
||||
# }
|
||||
# "mean() of the current metric across all folds for this model"
|
||||
|
||||
# the output containing all the metrics across all folds for this model
|
||||
out={}
|
||||
# Just the mean() for each of the above metrics-per-model
|
||||
|
@ -64,16 +41,16 @@ out_means={}
|
|||
# Build up out{} from t3_res, which came from loopity_loop
|
||||
for model in t3_res:
|
||||
# NOTE: can't copy objects in Python!!!
|
||||
out[model]={'F1_score': [], 'MCC': [], 'Precision': [], 'Recall': [], 'Accuracy': []}
|
||||
out[model]={'F1_score': [], 'MCC': [], 'Precision': [], 'Recall': [], 'Accuracy': [], 'ROC_AUC':[]}
|
||||
out_means[model]={} # just to make life easier
|
||||
print(model)
|
||||
for fold in t3_res[model]:
|
||||
for metric in {'F1_score': [], 'MCC': [], 'Precision': [], 'Recall': [], 'Accuracy': []}:
|
||||
for metric in {'F1_score': [], 'MCC': [], 'Precision': [], 'Recall': [], 'Accuracy': [], 'ROC_AUC':[]}:
|
||||
metric_value = t3_res[model][fold][metric]
|
||||
out[model][metric].append(metric_value)
|
||||
# now that we've built out{}, let's mean() each metric
|
||||
for model in out:
|
||||
for metric in {'F1_score': [], 'MCC': [], 'Precision': [], 'Recall': [], 'Accuracy': []}:
|
||||
for metric in {'F1_score': [], 'MCC': [], 'Precision': [], 'Recall': [], 'Accuracy': [], 'ROC_AUC':[]}:
|
||||
metric_mean = mean(out[model][metric])
|
||||
# just some debug output
|
||||
# print('model:', model
|
||||
|
@ -84,3 +61,4 @@ for model in out:
|
|||
out_means[model].update({(metric+'_mean'): metric_mean })
|
||||
|
||||
out_scores = pd.DataFrame(out_means)
|
||||
out_scores2 = round(out_scores, 2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue