Commit 3d883784 authored by Chamodi Yapa's avatar Chamodi Yapa

ML Model for dyscalculia

parent 28c4f42b
{
"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
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment