import pandas as pd import numpy as np import seaborn as sn import matplotlib.pyplot as plt import gradio as gr df=pd.read_csv('Placement_Data_Full_Class.csv') df.drop(columns=['sl_no'],axis=1,inplace=True) df_encoded=pd.get_dummies(df,columns=['gender','ssc_b',"hsc_b","workex","hsc_s","degree_t","specialisation","status"],prefix=['gender','ssc_b',"hsc_b","workex","hsc_s","degree_t","specialisation","status"], drop_first=True) df_encoded.drop(columns='salary',axis=1,inplace=True) test=df_encoded['status_Placed'] train=df_encoded.drop(columns='status_Placed',axis=1) from sklearn.linear_model import LogisticRegression from sklearn.tree import DecisionTreeClassifier from sklearn.ensemble import RandomForestClassifier from sklearn.svm import SVC from sklearn import tree from sklearn.model_selection import train_test_split from sklearn import metrics x_train,x_test,y_train,y_test=train_test_split(train,test,test_size=0.2,random_state=0) from sklearn.preprocessing import StandardScaler ss=StandardScaler() x_train=ss.fit_transform(x_train) x_test=ss.transform(x_test) lr = LogisticRegression() lr.fit(x_train,y_train) #y_pred = lr.predict(x_test) #print(metrics.accuracy_score(y_test,y_pred)) # Define the prediction function def predict_placement_status(ssc_p,hsc_p,degree_p,etest_p,mba_p,gender_M,ssc_b_Others,hsc_b_Others,workex_Yes,hsc_s_Commerce,hsc_s_Science,degree_t_Others,degree_t_Sci_Tech,specialisation_Mkt_HR): gender_M = 1 if gender_M == "Male" else 0 ssc_b_Others = 1 if ssc_b_Others == "Others" else 0 hsc_b_Others = 1 if hsc_b_Others == "Others" else 0 workex_Yes = 1 if workex_Yes == "Yes" else 0 hsc_s_Commerce = 1 if hsc_s_Commerce == "Commerce" else 0 hsc_s_Science = 1 if hsc_s_Science == "Science" else 0 degree_t_Others = 1 if degree_t_Others == "Others" else 0 degree_t_Sci_Tech = 1 if degree_t_Sci_Tech == "Sci&Tech" else 0 specialisation_Mkt_HR = 1 if specialisation_Mkt_HR == "Mkt&HR" else 0 input_data = [[float(ssc_p),float(hsc_p),float(degree_p),float(etest_p),float(mba_p),gender_M,ssc_b_Others,hsc_b_Others,workex_Yes,hsc_s_Commerce,hsc_s_Science,degree_t_Others,degree_t_Sci_Tech,specialisation_Mkt_HR]] input_data_scaled = ss.transform(input_data) prediction = lr.predict(input_data_scaled) return "Placed" if prediction[0] == 1 else "Not Placed" iface = gr.Interface(fn=predict_placement_status, inputs=[gr.Number(label="SSC Marks"), gr.Number(label="HSC Marks"), gr.Number(label="Degree Marks"), gr.Number(label="Emploibility-test Marks"), gr.Number(label="MBA Marks"), gr.Radio(label="Gender", choices=["Female", "Male"]), gr.Radio(label="SSC Board", choices=["Central", "Others"]), gr.Radio(label="HSC Board", choices=["Central", "Others"]), gr.Radio(label="Work Experience", choices=["No", "Yes"]), gr.Radio(label="HSC Stream", choices=["Commerce", "Science", "Arts"]), gr.Radio(label="HSC Stream", choices=["Commerce", "Science", "Arts"]), gr.Radio(label="Degree Type", choices=["Others", "Sci&Tech", "Comm&Mgmt"]), gr.Radio(label="Degree Type", choices=["Others", "Sci&Tech", "Comm&Mgmt"]), gr.Radio(label="Specialisation", choices=["Mkt&HR", "Mkt&Fin"]), ], outputs="text", title="Prediction", description="Predict based on selected features.",theme='compact' ) iface.launch(share=True)