Spaces:
Runtime error
Runtime error
import pandas as pd | |
import numpy as np | |
from sklearn.model_selection import train_test_split | |
from sklearn.linear_model import LinearRegression | |
import gradio as gr | |
df=pd.read_csv("mexican_medical_students_mental_health_data.csv") | |
df.head() | |
df.info | |
target=df.iloc[:,19:27].sum(axis=1) | |
df.insert(43,"gad_total",target) | |
df.head() | |
df.nunique() | |
df.isna().sum() | |
h_mean=df["height"].mean() | |
w_mean=df["weight"].mean() | |
age_mean=df["age"].mean() | |
g_mode=df["gender"].mode()[0] | |
p1=df["phq1"].mode()[0] | |
p2=df["phq2"].mode()[0] | |
p3=df["phq3"].mode()[0] | |
p4=df["phq4"].mode()[0] | |
p5=df["phq5"].mode()[0] | |
p6=df["phq6"].mode()[0] | |
p7=df["phq7"].mode()[0] | |
p8=df["phq8"].mode()[0] | |
p9=df["phq9"].mode()[0] | |
p5 | |
df["height"].fillna(h_mean,inplace=True) | |
df["weight"].fillna(w_mean,inplace=True) | |
df["age"].fillna(age_mean,inplace=True) | |
df["gender"].fillna(g_mode,inplace=True) | |
df["phq1"].fillna(p1,inplace=True) | |
df["phq2"].fillna(p2,inplace=True) | |
df["phq3"].fillna(p3,inplace=True) | |
df["phq4"].fillna(p4,inplace=True) | |
df["phq5"].fillna(p5,inplace=True) | |
df["phq6"].fillna(p6,inplace=True) | |
df["phq7"].fillna(p7,inplace=True) | |
df["phq8"].fillna(p8,inplace=True) | |
df["phq9"].fillna(p9,inplace=True) | |
df.isna().sum() | |
df["reported_sleep_hours"][0] | |
from sklearn import preprocessing | |
le= preprocessing.LabelEncoder() | |
df["gender"]=le.fit_transform(df["gender"]) | |
df.head() | |
X=df[["age","gender","height","weight","phq1","phq2","phq3","phq4","phq5","phq6","phq7","phq8","phq9"]] | |
y=df["gad_total"] | |
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.25,random_state=21) | |
model=LinearRegression() | |
model.fit(X_train,y_train) | |
print("Training complete.") | |
r2_score=model.score(X_test,y_test) | |
print(r2_score*100,"%") | |
df["gad_total"].max() | |
df["gad_total"] | |
def greet(name): | |
return "Hello " + name + "!!" | |
iface = gr.Interface(fn=greet, inputs="text", outputs="text") | |
iface.launch() | |