Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -28,14 +28,16 @@ def predict(alpha):
|
|
28 |
ridge_reg = build_model(alpha)
|
29 |
preds = ridge_reg.predict(X_test)
|
30 |
fig = plt.figure()
|
31 |
-
plt.plot(
|
32 |
-
plt.plot(X_test,
|
33 |
-
plt.
|
34 |
plt.ylabel("Y")
|
35 |
plt.xlabel("X")
|
36 |
return plt
|
37 |
|
38 |
-
inputs = gr.
|
39 |
outputs = gr.Plot()
|
40 |
-
|
|
|
|
|
41 |
|
|
|
28 |
ridge_reg = build_model(alpha)
|
29 |
preds = ridge_reg.predict(X_test)
|
30 |
fig = plt.figure()
|
31 |
+
plt.plot(X_train, y_train, "g-", label="train data")
|
32 |
+
plt.plot(X_test, y_test, "r-", label="test data")
|
33 |
+
plt.plot(X_test, preds, "b--", label="regularized model")
|
34 |
plt.ylabel("Y")
|
35 |
plt.xlabel("X")
|
36 |
return plt
|
37 |
|
38 |
+
inputs = gr.Slider(-10, 20, label='alpha', default=1)
|
39 |
outputs = gr.Plot()
|
40 |
+
title = "Effect of regularization using Ridge regression"
|
41 |
+
description = "Alpha is the regularization parameter which basically restricts model. The idea is that using regularization the model even if performs poorly on the training data, it would provide a better fit for generalizing data. Try out yourself by increasing or decreasing the value of alpha."
|
42 |
+
gr.Interface(fn = predict, inputs = inputs, outputs = outputs, title = title, description = description).launch()
|
43 |
|