-
Notifications
You must be signed in to change notification settings - Fork 0
/
Practice.py
33 lines (32 loc) · 1.03 KB
/
Practice.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from flask import Flask,render_template,request,flash
import pandas as pd
import numpy as np
import pickle
from sklearn.linear_model import LinearRegression
app=Flask(__name__)
app.secret_key="kunu_pintu"
@app.route("/")
def home():
return render_template("home2.html")
@app.route("/predict",methods=["POST","GET"])
def predict():
# data = pd.read_csv("Salary_Data.csv")
# x = data.iloc[:, :-1].values
# y = data.iloc[:, -1].values
# regressor = LinearRegression()
# regressor.fit(x, y)
# with open("lucky.pkl", "wb") as f:
# pickle.dump(regressor, f)
# pass
if request.method=="POST":
year=request.form["year"]
with open("lucky.pkl","rb") as f:
regressor=pickle.load(f)
for i in regressor.predict([[int(year)]]):
pred=int(i)
flash(f"You may have a salary of {pred}$", "info")
return render_template("home2.html")
else:
return render_template("home2.html")
if __name__ == "__main__":
app.run(debug=True)