Spaces:
Runtime error
Runtime error
app.py
Browse files
app.py
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import numpy as np
|
3 |
+
import seaborn as sn
|
4 |
+
import matplotlib.pyplot as plt
|
5 |
+
import plotly.express as px
|
6 |
+
|
7 |
+
df=pd.read_csv('Placement_Data_Full_Class.csv')
|
8 |
+
|
9 |
+
df.drop(columns=['sl_no'],axis=1,inplace=True)
|
10 |
+
|
11 |
+
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)
|
12 |
+
|
13 |
+
df_encoded.drop(columns='salary',axis=1,inplace=True)
|
14 |
+
|
15 |
+
test=df_encoded['status_Placed']
|
16 |
+
train=df_encoded.drop(columns='status_Placed',axis=1)
|
17 |
+
|
18 |
+
from sklearn.linear_model import LogisticRegression
|
19 |
+
from sklearn.tree import DecisionTreeClassifier
|
20 |
+
from sklearn.ensemble import RandomForestClassifier
|
21 |
+
from sklearn.svm import SVC
|
22 |
+
from sklearn import tree
|
23 |
+
from sklearn.model_selection import train_test_split
|
24 |
+
from sklearn import metrics
|
25 |
+
|
26 |
+
x_train,x_test,y_train,y_test=train_test_split(train,test,test_size=0.2,random_state=0)
|
27 |
+
|
28 |
+
from sklearn.preprocessing import StandardScaler
|
29 |
+
ss=StandardScaler()
|
30 |
+
x_train=ss.fit_transform(x_train)
|
31 |
+
x_test=ss.transform(x_test)
|
32 |
+
|
33 |
+
lr = LogisticRegression()
|
34 |
+
|
35 |
+
lr.fit(x_train,y_train)
|
36 |
+
#y_pred = lr.predict(x_test)
|
37 |
+
#print(metrics.accuracy_score(y_test,y_pred))
|
38 |
+
|
39 |
+
# Define the prediction function
|
40 |
+
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):
|
41 |
+
|
42 |
+
gender_M = 1 if gender_M == "Male" else 0
|
43 |
+
ssc_b_Others = 1 if ssc_b_Others == "Others" else 0
|
44 |
+
hsc_b_Others = 1 if hsc_b_Others == "Others" else 0
|
45 |
+
workex_Yes = 1 if workex_Yes == "Yes" else 0
|
46 |
+
hsc_s_Commerce = 1 if hsc_s_Commerce == "Commerce" else 0
|
47 |
+
hsc_s_Science = 1 if hsc_s_Science == "Science" else 0
|
48 |
+
degree_t_Others = 1 if degree_t_Others == "Others" else 0
|
49 |
+
degree_t_Sci_Tech = 1 if degree_t_Sci_Tech == "Sci&Tech" else 0
|
50 |
+
specialisation_Mkt_HR = 1 if specialisation_Mkt_HR == "Mkt&HR" else 0
|
51 |
+
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]]
|
52 |
+
|
53 |
+
|
54 |
+
|
55 |
+
input_data_scaled = ss.transform(input_data)
|
56 |
+
prediction = lr.predict(input_data_scaled)
|
57 |
+
return "Placed" if prediction[0] == 1 else "Not Placed"
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
iface = gr.Interface(fn=predict_placement_status,
|
62 |
+
inputs=[gr.Number(label="SSC Marks"),
|
63 |
+
gr.Number(label="HSC Marks"),
|
64 |
+
gr.Number(label="Degree Marks"),
|
65 |
+
gr.Number(label="Emploibility-test Marks"),
|
66 |
+
gr.Number(label="MBA Marks"),
|
67 |
+
gr.Radio(label="Gender", choices=["Female", "Male"]),
|
68 |
+
gr.Radio(label="SSC Board", choices=["Central", "Others"]),
|
69 |
+
gr.Radio(label="HSC Board", choices=["Central", "Others"]),
|
70 |
+
gr.Radio(label="Work Experience", choices=["No", "Yes"]),
|
71 |
+
gr.Radio(label="HSC Stream", choices=["Commerce", "Science", "Arts"]),
|
72 |
+
gr.Radio(label="HSC Stream", choices=["Commerce", "Science", "Arts"]),
|
73 |
+
gr.Radio(label="Degree Type", choices=["Others", "Sci&Tech", "Comm&Mgmt"]),
|
74 |
+
gr.Radio(label="Degree Type", choices=["Others", "Sci&Tech", "Comm&Mgmt"]),
|
75 |
+
gr.Radio(label="Specialisation", choices=["Mkt&HR", "Mkt&Fin"]),
|
76 |
+
],
|
77 |
+
outputs="text",
|
78 |
+
title="Prediction",
|
79 |
+
description="Predict based on selected features.",theme='compact'
|
80 |
+
)
|
81 |
+
|
82 |
+
iface.launch(share=True)
|
83 |
+
|