|
import gradio as gr |
|
import pandas as pd |
|
import numpy as np |
|
from sklearn.linear_model import LinearRegression |
|
|
|
|
|
mydata = "data.txt" |
|
student_data = pd.read_csv(mydata) |
|
|
|
X = student_data.copy() |
|
y = student_data['Scores'] |
|
del X['Scores'] |
|
|
|
lineareg = LinearRegression() |
|
lineareg.fit(X,y) |
|
print('Accuracy score : ',lineareg.score(X,y),'\n') |
|
|
|
|
|
def predict_score(hours): |
|
hours = np.array(hours) |
|
pred_score = lineareg.predict(hours.reshape(-1,1)) |
|
return np.round(pred_score[0], 2) |
|
input = gr.inputs.Number(label='Number of Hours studied') |
|
output = gr.outputs.Textbox(label='Predicted Score') |
|
gr.Interface( fn=predict_score, |
|
inputs=input, |
|
outputs=output).launch(); |