{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":53666,"databundleVersionId":6589269,"sourceType":"competition"}],"dockerImageVersionId":30587,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport matplotlib.pyplot as plt\nimport warnings\nwarnings.filterwarnings('ignore')\n\n\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-11-26T13:17:03.368190Z","iopub.execute_input":"2023-11-26T13:17:03.368696Z","iopub.status.idle":"2023-11-26T13:17:03.380243Z","shell.execute_reply.started":"2023-11-26T13:17:03.368658Z","shell.execute_reply":"2023-11-26T13:17:03.378713Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Data Mining Pipeline and Preprocessing","metadata":{}},{"cell_type":"code","source":"training_data_events = pd.read_csv('/kaggle/input/child-mind-institute-detect-sleep-states/train_events.csv')\ntraining_data_events","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:17:03.443255Z","iopub.execute_input":"2023-11-26T13:17:03.443722Z","iopub.status.idle":"2023-11-26T13:17:03.488464Z","shell.execute_reply.started":"2023-11-26T13:17:03.443688Z","shell.execute_reply":"2023-11-26T13:17:03.487270Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def translate_time(data: pd.DataFrame, col: str):\n    try:\n        data['datetime'] = data[col].astype(str).str.replace('T', ' ').str[:-5]\n        data['datetime'] = pd.to_datetime(data['datetime'] )\n    except Exception as e:\n        print(e)\n    return data\n\ntraining_data_events = translate_time(training_data_events, \"timestamp\")\ntraining_data_events.sample(5)","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:17:03.510727Z","iopub.execute_input":"2023-11-26T13:17:03.511148Z","iopub.status.idle":"2023-11-26T13:17:03.568103Z","shell.execute_reply.started":"2023-11-26T13:17:03.511116Z","shell.execute_reply":"2023-11-26T13:17:03.566646Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_data_events.isna().sum()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:17:03.571518Z","iopub.execute_input":"2023-11-26T13:17:03.572047Z","iopub.status.idle":"2023-11-26T13:17:03.588513Z","shell.execute_reply.started":"2023-11-26T13:17:03.572000Z","shell.execute_reply":"2023-11-26T13:17:03.587154Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"training_data_events.dropna().nunique()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:17:03.590766Z","iopub.execute_input":"2023-11-26T13:17:03.591280Z","iopub.status.idle":"2023-11-26T13:17:03.620379Z","shell.execute_reply.started":"2023-11-26T13:17:03.591214Z","shell.execute_reply":"2023-11-26T13:17:03.619151Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_events = pd.read_csv('/kaggle/input/child-mind-institute-detect-sleep-states/train_events.csv')\ntrain_series = pd.read_parquet('/kaggle/input/child-mind-institute-detect-sleep-states/train_series.parquet')","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:17:03.622218Z","iopub.execute_input":"2023-11-26T13:17:03.623051Z","iopub.status.idle":"2023-11-26T13:18:28.607541Z","shell.execute_reply.started":"2023-11-26T13:17:03.623015Z","shell.execute_reply":"2023-11-26T13:18:28.603916Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"top_five_series = train_events.groupby('series_id')['event'].count().sort_values(ascending=False).head(5)\ntop_five_series","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:18:28.616347Z","iopub.execute_input":"2023-11-26T13:18:28.618722Z","iopub.status.idle":"2023-11-26T13:18:28.649016Z","shell.execute_reply.started":"2023-11-26T13:18:28.618603Z","shell.execute_reply":"2023-11-26T13:18:28.646862Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_series_subset = train_series[train_series['series_id'].isin(top_five_series.index)]\ntrain_series_subset = translate_time(train_series_subset, 'timestamp')\n\ntrain_events_subset = train_events[train_events['series_id'].isin(top_five_series.index)]\ntrain_events_subset = translate_time(train_events_subset, 'timestamp')\n\nmask_non_NULL = (~train_events_subset['step'].isnull()) | (~train_events_subset['timestamp'].isnull())\ntrain_events_subset_nonNULL = train_events_subset[mask_non_NULL]\n\ntrain_data_events = pd.merge(train_series_subset, train_events_subset_nonNULL, on=['series_id', 'timestamp', 'datetime'], how='left')\n\ntrain_data_events = train_data_events.drop(['step_y'], axis=1)\ntrain_data_events = train_data_events.rename(columns = {'step_x' : 'step'})\n\ntrain_data_events['event'].fillna(\"NoChange\", inplace=True)\n\ndef event_cat_mapper(x):\n    if x == \"NoChange\":\n        return 0\n    elif x == \"wakeup\":\n        return 1\n    return 2\ntrain_data_events[\"event_cat\"] = train_data_events['event'].apply(event_cat_mapper)\n\ntrain_data_events[\"y\"] = \"NULL\"\n\nfor idx in train_data_events['series_id'].unique():\n    print(idx)\n    val = 0\n    for index, row in train_data_events[train_data_events['series_id'] == idx].iterrows():\n        if row['event'] == \"NoChange\":\n            train_data_events.loc[index, 'y'] = val\n        else:\n            if row['event'] == 'wakeup':\n                val = 0\n                train_data_events.loc[index, 'y'] = val\n            else:\n                val = 1\n                train_data_events.loc[index, 'y'] = val","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:18:28.652317Z","iopub.execute_input":"2023-11-26T13:18:28.654017Z","iopub.status.idle":"2023-11-26T13:34:12.761874Z","shell.execute_reply.started":"2023-11-26T13:18:28.653946Z","shell.execute_reply":"2023-11-26T13:34:12.760327Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_events","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:34:12.763756Z","iopub.execute_input":"2023-11-26T13:34:12.764218Z","iopub.status.idle":"2023-11-26T13:34:12.793184Z","shell.execute_reply.started":"2023-11-26T13:34:12.764176Z","shell.execute_reply":"2023-11-26T13:34:12.791821Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X = train_data_events.drop(columns=['y', 'series_id', 'night', 'event', 'event_cat', 'timestamp', 'datetime'])\ny = train_data_events['y'].astype('int')\n\nfrom sklearn.model_selection import train_test_split\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)\nX_train","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:34:12.794610Z","iopub.execute_input":"2023-11-26T13:34:12.795021Z","iopub.status.idle":"2023-11-26T13:34:14.474727Z","shell.execute_reply.started":"2023-11-26T13:34:12.794988Z","shell.execute_reply":"2023-11-26T13:34:14.473402Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:34:14.476475Z","iopub.execute_input":"2023-11-26T13:34:14.477000Z","iopub.status.idle":"2023-11-26T13:34:14.493666Z","shell.execute_reply.started":"2023-11-26T13:34:14.476954Z","shell.execute_reply":"2023-11-26T13:34:14.492432Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import xgboost as xgb\n# Assuming X_train and y_train are your feature matrix and target variable\ndtrain = xgb.DMatrix(X_train, label=y_train)\nparams = {\n    'objective': 'binary:logistic',\n    'max_depth': 3,\n    'learning_rate': 0.1,\n    'eval_metric': 'logloss'\n}\nnum_round = 100  # Number of boosting rounds\nmodel = xgb.train(params, dtrain, num_round)\n","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:34:14.495401Z","iopub.execute_input":"2023-11-26T13:34:14.495817Z","iopub.status.idle":"2023-11-26T13:34:28.721652Z","shell.execute_reply.started":"2023-11-26T13:34:14.495774Z","shell.execute_reply":"2023-11-26T13:34:28.720666Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score, confusion_matrix, classification_report\ny_pred = model.predict(xgb.DMatrix(X_test, label=y_test))\npredictions = [round(value) for value in y_pred]\naccuracy = accuracy_score(y_test, predictions) * 100\nconf_matrix = confusion_matrix(y_test, predictions)\nclassification_rep = classification_report(y_test, predictions)\n\nprint(\"Accuracy:\", accuracy)\nprint(\"Confusion Matrix:\\n\", conf_matrix)\nprint(\"Classification Report:\\n\", classification_rep)\n","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:34:28.723591Z","iopub.execute_input":"2023-11-26T13:34:28.724336Z","iopub.status.idle":"2023-11-26T13:34:34.728458Z","shell.execute_reply.started":"2023-11-26T13:34:28.724298Z","shell.execute_reply":"2023-11-26T13:34:34.726958Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.ensemble import AdaBoostClassifier\nadb = AdaBoostClassifier(n_estimators=100)\nadb.fit(X_train, y_train)","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:34:34.730437Z","iopub.execute_input":"2023-11-26T13:34:34.730932Z","iopub.status.idle":"2023-11-26T13:45:16.277799Z","shell.execute_reply.started":"2023-11-26T13:34:34.730878Z","shell.execute_reply":"2023-11-26T13:45:16.276080Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = adb.predict(X_test)\naccuracy = accuracy_score(y_test, y_pred) * 100\nconf_matrix = confusion_matrix(y_test, y_pred)\nclassification_rep = classification_report(y_test, y_pred)\n\nprint(\"Accuracy:\", accuracy)\nprint(\"Confusion Matrix:\\n\", conf_matrix)\nprint(\"Classification Report:\\n\", classification_rep)","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:45:16.279888Z","iopub.execute_input":"2023-11-26T13:45:16.280871Z","iopub.status.idle":"2023-11-26T13:45:29.613465Z","shell.execute_reply.started":"2023-11-26T13:45:16.280833Z","shell.execute_reply":"2023-11-26T13:45:29.611831Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_events","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:45:29.620603Z","iopub.execute_input":"2023-11-26T13:45:29.621033Z","iopub.status.idle":"2023-11-26T13:45:29.653775Z","shell.execute_reply.started":"2023-11-26T13:45:29.620998Z","shell.execute_reply":"2023-11-26T13:45:29.652043Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_events['y'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:45:29.656073Z","iopub.execute_input":"2023-11-26T13:45:29.656557Z","iopub.status.idle":"2023-11-26T13:45:30.308869Z","shell.execute_reply.started":"2023-11-26T13:45:29.656515Z","shell.execute_reply":"2023-11-26T13:45:30.307168Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_events.series_id.value_counts().keys().tolist()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:45:30.310549Z","iopub.execute_input":"2023-11-26T13:45:30.310971Z","iopub.status.idle":"2023-11-26T13:45:30.955818Z","shell.execute_reply.started":"2023-11-26T13:45:30.310911Z","shell.execute_reply":"2023-11-26T13:45:30.954197Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.linalg.norm(train_data_events[(train_data_events['y'] == 1) & (train_data_events['series_id'] == 'cfeb11428dd7')]['anglez'].values)","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:45:30.958046Z","iopub.execute_input":"2023-11-26T13:45:30.958571Z","iopub.status.idle":"2023-11-26T13:45:32.739405Z","shell.execute_reply.started":"2023-11-26T13:45:30.958527Z","shell.execute_reply":"2023-11-26T13:45:32.738022Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.linalg.norm(train_data_events[(train_data_events['y'] == 0) & (train_data_events['series_id'] == 'cfeb11428dd7')]['anglez'].values)","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:45:32.741272Z","iopub.execute_input":"2023-11-26T13:45:32.741695Z","iopub.status.idle":"2023-11-26T13:45:34.528490Z","shell.execute_reply.started":"2023-11-26T13:45:32.741662Z","shell.execute_reply":"2023-11-26T13:45:34.527341Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"series_ids = train_data_events.series_id.value_counts().keys().tolist()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:45:34.530287Z","iopub.execute_input":"2023-11-26T13:45:34.530783Z","iopub.status.idle":"2023-11-26T13:45:35.170392Z","shell.execute_reply.started":"2023-11-26T13:45:34.530750Z","shell.execute_reply":"2023-11-26T13:45:35.168588Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import math\ntrain_data_events['lin_norm'] = 0","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:45:35.172173Z","iopub.execute_input":"2023-11-26T13:45:35.172527Z","iopub.status.idle":"2023-11-26T13:45:35.192566Z","shell.execute_reply.started":"2023-11-26T13:45:35.172490Z","shell.execute_reply":"2023-11-26T13:45:35.191099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for idx in train_data_events['series_id'].unique():\n    print(idx)\n    for index, row in train_data_events[train_data_events['series_id'] == idx].iterrows():\n        if index < 4:\n            pass\n        else:\n            train_data_events.loc[index, 'lin_norm'] = val = np.linalg.norm(train_data_events.loc[index-4:index, 'anglez'].values)","metadata":{"execution":{"iopub.status.busy":"2023-11-26T13:45:35.194212Z","iopub.execute_input":"2023-11-26T13:45:35.194561Z","iopub.status.idle":"2023-11-26T14:18:00.197913Z","shell.execute_reply.started":"2023-11-26T13:45:35.194533Z","shell.execute_reply":"2023-11-26T14:18:00.196442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_events.head(10)","metadata":{"execution":{"iopub.status.busy":"2023-11-26T14:18:00.199802Z","iopub.execute_input":"2023-11-26T14:18:00.200230Z","iopub.status.idle":"2023-11-26T14:18:00.225955Z","shell.execute_reply.started":"2023-11-26T14:18:00.200197Z","shell.execute_reply":"2023-11-26T14:18:00.224567Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nplt.plot(train_data_events[train_data_events['series_id'] == '78569a801a38']['lin_norm'])\nplt.plot(train_data_events[train_data_events['series_id'] == '78569a801a38']['y'] * 200)\nplt.figure(figsize=(10, 10))\n# plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T14:18:00.227718Z","iopub.execute_input":"2023-11-26T14:18:00.228169Z","iopub.status.idle":"2023-11-26T14:18:03.717809Z","shell.execute_reply.started":"2023-11-26T14:18:00.228118Z","shell.execute_reply":"2023-11-26T14:18:03.716930Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nplt.plot(train_data_events[train_data_events['series_id'] == 'cfeb11428dd7']['lin_norm'])\nplt.plot(train_data_events[train_data_events['series_id'] == 'cfeb11428dd7']['y'] * 200)\nplt.figure(figsize=(10, 10))\n# plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T14:18:03.719292Z","iopub.execute_input":"2023-11-26T14:18:03.719868Z","iopub.status.idle":"2023-11-26T14:18:06.803657Z","shell.execute_reply.started":"2023-11-26T14:18:03.719833Z","shell.execute_reply":"2023-11-26T14:18:06.802162Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nplt.plot(train_data_events[train_data_events['series_id'] == 'f564985ab692']['lin_norm'])\nplt.plot(train_data_events[train_data_events['series_id'] == 'f564985ab692']['y'] * 200)\nplt.figure(figsize=(10, 10))\n# plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T14:18:06.805682Z","iopub.execute_input":"2023-11-26T14:18:06.806811Z","iopub.status.idle":"2023-11-26T14:18:10.025510Z","shell.execute_reply.started":"2023-11-26T14:18:06.806757Z","shell.execute_reply":"2023-11-26T14:18:10.023881Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nplt.plot(train_data_events[train_data_events['series_id'] == 'fb223ed2278c']['lin_norm'])\nplt.plot(train_data_events[train_data_events['series_id'] == 'fb223ed2278c']['y'] * 200)\nplt.figure(figsize=(10, 10))\n# plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T14:18:10.027154Z","iopub.execute_input":"2023-11-26T14:18:10.027475Z","iopub.status.idle":"2023-11-26T14:18:13.185468Z","shell.execute_reply.started":"2023-11-26T14:18:10.027445Z","shell.execute_reply":"2023-11-26T14:18:13.183841Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nplt.plot(train_data_events[train_data_events['series_id'] == 'f56824b503a0']['lin_norm'])\nplt.plot(train_data_events[train_data_events['series_id'] == 'f56824b503a0']['y'] * 200)\nplt.figure(figsize=(10, 10))\n# plt.show()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T14:18:13.187542Z","iopub.execute_input":"2023-11-26T14:18:13.188055Z","iopub.status.idle":"2023-11-26T14:18:16.356238Z","shell.execute_reply.started":"2023-11-26T14:18:13.188017Z","shell.execute_reply":"2023-11-26T14:18:16.354497Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_events['math_predictions'] = train_data_events['lin_norm'].apply(lambda x: 1 if x > 100 else 0)\ntrain_data_events","metadata":{"execution":{"iopub.status.busy":"2023-11-26T14:18:16.358330Z","iopub.execute_input":"2023-11-26T14:18:16.358899Z","iopub.status.idle":"2023-11-26T14:18:21.096094Z","shell.execute_reply.started":"2023-11-26T14:18:16.358850Z","shell.execute_reply":"2023-11-26T14:18:21.095120Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_events['math_predictions'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T14:18:21.097341Z","iopub.execute_input":"2023-11-26T14:18:21.098252Z","iopub.status.idle":"2023-11-26T14:18:21.158059Z","shell.execute_reply.started":"2023-11-26T14:18:21.098215Z","shell.execute_reply":"2023-11-26T14:18:21.156430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_events['y'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T14:18:21.160117Z","iopub.execute_input":"2023-11-26T14:18:21.160570Z","iopub.status.idle":"2023-11-26T14:18:21.805308Z","shell.execute_reply.started":"2023-11-26T14:18:21.160537Z","shell.execute_reply":"2023-11-26T14:18:21.804261Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_events['lin_norm'].value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-11-26T14:18:21.806540Z","iopub.execute_input":"2023-11-26T14:18:21.807793Z","iopub.status.idle":"2023-11-26T14:18:22.349345Z","shell.execute_reply.started":"2023-11-26T14:18:21.807747Z","shell.execute_reply":"2023-11-26T14:18:22.347799Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_data_events['math_predictions']","metadata":{"execution":{"iopub.status.busy":"2023-11-26T14:39:49.934184Z","iopub.execute_input":"2023-11-26T14:39:49.934822Z","iopub.status.idle":"2023-11-26T14:39:49.949014Z","shell.execute_reply.started":"2023-11-26T14:39:49.934771Z","shell.execute_reply":"2023-11-26T14:39:49.947018Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import accuracy_score, confusion_matrix, classification_report\n\naccuracy = accuracy_score(train_data_events['math_predictions'], train_data_events['y'].astype('int16')) * 100\nconf_matrix = confusion_matrix(train_data_events['math_predictions'], train_data_events['y'].astype('int16'))\nclassification_rep = classification_report(train_data_events['math_predictions'], train_data_events['y'].astype('int16'))\n\nprint(\"Accuracy:\", accuracy)\nprint(\"Confusion Matrix:\\n\", conf_matrix)\nprint(\"Classification Report:\\n\", classification_rep)","metadata":{"execution":{"iopub.status.busy":"2023-11-26T14:42:07.740700Z","iopub.execute_input":"2023-11-26T14:42:07.741179Z","iopub.status.idle":"2023-11-26T14:42:20.452210Z","shell.execute_reply.started":"2023-11-26T14:42:07.741133Z","shell.execute_reply":"2023-11-26T14:42:20.450993Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}