Created
November 19, 2022 05:36
-
-
Save charanquartz/be2abb58ae41680c84f9c8a0e88376b3 to your computer and use it in GitHub Desktop.
Revisions
-
charanquartz created this gist
Nov 19, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,71 @@ import pandas as pd import pickle from sklearn.linear_model import LogisticRegression from sklearn import svm import matplotlib.pyplot as plt df=pd.read_csv('marks.csv') df.info() df.isnull().sum() df.describe() df.dropna(axis=0,inplace=True) df['gender'] = df['gender'].map({'male': 1 ,'female': 2}) cdf = df[['gender','internalmarks','internalmarks1','internalmarks2','study_hours','externalmarks']] x = cdf.iloc[:, :5] y = cdf.iloc[:, -1] from sklearn.linear_model import LinearRegression linearRegression = LinearRegression() linearRegression.fit(x, y) lracc = linearRegression.score(x,y) from sklearn.tree import DecisionTreeRegressor model = DecisionTreeRegressor(random_state=44) model.fit(x, y) dtacc = model.score(x,y) from sklearn.svm import SVR SVM = SVR() SVM.fit(x, y) SVMacc =SVM.score(x, y) print(model.predict([[2,69,90,88,6.56]])) from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_test = train_test_split(x, y, random_state=0, test_size=0.3, shuffle=False) SVM.score(X_train, y_train) svm_acc=round(SVM.score(x,y), 4) data = {'LinearRegression':lracc*100, 'SVC':SVMacc*100, 'DecisionTree':dtacc*100} courses = list(data.keys()) values = list(data.values()) fig = plt.figure(figsize = (10, 5)) # creating the bar plot plt.bar(courses, values, color =['black', 'red', 'green', 'cyan'], width = 0.4) plt.xlabel("Algorithm") plt.ylabel("Accuracy") plt.title("Accuracy of Algorithms") plt.show() file= open('my_modell.pkl','wb') pickle.dump(model,file,protocol=2) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ from flask import Flask, request, render_template import pickle import numpy as np model = pickle.load(open('my_model.pkl', 'rb')) app = Flask(__name__) @app.route('/') def hello(): return render_template("Hoome.html") @app.route('/predict', methods=['POST']) def home(): data1 = 1 data2 = request.form['a'] data3 = request.form['b'] data4 = request.form['c'] data5 = request.form['d'] arr = np.array([[data1, data2, data3, data4, data5]]) pred = model.predict(arr) return render_template('After.html', pred=pred) if __name__ == "__main__": app.run(debug=True)