Spaces:
Runtime error
Runtime error
Sagar
commited on
Commit
·
804bce3
1
Parent(s):
8364b94
Updated Code
Browse files
app.py
CHANGED
|
@@ -66,7 +66,7 @@ from sklearn import preprocessing
|
|
| 66 |
le= preprocessing.LabelEncoder()
|
| 67 |
df["gender"]=le.fit_transform(df["gender"])
|
| 68 |
df.head()
|
| 69 |
-
|
| 70 |
|
| 71 |
# In[22]:
|
| 72 |
|
|
@@ -88,11 +88,37 @@ y_pred = model.predict(X_test)
|
|
| 88 |
print('Coefficients: \n', model.coef_)
|
| 89 |
print("Mean squared error: %.2f" % np.mean((model.predict(X_test) - y_test) ** 2))
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
def greet(input):
|
| 92 |
temp =np.array(input.split(","), dtype=float)
|
| 93 |
y = model.predict([[temp[0],temp[1],temp[2],temp[3],temp[4],temp[5],temp[6],temp[7],temp[8],temp[9],temp[10],temp[11],temp[12],temp[13],temp[14]]])
|
| 94 |
-
|
| 95 |
-
return y
|
| 96 |
|
| 97 |
textbox_x = gr.Textbox(label="Variable X:", placeholder="10", lines=1)
|
| 98 |
textbox_y = gr.Textbox(label="Variable Y:", placeholder ="11", lines=1)
|
|
|
|
| 66 |
le= preprocessing.LabelEncoder()
|
| 67 |
df["gender"]=le.fit_transform(df["gender"])
|
| 68 |
df.head()
|
| 69 |
+
df.insert(44,"epw_total",target)
|
| 70 |
|
| 71 |
# In[22]:
|
| 72 |
|
|
|
|
| 88 |
print('Coefficients: \n', model.coef_)
|
| 89 |
print("Mean squared error: %.2f" % np.mean((model.predict(X_test) - y_test) ** 2))
|
| 90 |
|
| 91 |
+
#epw
|
| 92 |
+
X=df[["age","gender","height","weight","phq1","phq2","phq3","phq4","phq5","phq6","phq7","phq8","phq9","reported_sleep_in_hours","nap_duration_hours"]]
|
| 93 |
+
y=df["epw_total"]
|
| 94 |
+
|
| 95 |
+
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.15,random_state=21)
|
| 96 |
+
|
| 97 |
+
modelepw=LinearRegression()
|
| 98 |
+
modelepw.fit(X_train,y_train)
|
| 99 |
+
print("Training complete.")
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
# In[79]:
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
r2_score=modelepw.score(X_test,y_test)
|
| 106 |
+
print(r2_score*100,"%")
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
# In[80]:
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
y_pred = modelepw.predict(X_test)
|
| 113 |
+
print('Coefficients: \n', modelepw.coef_)
|
| 114 |
+
# The mean squared error
|
| 115 |
+
print("Mean squared error: %.2f" % np.mean((modelepw.predict(X_test) - y_test) ** 2))
|
| 116 |
+
|
| 117 |
def greet(input):
|
| 118 |
temp =np.array(input.split(","), dtype=float)
|
| 119 |
y = model.predict([[temp[0],temp[1],temp[2],temp[3],temp[4],temp[5],temp[6],temp[7],temp[8],temp[9],temp[10],temp[11],temp[12],temp[13],temp[14]]])
|
| 120 |
+
z = modelepw.predict([[temp[0],temp[1],temp[2],temp[3],temp[4],temp[5],temp[6],temp[7],temp[8],temp[9],temp[10],temp[11],temp[12],temp[13],temp[14]]])
|
| 121 |
+
return str(y,",",z)
|
| 122 |
|
| 123 |
textbox_x = gr.Textbox(label="Variable X:", placeholder="10", lines=1)
|
| 124 |
textbox_y = gr.Textbox(label="Variable Y:", placeholder ="11", lines=1)
|