Spaces:
Runtime error

File size: 2,021 Bytes
fbbb5eb
6702979
 
 
6c02389
6702979
7cdd51d
 
 
50b37b9
26da279
50b37b9
 
 
 
 
 
 
 
 
 
 
 
26da279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b01ec99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7cdd51d
 
 
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from flask import *
import sqlite3
import numpy as np
import pandas as pd
import joblib
from sklearn.linear_model import LinearRegression

app = Flask(__name__)

 
@app.route('/ml') 
def run():
  url='https://raw.githubusercontent.com/sarwansingh/Python/master/ClassExamples/data/student-pass-fail-data.csv'
  df=pd.read_csv(url)
  df1=df.values
  
  X=df1[:,0:2]
  Y= df1[:,2]
  model=LinearRegression()
  model.fit(X,Y)
  var=model.predict([[7,27]])
  
  return "The prdeicted result is " + str(var[0]* 100) + "%"


@app.route('/') 
def indexpage(): 
  return render_template('index.html') 

@app.route('/p', methods=["POST"]) 
def mainpage(): 
  selfstudy= eval(request.form.get("selfstudy"))
  tut=  eval(request.form.get("tut"))
  # model prediction
  url='https://raw.githubusercontent.com/sarwansingh/Python/master/ClassExamples/data/student-pass-fail-data.csv'
  df=pd.read_csv(url)
  df1=df.values
  
  X=df1[:,0:2]
  Y= df1[:,2]
  model=LinearRegression()
  model.fit(X,Y)
  var=model.predict([[selfstudy,tut]])
  result=var[0]*100
  if result >50:
    return render_template('index.html', data= str(round(result)) + "% implies a high chance of passing" )
  else:
    return render_template('index.html', data= str(round(result)) + "% implies you might fail" )

@app.route('/carprice')
def carpricepage():
  return render_template('carprice.html') 


@app.route('/carpriceprediction', methods=["POST"])
def carpricepredict():
  fueltype=int(request.form.get("fueltype"))
  enginetype=int(request.form.get("enginetype"))
  enginesize=int(request.form.get("enginesize"))
  horsepower=int(request.form.get("horsepower"))
  car=pd.read_csv('https://raw.githubusercontent.com/Ruth-Oteng/data/main/car%20price.csv')
  
  
  model5 =joblib.load('carprice.pkl') #carmodel=joblib.load('carprice.pkl')
  predictModel= model5.predict([[fueltype,enginetype,enginesize,horsepower]])
  
  return render_template('carprice.html', data=str(predictModel[0]))

if __name__ == '__main__': 
    app.run(host="0.0.0.0", port=7860)