Shamima commited on
Commit
8cbbdae
·
1 Parent(s): 31f98af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
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(X_test, y_test, "r-")
32
- plt.plot(X_test, preds, "b--")
33
- plt.title("Effect of regularization parameter on Ridge regression")
34
  plt.ylabel("Y")
35
  plt.xlabel("X")
36
  return plt
37
 
38
- inputs = gr.Number()
39
  outputs = gr.Plot()
40
- gr.Interface(fn = predict, inputs = inputs, outputs = outputs).launch()
 
 
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