Spaces:
Sleeping
Sleeping
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import warnings | |
import gradio as gr | |
import sklearn | |
warnings.filterwarnings('ignore') | |
data = pd.read_csv("Placement_Data_Full_Class.csv") | |
X = data.drop(["sl_no","status","salary"],axis=1) | |
y = data["status"] | |
X = pd.get_dummies(X,drop_first=True) | |
y = pd.get_dummies(y,drop_first=True) | |
from sklearn.preprocessing import MinMaxScaler | |
scaler = MinMaxScaler() | |
X = scaler.fit_transform(X) | |
from sklearn.model_selection import train_test_split | |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.1) | |
from sklearn.linear_model import LogisticRegression | |
model = LogisticRegression() | |
model.fit(X_train,y_train) | |
def prediction(name,gender,ssc_p,ssc_b,hsc_p,hsc_b,hsc_s,degree_p,degree_t,workex,etest_p,specialisation,mba_p): | |
df = pd.DataFrame({"gender":gender, | |
"ssc_p":float(ssc_p),"ssc_b":ssc_b,"hsc_p":int(hsc_p),"hsc_b":hsc_b,"hsc_s":hsc_s, | |
"degree_p":float(degree_p), | |
"degree_t":degree_t,"workex":workex,"etest_p":float(etest_p),"specialisation":specialisation, | |
"mba_p":float(mba_p) | |
},index=[0]) | |
data = pd.read_csv("Placement_Data_Full_Class.csv") | |
data = data.drop(["sl_no","status","salary"],axis=1) | |
data = data.append(df,ignore_index = True) | |
data = pd.get_dummies(data,drop_first = True) | |
data = scaler.fit_transform(data) | |
var = model.predict(data[[-1]]) | |
if var == 1: | |
return "Congratulations! "+name+", you have a high chance of getting placed." | |
else: | |
return "Sorry! "+name+", better luck next time." | |
interface = gr.Interface(prediction,inputs=[ | |
gr.Textbox(lines=2, placeholder="Enter your Name Here...", show_label = False), | |
gr.Dropdown(choices=["M","F"],value = "M",label = "Select your Gender"), | |
gr.Textbox(lines=2, placeholder="Enter your SSC Percentage Here...", show_label = False), | |
gr.Dropdown(choices=["Central","Others"],value = "Central",label = "Select your SSC Board"), | |
gr.Textbox(lines=2, placeholder="Enter your HSC Percentage Here...",show_label = False), | |
gr.Dropdown(choices=["Central","Others"],value = "Others",label = "Select your HSC Board"), | |
gr.Dropdown(choices=["Commerce","Science","Arts"],value = "Commerce",label = "Select your HSC Stream"), | |
gr.Textbox(lines=2, placeholder="Enter your Degree Percentage Here...",show_label = False), | |
gr.Dropdown(choices=["Comm&Mgmt","Sci&Tech","Others"],value = "Comm&Mgmt",label = "Select your Degree Domain"), | |
gr.Dropdown(choices=["No","Yes"],value = "No",label = "Select Whether you have prior Work Experience"), | |
gr.Textbox(lines=2, placeholder="Enter your E Test Percentage Here...",show_label = False), | |
gr.Dropdown(choices=["Mkt&Fin","Mkt&HR"],value = "Mkt&Fin",label = "Select your Specialisation"), | |
gr.Textbox(lines=2, placeholder="Enter your MBA Percentage Here...",show_label = False) | |
],outputs = gr.Label(value = "Prediction"),description = "Predicting Placement Chances") | |
interface.launch() |