Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
LearnJoy-ML
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TMP-2023-24-059
LearnJoy-ML
Commits
3d883784
Commit
3d883784
authored
Mar 08, 2024
by
Chamodi Yapa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ML Model for dyscalculia
parent
28c4f42b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
0 deletions
+81
-0
final_model_deploy.ipynb
final_model_deploy.ipynb
+81
-0
No files found.
final_model_deploy.ipynb
0 → 100644
View file @
3d883784
{
"cells": [
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Predicted Improvement Score: 78.01%\n"
]
}
],
"source": [
"import joblib\n",
"import numpy as np\n",
"import warnings\n",
"\n",
"# Load the saved model and scalers\n",
"rf_model = joblib.load(\"./fun1/rf_model.pkl\")\n",
"scaler_X = joblib.load(\"./fun1/scaler_X.pkl\")\n",
"scaler_y = joblib.load(\"./fun1/scaler_y.pkl\")\n",
"\n",
"def predict_improvement_score(success_count, attempt_count, game_score_xp, game_level, engagement_time_mins):\n",
" # Prepare the user inputs as a numpy array\n",
" user_inputs = np.array([success_count, attempt_count, game_score_xp, game_level, engagement_time_mins]).reshape(1, -1)\n",
" \n",
" # Disable warnings\n",
" warnings.filterwarnings(\"ignore\")\n",
" \n",
" # Scale the user inputs using the loaded scalers\n",
" user_inputs_scaled = scaler_X.transform(user_inputs)\n",
" \n",
" # Enable warnings again\n",
" warnings.filterwarnings(\"default\")\n",
" \n",
" # Make the prediction using the loaded model\n",
" predicted_score_scaled = rf_model.predict(user_inputs_scaled)\n",
" \n",
" # Inverse transform to get the predicted score back to the original scale\n",
" predicted_score = scaler_y.inverse_transform(predicted_score_scaled.reshape(1, -1))\n",
" \n",
" return predicted_score[0][0] * 10\n",
"\n",
"# Example usage:\n",
"success_count = 8\n",
"attempt_count = 10\n",
"game_score_xp = 73\n",
"game_level = 9\n",
"engagement_time_mins = 5\n",
"\n",
"predicted_improvement_score = predict_improvement_score(success_count, attempt_count, game_score_xp, game_level, engagement_time_mins)\n",
"\n",
"print(f\"Predicted Improvement Score: {predicted_improvement_score:.2f}%\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "learn-joy",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment