Abid Ali Awan commited on
Commit
275e79c
·
1 Parent(s): 7775e43

Initial commit of Dockerized student placement app

Browse files
Dockerfile ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Use an official Python runtime as a parent image
2
+ FROM python:3.12-slim
3
+
4
+ # Set the working directory in the container
5
+ WORKDIR /app
6
+
7
+ # Copy the requirements file and install dependencies
8
+ COPY requirements.txt ./
9
+ RUN pip install --upgrade pip && pip install -r requirements.txt
10
+
11
+ # Copy the entire project
12
+ COPY . .
13
+
14
+ # Expose port (adjust as necessary)
15
+ EXPOSE 5000
16
+
17
+ # Command to run the Flask app
18
+ CMD ["python", "app/app.py"]
app/app.py ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, render_template, jsonify
2
+ import joblib
3
+ import numpy as np
4
+
5
+ app = Flask(__name__)
6
+
7
+ # Load the trained model and scaler (update paths as necessary)
8
+ model = joblib.load("model_rf.joblib")
9
+ scaler = joblib.load("scaler.joblib")
10
+
11
+
12
+ @app.route("/")
13
+ def home():
14
+ return render_template("index.html")
15
+
16
+
17
+ @app.route("/predict", methods=["POST"])
18
+ def predict():
19
+ try:
20
+ # Expecting form data from the HTML template
21
+ CGPA = float(request.form.get("CGPA"))
22
+ Internships = int(request.form.get("Internships"))
23
+ Projects = int(request.form.get("Projects"))
24
+ Workshops_Certifications = int(request.form.get("Workshops_Certifications"))
25
+ AptitudeTestScore = float(request.form.get("AptitudeTestScore"))
26
+ SoftSkillRating = float(request.form.get("SoftSkillRating"))
27
+ ExtracurricularActivities = request.form.get("ExtracurricularActivities")
28
+ PlacementTraining = request.form.get("PlacementTraining")
29
+ SSC_Marks = float(request.form.get("SSC_Marks"))
30
+ HSC_Marks = float(request.form.get("HSC_Marks"))
31
+
32
+ # Convert categorical fields to numerical
33
+ extra_act = 1 if ExtracurricularActivities.lower() == "yes" else 0
34
+ placement_training = 1 if PlacementTraining.lower() == "yes" else 0
35
+
36
+ # Construct feature vector
37
+ features = [
38
+ CGPA,
39
+ Internships,
40
+ Projects,
41
+ Workshops_Certifications,
42
+ AptitudeTestScore,
43
+ SoftSkillRating,
44
+ extra_act,
45
+ placement_training,
46
+ SSC_Marks,
47
+ HSC_Marks,
48
+ ]
49
+
50
+ # Scale features and make prediction
51
+ features_scaled = scaler.transform(np.array(features).reshape(1, -1))
52
+ prediction = model.predict(features_scaled)
53
+ result = "Placed" if prediction[0] == 1 else "Not Placed"
54
+
55
+ return render_template("index.html", prediction=result)
56
+ except Exception as e:
57
+ return render_template("index.html", prediction=f"Error: {e}")
58
+
59
+
60
+ if __name__ == "__main__":
61
+ app.run(host='0.0.0.0', port=5000, debug=True)
app/requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ matplotlib
4
+ seaborn
5
+ scikit-learn
6
+ mlflow
7
+ joblib
8
+ flask
app/templates/index.html ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Student Placement Prediction</title>
5
+ <style>
6
+ body { font-family: Arial, sans-serif; margin: 40px; }
7
+ label { display: inline-block; width: 200px; }
8
+ input, select { margin-bottom: 10px; }
9
+ </style>
10
+ </head>
11
+ <body>
12
+ <h1>Student Placement Prediction</h1>
13
+ <form action="/predict" method="post">
14
+ <label for="CGPA">CGPA:</label>
15
+ <input type="number" step="0.1" id="CGPA" name="CGPA" required><br>
16
+
17
+ <label for="Internships">Internships:</label>
18
+ <input type="number" id="Internships" name="Internships" required><br>
19
+
20
+ <label for="Projects">Projects:</label>
21
+ <input type="number" id="Projects" name="Projects" required><br>
22
+
23
+ <label for="Workshops_Certifications">Workshops/Certifications:</label>
24
+ <input type="number" id="Workshops_Certifications" name="Workshops_Certifications" required><br>
25
+
26
+ <label for="AptitudeTestScore">Aptitude Test Score:</label>
27
+ <input type="number" id="AptitudeTestScore" name="AptitudeTestScore" required><br>
28
+
29
+ <label for="SoftSkillRating">Soft Skill Rating:</label>
30
+ <input type="number" step="0.1" id="SoftSkillRating" name="SoftSkillRating" required><br>
31
+
32
+ <label for="ExtracurricularActivities">Extracurricular Activities:</label>
33
+ <select id="ExtracurricularActivities" name="ExtracurricularActivities" required>
34
+ <option value="Yes">Yes</option>
35
+ <option value="No">No</option>
36
+ </select><br>
37
+
38
+ <label for="PlacementTraining">Placement Training:</label>
39
+ <select id="PlacementTraining" name="PlacementTraining" required>
40
+ <option value="Yes">Yes</option>
41
+ <option value="No">No</option>
42
+ </select><br>
43
+
44
+ <label for="SSC_Marks">SSC Marks:</label>
45
+ <input type="number" id="SSC_Marks" name="SSC_Marks" required><br>
46
+
47
+ <label for="HSC_Marks">HSC Marks:</label>
48
+ <input type="number" id="HSC_Marks" name="HSC_Marks" required><br>
49
+
50
+ <button type="submit">Predict</button>
51
+ </form>
52
+
53
+ {% if prediction %}
54
+ <h2>Prediction: {{ prediction }}</h2>
55
+ {% endif %}
56
+ </body>
57
+ </html>
model_rf.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c870e3c62567fafa90f63a60bfa21a1f77d4800b5522e550fefcfadc7d2c741
3
+ size 815337
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ pandas
2
+ numpy
3
+ matplotlib
4
+ seaborn
5
+ scikit-learn
6
+ mlflow
7
+ joblib
8
+ flask
scaler.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:31dc61f25100ed5df127b242c8b8cb24475366173644bb2db801ed112897f399
3
+ size 1367