text_html_output_1.png
from sklearn.ensemble import RandomForestRegressor

from sklearn.linear_model import LinearRegression,LogisticRegression

from sklearn.neighbors import KNeighborsRegressor

from sklearn.svm import SVR

from sklearn.tree import DecisionTreeRegressor

import pickle

knn = KNeighborsRegressor(n_neighbors=2)
knn.fit(X_train, Y_train)

Logistic_R = LogisticRegression()
Logistic_R.fit(X_train, Y_train)

svr_regressor = SVR(kernel='rbf', gamma='auto')
svr_regressor.fit(X_train, Y_train)

lr = LinearRegression()
lr.fit(X_train, Y_train)

tree_regressor = DecisionTreeRegressor(random_state=0)
tree_regressor.fit(X_train, Y_train)

forest_regressor = RandomForestRegressor(n_estimators=300, random_state=0)
forest_regressor.fit(X_train, Y_train)

knn_sav = pickle.dumps(knn)
knn_mod = pickle.loads(knn_sav)

lr_sav = pickle.dumps(lr)
lr_mod = pickle.loads(lr_sav)

Logistic_R_sav = pickle.dumps(Logistic_R)
log_mod = pickle.loads(Logistic_R_sav)

svr_sav = pickle.dumps(svr_regressor)
svr_mod = pickle.loads(svr_sav)

tree_regressor_sav = pickle.dumps(tree_regressor)
tree_mod = pickle.loads(tree_regressor_sav)

forest_regressor_sav = pickle.dumps(forest_regressor)
fr_mod = pickle.loads(forest_regressor_sav)

from tkinter import *
def predict(choice):
    try:
        a = float(int1.get())
        b = float(int2.get())
        if choice.get() == 1:
            pred = lr_mod.predict([[a, b]])
        if choice.get() == 2:
            pred = log_mod.predict([[a, b]])
        if choice.get() == 3:
            pred = svr_mod.predict([[a, b]])
        if choice.get() == 4:
            pred = knn_mod.predict([[a, b]])
        if choice.get() == 5:
            pred = tree_mod.predict([[a, b]])
        if choice.get() == 6:
            pred = fr_mod.predict([[a, b]])
        res = str(pred[0])
        T.insert(END, bool(res))
    except:
        if choice.get() <= 0:
            res = 'Choose the regression algorithm'
        else:
            res = 'INVALID INPUT'
        T.insert(END, res)
root = Tk()
root.geometry('400x250')
frame = Frame(root)
frame.pack()
fr = Frame(root)
fr.pack()
int1 = StringVar()
int2 = StringVar()
choice = IntVar()
label1 = Label(frame, text='CGPA:').grid(row=0)
label2 = Label(frame, text='Placement Exam Marks:').grid(row=1)
e1 = Entry(frame, textvariable=int1)
e2 = Entry(frame, textvariable=int2)
e1.grid(row=0, column=1)
e2.grid(row=1, column=1)
r1 = Radiobutton(fr, text='LR', variable=choice, value=1)
r1.grid(row=0, column=0)
r2 = Radiobutton(fr, text='LOG', variable=choice, value=2)
r2.grid(row=0, column=1)
r3 = Radiobutton(fr, text='SVM', variable=choice, value=3)
r3.grid(row=0, column=2)
r4 = Radiobutton(fr, text='KNN', variable=choice, value=4)
r4.grid(row=1, column=0)
r5 = Radiobutton(fr, text='DTR', variable=choice, value=5)
r5.grid(row=1, column=1)
r6 = Radiobutton(fr, text='RFR', variable=choice, value=6)
r6.grid(row=1, column=2)
Button = Button(root, text='IS Placed', command=lambda: predict(choice), activebackground='red')
Button.pack()
T = Text(root, height=2, width=32)
T.pack()
root.mainloop()