<jupyter_start><jupyter_text>Model comparisonIn this part of the project to predict the photovoltaic production of solar cells on a roof we are comparing the different regression models that we selected based on their performance in terms of r2_score and mean squared error.Models we considered can be found here:- Multi Linear Regression: https://kyso.io/heiko/predicting-solar-panel-output-model-01-multilinearregressioncode=shown- Polynomial Regression: https://kyso.io/heiko/predicting-solar-panel-output-model-02-polynomial-regressioncode=shown- Random Forest Regression: https://kyso.io/heiko/predicting-solar-panel-output-model-03-random-forest-regressionhttps://kyso.io/heiko/predicting-solar-panel-output-model-03-random-forest-regressioncode=shown- Support Vector Regression: https://kyso.io/heiko/predicting-solar-panel-output-model-04-support-vector-regressioncode=shown- Decision Tree Regression: https://kyso.io/heiko/predicting-solar-panel-output-model-05-decision-tree-regressioncode=shown- XGBoost Regression: https://kyso.io/heiko/predicting-solar-panel-output-model-06-xgboost-regressioncode=shown- Artificial Neural Network Regression: https://kyso.io/heiko/predicting-solar-panel-output-model-07-ann-regressioncode=shown<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
%config InlineBackend.figure_format = 'svg'<jupyter_output><empty_output><jupyter_text>Gather r2_scores and MSE for each model<jupyter_code>data = pd.DataFrame({
    'model': ['Linear','RandomForest', 'SVR', 'DecisionTree', 'XGBoost', 'ANN_32neurons_500epochs', 'ANN_100neurons_1000epochs', 'ANN_32neurons_1000epochs', 'ANN_6neurons_1000epochs'],
    'r2_score': [0.7190894719908503,0.8034519994023561,0.7944537346006463, 0.6783149762507574, 0.7852497173370512, 0.7347774390640276, 0.6639340975614128, 0.7128565927564843, 0.7295538005868867],
    'MSE': [54.70055724462856,38.272987609985634,40.02518288147158, 62.64040789443818, 41.81744348763667, 51.645703633338364, 65.440737535159, 55.914260304370025,52.6628813716351]
})

data<jupyter_output><empty_output><jupyter_text>Visualize<jupyter_code># find best MSE
best = data[data.loc[:, 'model'] == 'RandomForest']
x_b = best.index.values
y_b = best['MSE'].values

# find best r2_score
best_r2 = data[data.loc[:, 'model'] == 'ANN_100neurons_1000epochs']
x_b_r2 = best_r2.index.values
y_b_r2 = best_r2['r2_score'].values*100
fig, ax = plt.subplots(figsize=(8,6))
plt.plot(data['r2_score'].values * 100, color='darkblue', lw=3)
plt.plot(data['MSE'].values, color='darkorange', lw=3)

# annotate the best in terms of MSE
plt.scatter(x_b, y_b, color='darkorange', s=80)
ax.annotate(f'{y_b[0]:.1f}', xy=(x_b,y_b+3), fontweight='bold', color='darkorange')

# annotate the best in terms of r2_score
plt.scatter(x_b_r2, y_b_r2, color='darkblue', s=80)
ax.annotate(f'{y_b_r2[0]:.1f}%', xy=(x_b_r2-0.2,y_b_r2+3), fontweight='bold', color='darkblue')


ax.annotate('MSE', xy=(8.1,52), fontweight='bold', color='darkorange')
ax.annotate('r2_score [%]', xy=(8.1,72.5), fontweight='bold', color='darkblue')
plt.ylabel('R2 score [%], MSE [-]')
plt.xticks(range(9), data['model'].values, rotation=90)
# ax.set_xticklabels(data['model'].values, rotation=45)
# Hide the right and top spines
ax.spines['right'].set_visible(False)
ax.spines['top'].set_visible(False)
plt.tight_layout()
plt.savefig('model_comparison.png',dpi=200)
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1508608112051357, 'fraction_numerical': 0.11701196381674935, 'mean_word_length': 7.300242130750605, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '619941', 'license': 'MIT', 'n_tokens_mistral': 1572, 'n_tokens_neox': 1318, 'n_words': 206, 'path': '2020-04-16.solarAnalytics/04.Analysis/2020-06-25.Model_eng.008.Model_comparison.ipynb', 'repo_name': 'kromerh/solarAnalytics', 'size': '3427'}