Spaces:
Runtime error
Runtime error
Commit
·
1bdb2db
1
Parent(s):
cdc4b33
commit
Browse files
Makefile
CHANGED
|
@@ -1,2 +1,2 @@
|
|
| 1 |
-
|
| 2 |
-
|
|
|
|
| 1 |
+
black app.py
|
| 2 |
+
isort app.py
|
app.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import numpy as np
|
| 3 |
import matplotlib.pyplot as plt
|
|
|
|
|
|
|
| 4 |
from sklearn.datasets import make_regression
|
| 5 |
-
from sklearn.neighbors import KNeighborsRegressor
|
| 6 |
from sklearn.metrics import mean_squared_error
|
| 7 |
-
|
| 8 |
|
| 9 |
st.subheader("K nearest neighbor (KNN) Regressor")
|
| 10 |
|
|
@@ -15,7 +14,7 @@ K = st.slider(
|
|
| 15 |
)
|
| 16 |
|
| 17 |
|
| 18 |
-
X, y = make_regression(n_samples=1000, n_features=1,random_state=42)
|
| 19 |
|
| 20 |
ntrain = 700
|
| 21 |
|
|
@@ -28,14 +27,14 @@ knn = KNeighborsRegressor(n_neighbors=K)
|
|
| 28 |
knn.fit(x_train, y_train)
|
| 29 |
plt.figure()
|
| 30 |
y_pred = knn.predict(x_test)
|
| 31 |
-
plt.scatter(x_test,y_test)
|
| 32 |
-
plt.plot(x_test,y_pred)
|
| 33 |
plt.xlabel("Datapoints")
|
| 34 |
plt.ylabel("Predictions")
|
| 35 |
|
| 36 |
with st_col:
|
| 37 |
st.pyplot(plt)
|
| 38 |
-
error = mean_squared_error(y_test,y_pred)
|
| 39 |
st.write("The error is", error)
|
| 40 |
|
| 41 |
hide_streamlit_style = """
|
|
|
|
|
|
|
|
|
|
| 1 |
import matplotlib.pyplot as plt
|
| 2 |
+
import numpy as np
|
| 3 |
+
import streamlit as st
|
| 4 |
from sklearn.datasets import make_regression
|
|
|
|
| 5 |
from sklearn.metrics import mean_squared_error
|
| 6 |
+
from sklearn.neighbors import KNeighborsRegressor
|
| 7 |
|
| 8 |
st.subheader("K nearest neighbor (KNN) Regressor")
|
| 9 |
|
|
|
|
| 14 |
)
|
| 15 |
|
| 16 |
|
| 17 |
+
X, y = make_regression(n_samples=1000, n_features=1, random_state=42)
|
| 18 |
|
| 19 |
ntrain = 700
|
| 20 |
|
|
|
|
| 27 |
knn.fit(x_train, y_train)
|
| 28 |
plt.figure()
|
| 29 |
y_pred = knn.predict(x_test)
|
| 30 |
+
plt.scatter(x_test, y_test)
|
| 31 |
+
plt.plot(x_test, y_pred)
|
| 32 |
plt.xlabel("Datapoints")
|
| 33 |
plt.ylabel("Predictions")
|
| 34 |
|
| 35 |
with st_col:
|
| 36 |
st.pyplot(plt)
|
| 37 |
+
error = mean_squared_error(y_test, y_pred)
|
| 38 |
st.write("The error is", error)
|
| 39 |
|
| 40 |
hide_streamlit_style = """
|