Multiple Model Accuracy Json Result Format Using Python
I am building a multiple model and i am getting results with 7 models accuracy, i need those results with a proper json format. My multiple model building code will be like this se
Solution 1:
from collections import OrderedDict
sorted_model = dict(OrderedDict(sorted(kfold_result.items(), key = lambda x:x[1], reverse = True)))
s = pd.Series(sorted_model)
a = pd.DataFrame(s).reset_index()
sorted_models = a.rename(columns={'index':'model_name', 0 : 'model_accuracy'})
I got the expected output by converting the dict to series and to dataframe, then i rename the column names of dataframe. Finally i converted the results to json.
My output,
[{"model":[{"model_name":"LogisticRegression","model_accuracy":80.131},{"model_name":"LinearDiscriminantAnalysis","model_accuracy":80.131}]}]
Post a Comment for "Multiple Model Accuracy Json Result Format Using Python"