fahadcr14 commited on
Commit
d0c7e75
·
1 Parent(s): 076fbd9
.gitignore CHANGED
@@ -0,0 +1,2 @@
 
 
 
1
+ .venv/
2
+ env/
Dockerfile CHANGED
@@ -14,7 +14,7 @@ RUN pip install --no-cache-dir -r requirements.txt
14
  COPY . /app
15
 
16
  # Expose the port Flask will run on
17
- EXPOSE 7860
18
 
19
  # Run the Flask app
20
  CMD ["python", "app.py"]
 
14
  COPY . /app
15
 
16
  # Expose the port Flask will run on
17
+ EXPOSE 5000
18
 
19
  # Run the Flask app
20
  CMD ["python", "app.py"]
ICT.xlsx ADDED
Binary file (93.5 kB). View file
 
app.py CHANGED
@@ -1,23 +1,88 @@
1
- from flask import Flask, request, jsonify, render_template
 
 
2
 
3
  app = Flask(__name__)
4
 
5
- # Route for the home page
6
- @app.route('/')
7
- def index():
8
- return render_template('index.html')
9
-
10
- # Prediction endpoint (mock prediction for now)
11
- @app.route('/predict', methods=['POST'])
12
- def predict():
13
- data = request.json
14
- activities = data.get('activities')
15
-
16
- # Placeholder logic for prediction (replace with your ML model)
17
- if activities:
18
- predicted_score = sum(activities) / len(activities) # Example logic
19
- return jsonify({'predicted_score': predicted_score})
20
- return jsonify({'error': 'No activities provided'}), 400
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  if __name__ == '__main__':
23
- app.run(host='0.0.0.0', port=7860)
 
1
+ from flask import Flask, request, render_template
2
+ import numpy as np
3
+ import pickle
4
 
5
  app = Flask(__name__)
6
 
7
+ # Cloud Computing Weights and Max Marks
8
+ cc_weights = {
9
+ 'A1': 1, 'Q1': 1.5, 'A2': 1, 'Q2': 1.5, 'A3': 1,
10
+ 'A4': 4, 'Q3': 1.5, 'Mid': 35, 'AWS Labs': 3,
11
+ 'Q4': 1.25, 'A5': 4, 'Q5': 1.25, 'A6': 4, 'Final': 40
12
+ }
13
+ cc_max_marks = {
14
+ 'A1': 10, 'Q1': 21, 'A2': 10, 'Q2': 30, 'A3': 100,
15
+ 'A4': 10, 'Q3': 41, 'Mid': 35, 'AWS Labs': 10,
16
+ 'Q4': 40, 'A5': 100, 'Q5': 20, 'A6': 100, 'Final': 40
17
+ }
18
+
19
+ # ICT Weights and Max Marks
20
+ ict_weights = {
21
+ 'Q1': 2.625, 'Q2': 2.625, 'A1': 2, 'Q3': 2.625, 'Q4': 2.625,
22
+ 'Midterm': 35, 'Q5': 2.625, 'A2': 2, 'Q6': 2.625, 'Q7': 2.625,
23
+ 'Q8': 2.625, 'Final': 40
24
+ }
25
+ ict_max_marks = {
26
+ 'Q1': 30, 'Q2': 49, 'A1': 100, 'Q3': 30, 'Q4': 15,
27
+ 'Midterm': 35, 'Q5': 45, 'A2': 100, 'Q6': 32, 'Q7': 24,
28
+ 'Q8': 40, 'Final': 100
29
+ }
30
+
31
+ def normalize_input(input_activities, weights, max_marks):
32
+ """
33
+ Normalize the input activities based on weights and max marks.
34
+ """
35
+ normalized_activities = []
36
+ for activity, score in input_activities.items():
37
+ if score > 0: # Ignore zeros
38
+ normalized_score = (score / max_marks[activity]) * weights[activity]
39
+ normalized_activities.append(normalized_score)
40
+ return normalized_activities
41
+
42
+ def predict_final_score(input_activities, weights, max_marks, model_prefix):
43
+ """
44
+ Predict the final score based on input activities after normalization.
45
+ """
46
+ normalized_activities = normalize_input(input_activities, weights, max_marks)
47
+ n = len(normalized_activities)
48
+
49
+ if n == 0:
50
+ return "No valid activities entered. Please provide scores greater than 0."
51
+
52
+ try:
53
+ with open(f"{model_prefix}_model_{n}_activities.pkl", "rb") as file:
54
+ model = pickle.load(file)
55
+ except FileNotFoundError:
56
+ return f"No model available for {n} activities. Train the model first."
57
+
58
+ input_array = np.array(normalized_activities).reshape(1, -1)
59
+ predicted_score = model.predict(input_array)[0]
60
+ return round(predicted_score, 2)
61
+
62
+ @app.route('/', methods=['GET', 'POST'])
63
+ def home():
64
+ cc_predicted_score = None
65
+ ict_predicted_score = None
66
+
67
+ if request.method == 'POST':
68
+ # Identify the form (Cloud Computing or ICT)
69
+ form_type = request.form.get('form_type')
70
+
71
+ if form_type == 'cloud_computing':
72
+ input_activities = {activity: float(request.form.get(activity, 0)) for activity in cc_weights.keys()}
73
+ cc_predicted_score = predict_final_score(input_activities, cc_weights, cc_max_marks, "cc")
74
+
75
+ elif form_type == 'ict':
76
+ input_activities = {activity: float(request.form.get(activity, 0)) for activity in ict_weights.keys()}
77
+ ict_predicted_score = predict_final_score(input_activities, ict_weights, ict_max_marks, "ict")
78
+
79
+ return render_template(
80
+ 'index.html',
81
+ cc_max_marks=cc_max_marks,
82
+ ict_max_marks=ict_max_marks,
83
+ cc_predicted_score=cc_predicted_score,
84
+ ict_predicted_score=ict_predicted_score
85
+ )
86
 
87
  if __name__ == '__main__':
88
+ app.run(debug=False, port=5000)
ccdata.xlsx ADDED
Binary file (42.9 kB). View file
 
cloud_computing_model_10_activities.pkl ADDED
Binary file (135 kB). View file
 
cloud_computing_model_11_activities.pkl ADDED
Binary file (131 kB). View file
 
cloud_computing_model_12_activities.pkl ADDED
Binary file (134 kB). View file
 
cloud_computing_model_13_activities.pkl ADDED
Binary file (135 kB). View file
 
cloud_computing_model_14_activities.pkl ADDED
Binary file (129 kB). View file
 
cloud_computing_model_5_activities.pkl ADDED
Binary file (130 kB). View file
 
cloud_computing_model_6_activities.pkl ADDED
Binary file (132 kB). View file
 
cloud_computing_model_7_activities.pkl ADDED
Binary file (134 kB). View file
 
cloud_computing_model_8_activities.pkl ADDED
Binary file (129 kB). View file
 
cloud_computing_model_9_activities.pkl ADDED
Binary file (131 kB). View file
 
cloudcomputing.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
ict.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
ict_model_10_activities.pkl ADDED
Binary file (129 kB). View file
 
ict_model_11_activities.pkl ADDED
Binary file (127 kB). View file
 
ict_model_12_activities.pkl ADDED
Binary file (127 kB). View file
 
ict_model_5_activities.pkl ADDED
Binary file (128 kB). View file
 
ict_model_6_activities.pkl ADDED
Binary file (131 kB). View file
 
ict_model_7_activities.pkl ADDED
Binary file (131 kB). View file
 
ict_model_8_activities.pkl ADDED
Binary file (129 kB). View file
 
ict_model_9_activities.pkl ADDED
Binary file (128 kB). View file
 
requirements.txt CHANGED
@@ -1,17 +1,56 @@
 
 
1
  certifi==2024.12.14
2
  charset-normalizer==3.4.1
 
 
 
 
 
 
3
  filelock==3.16.1
 
4
  fsspec==2024.12.0
5
  huggingface-hub==0.27.0
6
  idna==3.10
 
 
 
 
 
7
  joblib==1.4.2
 
 
 
 
 
8
  numpy==2.2.1
 
9
  packaging==24.2
 
 
 
 
 
 
 
 
 
 
 
10
  PyYAML==6.0.2
 
11
  requests==2.32.3
12
  scikit-learn==1.6.0
13
  scipy==1.15.0
 
 
14
  threadpoolctl==3.5.0
 
15
  tqdm==4.67.1
 
16
  typing_extensions==4.12.2
 
17
  urllib3==2.3.0
 
 
 
1
+ asttokens==3.0.0
2
+ blinker==1.9.0
3
  certifi==2024.12.14
4
  charset-normalizer==3.4.1
5
+ click==8.1.8
6
+ comm==0.2.2
7
+ debugpy==1.8.11
8
+ decorator==5.1.1
9
+ et_xmlfile==2.0.0
10
+ executing==2.1.0
11
  filelock==3.16.1
12
+ Flask==3.1.0
13
  fsspec==2024.12.0
14
  huggingface-hub==0.27.0
15
  idna==3.10
16
+ ipykernel==6.29.5
17
+ ipython==8.31.0
18
+ itsdangerous==2.2.0
19
+ jedi==0.19.2
20
+ Jinja2==3.1.5
21
  joblib==1.4.2
22
+ jupyter_client==8.6.3
23
+ jupyter_core==5.7.2
24
+ MarkupSafe==3.0.2
25
+ matplotlib-inline==0.1.7
26
+ nest-asyncio==1.6.0
27
  numpy==2.2.1
28
+ openpyxl==3.1.5
29
  packaging==24.2
30
+ pandas==2.2.3
31
+ parso==0.8.4
32
+ pexpect==4.9.0
33
+ platformdirs==4.3.6
34
+ prompt_toolkit==3.0.48
35
+ psutil==6.1.1
36
+ ptyprocess==0.7.0
37
+ pure_eval==0.2.3
38
+ Pygments==2.19.0
39
+ python-dateutil==2.9.0.post0
40
+ pytz==2024.2
41
  PyYAML==6.0.2
42
+ pyzmq==26.2.0
43
  requests==2.32.3
44
  scikit-learn==1.6.0
45
  scipy==1.15.0
46
+ six==1.17.0
47
+ stack-data==0.6.3
48
  threadpoolctl==3.5.0
49
+ tornado==6.4.2
50
  tqdm==4.67.1
51
+ traitlets==5.14.3
52
  typing_extensions==4.12.2
53
+ tzdata==2024.2
54
  urllib3==2.3.0
55
+ wcwidth==0.2.13
56
+ Werkzeug==3.1.3
templates/index.html CHANGED
@@ -6,7 +6,36 @@
6
  <title>Student Score Predictor</title>
7
  </head>
8
  <body>
9
- <h1>Welcome to the Student Score Predictor</h1>
10
- <p>Submit your activities scores via POST request to /predict to get the final score prediction.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  </body>
12
  </html>
 
6
  <title>Student Score Predictor</title>
7
  </head>
8
  <body>
9
+ <h1>Student Score Predictor</h1>
10
+
11
+ <h2>Cloud Computing</h2>
12
+ <form method="POST" action="/">
13
+ <input type="hidden" name="form_type" value="cloud_computing">
14
+ <p>Enter your scores for the activities:</p>
15
+ {% for activity, max_mark in cc_max_marks.items() %}
16
+ <label for="cc_{{ activity }}">{{ activity }} (Max Marks: {{ max_mark }}):</label>
17
+ <input type="number" step="0.1" name="{{ activity }}" id="cc_{{ activity }}"><br>
18
+ {% endfor %}
19
+ <button type="submit">Predict Cloud Computing Final Score</button>
20
+ </form>
21
+
22
+ {% if cc_predicted_score is not none %}
23
+ <h3 style="color: blue;">Predicted Cloud Computing Final Score: {{ cc_predicted_score }}</h3>
24
+ {% endif %}
25
+
26
+ <h2>ICT</h2>
27
+ <form method="POST" action="/">
28
+ <input type="hidden" name="form_type" value="ict">
29
+ <p>Enter your scores for the activities:</p>
30
+ {% for activity, max_mark in ict_max_marks.items() %}
31
+ <label for="ict_{{ activity }}">{{ activity }} (Max Marks: {{ max_mark }}):</label>
32
+ <input type="number" step="0.1" name="{{ activity }}" id="ict_{{ activity }}"><br>
33
+ {% endfor %}
34
+ <button type="submit">Predict ICT Final Score</button>
35
+ </form>
36
+
37
+ {% if ict_predicted_score is not none %}
38
+ <h3 style="color: green;">Predicted ICT Final Score: {{ ict_predicted_score }}</h3>
39
+ {% endif %}
40
  </body>
41
  </html>
web.ipynb ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": null,
6
+ "metadata": {},
7
+ "outputs": [
8
+ {
9
+ "name": "stdout",
10
+ "output_type": "stream",
11
+ "text": [
12
+ " * Serving Flask app '__main__'\n",
13
+ " * Debug mode: off\n"
14
+ ]
15
+ },
16
+ {
17
+ "name": "stderr",
18
+ "output_type": "stream",
19
+ "text": [
20
+ "\u001b[31m\u001b[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.\u001b[0m\n",
21
+ " * Running on http://127.0.0.1:5000\n",
22
+ "\u001b[33mPress CTRL+C to quit\u001b[0m\n"
23
+ ]
24
+ },
25
+ {
26
+ "name": "stderr",
27
+ "output_type": "stream",
28
+ "text": [
29
+ "127.0.0.1 - - [06/Jan/2025 13:19:51] \"GET / HTTP/1.1\" 200 -\n",
30
+ "/home/faddy/Documents/7-sem/mlops/assignment4/.venv/lib/python3.11/site-packages/sklearn/utils/validation.py:2739: UserWarning: X does not have valid feature names, but GradientBoostingRegressor was fitted with feature names\n",
31
+ " warnings.warn(\n",
32
+ "127.0.0.1 - - [06/Jan/2025 13:20:05] \"POST / HTTP/1.1\" 200 -\n",
33
+ "127.0.0.1 - - [06/Jan/2025 13:20:16] \"POST / HTTP/1.1\" 200 -\n",
34
+ "127.0.0.1 - - [06/Jan/2025 13:20:28] \"POST / HTTP/1.1\" 200 -\n"
35
+ ]
36
+ }
37
+ ],
38
+ "source": [
39
+ "from flask import Flask, request, render_template\n",
40
+ "import numpy as np\n",
41
+ "import pickle\n",
42
+ "\n",
43
+ "app = Flask(__name__)\n",
44
+ "\n",
45
+ "# Cloud Computing Weights and Max Marks\n",
46
+ "cc_weights = {\n",
47
+ " 'A1': 1, 'Q1': 1.5, 'A2': 1, 'Q2': 1.5, 'A3': 1,\n",
48
+ " 'A4': 4, 'Q3': 1.5, 'Mid': 35, 'AWS Labs': 3,\n",
49
+ " 'Q4': 1.25, 'A5': 4, 'Q5': 1.25, 'A6': 4, 'Final': 40\n",
50
+ "}\n",
51
+ "cc_max_marks = {\n",
52
+ " 'A1': 10, 'Q1': 21, 'A2': 10, 'Q2': 30, 'A3': 100,\n",
53
+ " 'A4': 10, 'Q3': 41, 'Mid': 35, 'AWS Labs': 10,\n",
54
+ " 'Q4': 40, 'A5': 100, 'Q5': 20, 'A6': 100, 'Final': 40\n",
55
+ "}\n",
56
+ "\n",
57
+ "# ICT Weights and Max Marks\n",
58
+ "ict_weights = {\n",
59
+ " 'Q1': 2.625, 'Q2': 2.625, 'A1': 2, 'Q3': 2.625, 'Q4': 2.625,\n",
60
+ " 'Midterm': 35, 'Q5': 2.625, 'A2': 2, 'Q6': 2.625, 'Q7': 2.625,\n",
61
+ " 'Q8': 2.625, 'Final': 40\n",
62
+ "}\n",
63
+ "ict_max_marks = {\n",
64
+ " 'Q1': 30, 'Q2': 49, 'A1': 100, 'Q3': 30, 'Q4': 15,\n",
65
+ " 'Midterm': 35, 'Q5': 45, 'A2': 100, 'Q6': 32, 'Q7': 24,\n",
66
+ " 'Q8': 40, 'Final': 100\n",
67
+ "}\n",
68
+ "\n",
69
+ "def normalize_input(input_activities, weights, max_marks):\n",
70
+ " \"\"\"\n",
71
+ " Normalize the input activities based on weights and max marks.\n",
72
+ " \"\"\"\n",
73
+ " normalized_activities = []\n",
74
+ " for activity, score in input_activities.items():\n",
75
+ " if score > 0: # Ignore zeros\n",
76
+ " normalized_score = (score / max_marks[activity]) * weights[activity]\n",
77
+ " normalized_activities.append(normalized_score)\n",
78
+ " return normalized_activities\n",
79
+ "\n",
80
+ "def predict_final_score(input_activities, weights, max_marks, model_prefix):\n",
81
+ " \"\"\"\n",
82
+ " Predict the final score based on input activities after normalization.\n",
83
+ " \"\"\"\n",
84
+ " normalized_activities = normalize_input(input_activities, weights, max_marks)\n",
85
+ " n = len(normalized_activities)\n",
86
+ "\n",
87
+ " if n == 0:\n",
88
+ " return \"No valid activities entered. Please provide scores greater than 0.\"\n",
89
+ "\n",
90
+ " try:\n",
91
+ " with open(f\"{model_prefix}_model_{n}_activities.pkl\", \"rb\") as file:\n",
92
+ " model = pickle.load(file)\n",
93
+ " except FileNotFoundError:\n",
94
+ " return f\"No model available for {n} activities. Train the model first.\"\n",
95
+ "\n",
96
+ " input_array = np.array(normalized_activities).reshape(1, -1)\n",
97
+ " predicted_score = model.predict(input_array)[0]\n",
98
+ " return round(predicted_score, 2)\n",
99
+ "\n",
100
+ "@app.route('/', methods=['GET', 'POST'])\n",
101
+ "def home():\n",
102
+ " cc_predicted_score = None\n",
103
+ " ict_predicted_score = None\n",
104
+ "\n",
105
+ " if request.method == 'POST':\n",
106
+ " # Identify the form (Cloud Computing or ICT)\n",
107
+ " form_type = request.form.get('form_type')\n",
108
+ "\n",
109
+ " if form_type == 'cloud_computing':\n",
110
+ " input_activities = {\n",
111
+ " activity: float(request.form.get(activity, 0) or 0) # Default to 0 for empty inputs\n",
112
+ " for activity in cc_weights.keys()\n",
113
+ " }\n",
114
+ " cc_predicted_score = predict_final_score(input_activities, cc_weights, cc_max_marks, \"cloud_computing\")\n",
115
+ "\n",
116
+ " elif form_type == 'ict':\n",
117
+ " input_activities = {\n",
118
+ " activity: float(request.form.get(activity, 0) or 0) # Default to 0 for empty inputs\n",
119
+ " for activity in ict_weights.keys()\n",
120
+ " }\n",
121
+ " ict_predicted_score = predict_final_score(input_activities, ict_weights, ict_max_marks, \"ict\")\n",
122
+ "\n",
123
+ " return render_template(\n",
124
+ " 'index.html',\n",
125
+ " cc_max_marks=cc_max_marks,\n",
126
+ " ict_max_marks=ict_max_marks,\n",
127
+ " cc_predicted_score=cc_predicted_score,\n",
128
+ " ict_predicted_score=ict_predicted_score\n",
129
+ " )\n",
130
+ "\n",
131
+ "if __name__ == '__main__':\n",
132
+ " app.run(debug=False, port=5000)\n"
133
+ ]
134
+ }
135
+ ],
136
+ "metadata": {
137
+ "kernelspec": {
138
+ "display_name": ".venv",
139
+ "language": "python",
140
+ "name": "python3"
141
+ },
142
+ "language_info": {
143
+ "codemirror_mode": {
144
+ "name": "ipython",
145
+ "version": 3
146
+ },
147
+ "file_extension": ".py",
148
+ "mimetype": "text/x-python",
149
+ "name": "python",
150
+ "nbconvert_exporter": "python",
151
+ "pygments_lexer": "ipython3",
152
+ "version": "3.11.6"
153
+ }
154
+ },
155
+ "nbformat": 4,
156
+ "nbformat_minor": 2
157
+ }