In [1]:
import matplotlib.pyplot as plt
import pandas as pd

Bar Plot Comparing Models

In [2]:
# initialize list of lists
data = [['Linear Regression', 0, .48], ['Random Forest', .075, .04, 14, .19, 69],  ['lightgbm', 0, .07, 31, .16, 69], 
        ['XGBoost', .06,.04,29,.15, 69],
        ['Neural Net', 0, .15], ['SVM', 0, .13, 4, .42, 69]
       ]
 
# Create the pandas DataFrame
df = pd.DataFrame(data, columns = ['Model Class', 'Avg Error', 'Low Avg Error', 'Schools Pred Bel .3','Low GT Error', 'Schools Bel .3'])
 
# print dataframe.
df
Out[2]:
Model Class Avg Error Low Avg Error Schools Pred Bel .3 Low GT Error Schools Bel .3
0 Linear Regression 0.000 0.48 NaN NaN NaN
1 Random Forest 0.075 0.04 14.0 0.19 69.0
2 lightgbm 0.000 0.07 31.0 0.16 69.0
3 XGBoost 0.060 0.04 29.0 0.15 69.0
4 Neural Net 0.000 0.15 NaN NaN NaN
5 SVM 0.000 0.13 4.0 0.42 69.0
In [3]:
import plotly.express as px
fig = px.bar(df, x='Model Class', y='Avg Error', title="Models with Avg Error",
#             title= 'Judged by the Low Average Error' 
             hover_data=['Schools Pred Bel .3', 'Schools Bel .3']
            )
fig.show()
In [4]:
import plotly.express as px
fig = px.bar(df, x='Model Class', y='Low Avg Error', title="Models with most correct predictions for schools with 30% or lower internet connectivity",
#             title= 'Judged by the Low Average Error' 
             hover_data=['Schools Pred Bel .3', 'Schools Bel .3']
            )
fig.show()
In [5]:
fig = px.bar(df, x='Model Class', y='Low GT Error', title="Models with avg error for predictions on schools with only 30% or lower internet connectivity",
#             title= 'Judged by the Low Average Error' 
            )
fig.show()