Spaces:
Runtime error
Runtime error
Update placement.py
Browse files- placement.py +18 -30
placement.py
CHANGED
@@ -49,38 +49,26 @@ pipeline.fit(X_train, y_train)
|
|
49 |
# Evaluate the model
|
50 |
accuracy = pipeline.score(X_test, y_test)
|
51 |
print('Accuracy:', accuracy)
|
52 |
-
|
|
|
53 |
|
54 |
-
# Define
|
55 |
-
def predict_placement(
|
56 |
-
#
|
57 |
-
|
58 |
|
59 |
-
#
|
60 |
-
|
61 |
-
'cgpa': [cgpa],
|
62 |
-
'history_of_backlogs': [history_of_backlogs],
|
63 |
-
'stream': [stream]})
|
64 |
|
65 |
-
#
|
66 |
-
prediction
|
67 |
-
|
68 |
-
return prediction[0]
|
69 |
|
70 |
-
#
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
stream = selectbox('Stream:', options=['Science', 'Commerce', 'Arts'])
|
77 |
-
prediction = predict_placement(internships, cgpa, history_of_backlogs, stream)
|
78 |
-
if prediction == 1:
|
79 |
-
result = 'Placed'
|
80 |
-
else:
|
81 |
-
result = 'Not Placed'
|
82 |
-
button('Predict Placement')
|
83 |
-
write(f'Result: {result}')
|
84 |
|
85 |
-
|
86 |
-
|
|
|
49 |
# Evaluate the model
|
50 |
accuracy = pipeline.score(X_test, y_test)
|
51 |
print('Accuracy:', accuracy)
|
52 |
+
input_type = 'csv'
|
53 |
+
output_type = 'label'
|
54 |
|
55 |
+
# Define the function to make predictions using the trained model
|
56 |
+
def predict_placement(Internships, CGPA, HistoryOfBacklogs):
|
57 |
+
# Create a DataFrame from the input data
|
58 |
+
input_df = pd.DataFrame({'Internships': [Internships], 'CGPA': [CGPA], 'HistoryOfBacklogs': [HistoryOfBacklogs]})
|
59 |
|
60 |
+
# Make a prediction using the trained model
|
61 |
+
prediction = pipeline.predict(input_df)[0]
|
|
|
|
|
|
|
62 |
|
63 |
+
# Return the predicted label
|
64 |
+
return 'Placed' if prediction else 'Not Placed'
|
|
|
|
|
65 |
|
66 |
+
# Create the Gradio interface
|
67 |
+
iface = gr.Interface(fn=predict_placement,
|
68 |
+
inputs=input_type,
|
69 |
+
outputs=output_type,
|
70 |
+
title='Student Job Placement Predictor',
|
71 |
+
description='Predicts whether a student will be placed in a job or not based on internships, CGPA, and history of backlogs.')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
+
# Launch the Gradio interface
|
74 |
+
iface.launch()
|