Spaces:
Runtime error
Runtime error
Download app.py from RuthBebe/minor-project: direct link, hf CLI and curl.
- Browser
- Download file 2.02 kB
-
https://huggingface.co/spaces/RuthBebe/minor-project/resolve/main/app.py
- Command line
-
hf download hf://spaces/RuthBebe/minor-project/app.py
-
curl -L -o app.py https://huggingface.co/spaces/RuthBebe/minor-project/resolve/main/app.py
2.02 kB
| from flask import * | |
| import sqlite3 | |
| import numpy as np | |
| import pandas as pd | |
| import joblib | |
| from sklearn.linear_model import LinearRegression | |
| app = Flask(__name__) | |
| 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) + "%" | |
| def indexpage(): | |
| return render_template('index.html') | |
| 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" ) | |
| def carpricepage(): | |
| return render_template('carprice.html') | |
| 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) | |