Spaces:
Build error
Build error
Commit
·
6e471f5
1
Parent(s):
ad48754
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import numpy as np
|
3 |
+
import matplotlib.pyplot as plt
|
4 |
+
from sklearn.model_selection import train_test_split
|
5 |
+
from sklearn.linear_model import LinearRegression
|
6 |
+
import gradio as gr
|
7 |
+
|
8 |
+
|
9 |
+
df=pd.read_excel("Salary.xlsx")
|
10 |
+
df.head(3)
|
11 |
+
|
12 |
+
y_dep=df.Salary
|
13 |
+
x_ind=df.drop(["Salary","Student"],axis=1)
|
14 |
+
|
15 |
+
x_train, x_test, y_train, y_test = train_test_split(x_ind,y_dep, test_size = 0.2,random_state=1)
|
16 |
+
|
17 |
+
model = LinearRegression()
|
18 |
+
model.fit(x_train, y_train)
|
19 |
+
y_pred = model.predict(x_test)
|
20 |
+
|
21 |
+
def salary(school_ranking,gpa,experience):
|
22 |
+
input1=np.array([school_ranking,gpa,experience])
|
23 |
+
output1=model.predict([input1])
|
24 |
+
return output1[0].round()
|
25 |
+
|
26 |
+
interface = gr.Interface(fn = salary,
|
27 |
+
inputs=[gr.inputs.Number(default=1, label="School Ranking"), gr.inputs.Slider(1,10,step=0.1,label = "G.P.A"),gr.inputs.Slider(1,15,step=1,label = "Experience")],
|
28 |
+
outputs = [gr.outputs.Textbox( label="Expected Salary")],description="SALARY PREDICTION")
|
29 |
+
|
30 |
+
interface.launch()
|