harshiv commited on
Commit
a8155b6
1 Parent(s): dab724c

Update placement.py

Browse files
Files changed (1) hide show
  1. 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
- joblib.dump(pipeline, 'student_placement_model.joblib')
 
53
 
54
- # Define Streamlit API
55
- def predict_placement(internships, cgpa, history_of_backlogs, stream):
56
- # Load the trained pipeline
57
- pipeline = joblib.load('student_placement_model.joblib')
58
 
59
- # Prepare input data
60
- input_data = pd.DataFrame({'internships': [internships],
61
- 'cgpa': [cgpa],
62
- 'history_of_backlogs': [history_of_backlogs],
63
- 'stream': [stream]})
64
 
65
- # Make prediction
66
- prediction = pipeline.predict(input_data)
67
-
68
- return prediction[0]
69
 
70
- # Define Streamlit web app
71
- def streamlit_app():
72
- title('Student Placement Prediction')
73
- internships = number_input('Number of internships:', min_value=0, max_value=10, step=1)
74
- cgpa = number_input('CGPA:', min_value=0.0, max_value=10.0, step=0.1)
75
- history_of_backlogs = number_input('Number of history of backlogs:', min_value=0, max_value=10, step=1)
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
- if __name__ == '__main__':
86
- streamlit_app()
 
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()