Spaces:
Runtime error
Runtime error
add R2
Browse files- stream_app.py +25 -2
stream_app.py
CHANGED
|
@@ -197,8 +197,6 @@ fig = px.bar(xgb_features_importance,
|
|
| 197 |
st.plotly_chart(fig)
|
| 198 |
|
| 199 |
st.subheader("Plot predicted vs real")
|
| 200 |
-
import plotly.graph_objs as go
|
| 201 |
-
|
| 202 |
compare = pd.concat([pd.DataFrame({'target': target_test, 'predicted': target_test_predicted, 'sample': 'test'}),
|
| 203 |
pd.DataFrame({'target': target_train, 'predicted': target_train_predicted, 'sample': 'train'})])
|
| 204 |
fig = px.scatter(
|
|
@@ -214,6 +212,31 @@ fig = px.scatter(
|
|
| 214 |
|
| 215 |
st.plotly_chart(fig)
|
| 216 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
sample_revenues = st.sidebar.number_input('Yearly revenues', value=1000000)
|
| 218 |
authority = st.sidebar.selectbox('Organization country', predictors.org_country.cat.categories)
|
| 219 |
authority = st.sidebar.selectbox('Organization activity', predictors.org_company_type.cat.categories)
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
st.plotly_chart(fig)
|
| 198 |
|
| 199 |
st.subheader("Plot predicted vs real")
|
|
|
|
|
|
|
| 200 |
compare = pd.concat([pd.DataFrame({'target': target_test, 'predicted': target_test_predicted, 'sample': 'test'}),
|
| 201 |
pd.DataFrame({'target': target_train, 'predicted': target_train_predicted, 'sample': 'train'})])
|
| 202 |
fig = px.scatter(
|
|
|
|
| 212 |
|
| 213 |
st.plotly_chart(fig)
|
| 214 |
|
| 215 |
+
|
| 216 |
+
naive_error_std = np.std(target_train - np.mean(target_train_predicted))
|
| 217 |
+
model_error_std = np.std(target_train - target_train_predicted)
|
| 218 |
+
|
| 219 |
+
st.metric(label="Naive error standard deviation", value=naive_error_std)
|
| 220 |
+
st.metric(label="Model error standard deviation", value=model_error_std)
|
| 221 |
+
|
| 222 |
+
corr_matrix = np.corrcoef(target_train, target_train_predicted)
|
| 223 |
+
R_sq = corr_matrix[0, 1] ** 2
|
| 224 |
+
st.metric(label="Explained variation thanks to model (R^2)", value=f"{round(100*R_sq, 2)}%")
|
| 225 |
+
|
| 226 |
+
naive_error_std = np.std(target_test - np.mean(target_test_predicted))
|
| 227 |
+
model_error_std = np.std(target_test - target_test_predicted)
|
| 228 |
+
|
| 229 |
+
st.metric(label="Naive error standard deviation", value=naive_error_std)
|
| 230 |
+
st.metric(label="Model error standard deviation", value=model_error_std)
|
| 231 |
+
|
| 232 |
+
corr_matrix = np.corrcoef(target_test, target_test_predicted)
|
| 233 |
+
R_sq = corr_matrix[0, 1] ** 2
|
| 234 |
+
st.metric(label="Explained variation thanks to model (R^2)", value=f"{round(100*R_sq, 2)}%")
|
| 235 |
+
|
| 236 |
+
|
| 237 |
sample_revenues = st.sidebar.number_input('Yearly revenues', value=1000000)
|
| 238 |
authority = st.sidebar.selectbox('Organization country', predictors.org_country.cat.categories)
|
| 239 |
authority = st.sidebar.selectbox('Organization activity', predictors.org_company_type.cat.categories)
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
|