marik0 commited on
Commit
0ab3e6b
·
1 Parent(s): ce2800a

Minor improvements

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -5,8 +5,6 @@ import numpy as np
5
  from sklearn import datasets, linear_model
6
  from sklearn.metrics import mean_squared_error, r2_score
7
 
8
- from functools import partial
9
-
10
  FIGSIZE = (10,10)
11
 
12
  feature_names = ["age", "body-mass index (BMI)", "blood pressure",
@@ -33,7 +31,7 @@ def create_dataset(feature_id=2):
33
 
34
  def train_model(input_data):
35
 
36
- # We reomved the sex variable
37
  if input_data == 'age':
38
  feature_id = 0
39
  else:
@@ -57,7 +55,7 @@ def train_model(input_data):
57
  # Plot outputs
58
  fig = plt.figure(figsize=FIGSIZE)
59
 
60
- plt.title(input_data)
61
  plt.scatter(diabetes_X_test, diabetes_y_test, color="black")
62
  plt.plot(diabetes_X_test, diabetes_y_pred, color="blue", linewidth=3)
63
 
@@ -68,7 +66,7 @@ def train_model(input_data):
68
 
69
  return fig, regr.coef_, mse, r2
70
 
71
- title = "Linear Regression Example"
72
  description = "The example shows how linear regression attempts to draw a straight line that will best minimize the residual sum of squares between the observed responses in the dataset"
73
  with gr.Blocks() as demo:
74
  gr.Markdown(f"## {title}")
@@ -77,7 +75,7 @@ with gr.Blocks() as demo:
77
  with gr.Column():
78
 
79
  with gr.Row():
80
- plot = gr.Plot(label="Feature")
81
  with gr.Column():
82
  input_data = gr.Dropdown(choices=feature_names, label="Feature", value="body-mass index")
83
  coef = gr.Textbox(label="Coefficients")
 
5
  from sklearn import datasets, linear_model
6
  from sklearn.metrics import mean_squared_error, r2_score
7
 
 
 
8
  FIGSIZE = (10,10)
9
 
10
  feature_names = ["age", "body-mass index (BMI)", "blood pressure",
 
31
 
32
  def train_model(input_data):
33
 
34
+ # We removed the sex variable
35
  if input_data == 'age':
36
  feature_id = 0
37
  else:
 
55
  # Plot outputs
56
  fig = plt.figure(figsize=FIGSIZE)
57
 
58
+ # plt.title(input_data)
59
  plt.scatter(diabetes_X_test, diabetes_y_test, color="black")
60
  plt.plot(diabetes_X_test, diabetes_y_pred, color="blue", linewidth=3)
61
 
 
66
 
67
  return fig, regr.coef_, mse, r2
68
 
69
+ title = "Linear Regression Example 📈"
70
  description = "The example shows how linear regression attempts to draw a straight line that will best minimize the residual sum of squares between the observed responses in the dataset"
71
  with gr.Blocks() as demo:
72
  gr.Markdown(f"## {title}")
 
75
  with gr.Column():
76
 
77
  with gr.Row():
78
+ plot = gr.Plot()
79
  with gr.Column():
80
  input_data = gr.Dropdown(choices=feature_names, label="Feature", value="body-mass index")
81
  coef = gr.Textbox(label="Coefficients")