{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"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)\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-03-26T02:21:56.825273Z","iopub.execute_input":"2023-03-26T02:21:56.825988Z","iopub.status.idle":"2023-03-26T02:21:56.858212Z","shell.execute_reply.started":"2023-03-26T02:21:56.825948Z","shell.execute_reply":"2023-03-26T02:21:56.857027Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Importing Libraries\n\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nfrom sklearn.model_selection import train_test_split","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:56.860246Z","iopub.execute_input":"2023-03-26T02:21:56.860886Z","iopub.status.idle":"2023-03-26T02:21:57.867786Z","shell.execute_reply.started":"2023-03-26T02:21:56.860845Z","shell.execute_reply":"2023-03-26T02:21:57.866698Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# Loading Dataset\n\ndf = pd.read_csv(\"/kaggle/input/predict-student-performance-from-game-play/train_labels.csv\")","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:57.870239Z","iopub.execute_input":"2023-03-26T02:21:57.870654Z","iopub.status.idle":"2023-03-26T02:21:58.231212Z","shell.execute_reply.started":"2023-03-26T02:21:57.870612Z","shell.execute_reply":"2023-03-26T02:21:58.230088Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df = df.sample(n=20000)","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.232612Z","iopub.execute_input":"2023-03-26T02:21:58.233014Z","iopub.status.idle":"2023-03-26T02:21:58.263614Z","shell.execute_reply.started":"2023-03-26T02:21:58.232972Z","shell.execute_reply":"2023-03-26T02:21:58.262340Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.266710Z","iopub.execute_input":"2023-03-26T02:21:58.267500Z","iopub.status.idle":"2023-03-26T02:21:58.284083Z","shell.execute_reply.started":"2023-03-26T02:21:58.267468Z","shell.execute_reply":"2023-03-26T02:21:58.283101Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.tail()","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.285773Z","iopub.execute_input":"2023-03-26T02:21:58.286185Z","iopub.status.idle":"2023-03-26T02:21:58.296145Z","shell.execute_reply.started":"2023-03-26T02:21:58.286144Z","shell.execute_reply":"2023-03-26T02:21:58.294856Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.sample(10)","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.298184Z","iopub.execute_input":"2023-03-26T02:21:58.298641Z","iopub.status.idle":"2023-03-26T02:21:58.315918Z","shell.execute_reply.started":"2023-03-26T02:21:58.298602Z","shell.execute_reply":"2023-03-26T02:21:58.314928Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.319982Z","iopub.execute_input":"2023-03-26T02:21:58.320377Z","iopub.status.idle":"2023-03-26T02:21:58.340239Z","shell.execute_reply.started":"2023-03-26T02:21:58.320338Z","shell.execute_reply":"2023-03-26T02:21:58.339098Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.duplicated().sum()","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.344778Z","iopub.execute_input":"2023-03-26T02:21:58.345170Z","iopub.status.idle":"2023-03-26T02:21:58.377608Z","shell.execute_reply.started":"2023-03-26T02:21:58.345131Z","shell.execute_reply":"2023-03-26T02:21:58.376477Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.381875Z","iopub.execute_input":"2023-03-26T02:21:58.382955Z","iopub.status.idle":"2023-03-26T02:21:58.403189Z","shell.execute_reply.started":"2023-03-26T02:21:58.382904Z","shell.execute_reply":"2023-03-26T02:21:58.402000Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.shape","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.407854Z","iopub.execute_input":"2023-03-26T02:21:58.409073Z","iopub.status.idle":"2023-03-26T02:21:58.416637Z","shell.execute_reply.started":"2023-03-26T02:21:58.408997Z","shell.execute_reply":"2023-03-26T02:21:58.415442Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.correct.value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.418220Z","iopub.execute_input":"2023-03-26T02:21:58.419417Z","iopub.status.idle":"2023-03-26T02:21:58.429429Z","shell.execute_reply.started":"2023-03-26T02:21:58.419378Z","shell.execute_reply":"2023-03-26T02:21:58.427820Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.session_id","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.431645Z","iopub.execute_input":"2023-03-26T02:21:58.432650Z","iopub.status.idle":"2023-03-26T02:21:58.442193Z","shell.execute_reply.started":"2023-03-26T02:21:58.432611Z","shell.execute_reply":"2023-03-26T02:21:58.440825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['question'] = df['session_id'].apply(lambda x: x.split(\"q\")[1])","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.443840Z","iopub.execute_input":"2023-03-26T02:21:58.444534Z","iopub.status.idle":"2023-03-26T02:21:58.466599Z","shell.execute_reply.started":"2023-03-26T02:21:58.444493Z","shell.execute_reply":"2023-03-26T02:21:58.465436Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head()","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.468102Z","iopub.execute_input":"2023-03-26T02:21:58.469332Z","iopub.status.idle":"2023-03-26T02:21:58.486975Z","shell.execute_reply.started":"2023-03-26T02:21:58.469282Z","shell.execute_reply":"2023-03-26T02:21:58.485589Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['session_id'] = df['session_id'].str.replace('_q2', '').str.replace('_q3', '')\ndf['session_id'] = df['session_id'].str.replace('_q4', '').str.replace('_q5', '')\ndf['session_id'] = df['session_id'].str.replace('_q6', '').str.replace('_q7', '')\ndf['session_id'] = df['session_id'].str.replace('_q8', '').str.replace('_q9', '')\ndf['session_id'] = df['session_id'].str.replace('_q10', '').str.replace('_q11', '')\ndf['session_id'] = df['session_id'].str.replace('_q12', '').str.replace('_q1', '')\ndf['session_id'] = df['session_id'].str.replace('_q13', '').str.replace('_q14', '')\ndf['session_id'] = df['session_id'].str.replace('_q15', '').str.replace('_q16', '')\ndf['session_id'] = df['session_id'].str.replace('_q17', '').str.replace('_q18', '')","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.491805Z","iopub.execute_input":"2023-03-26T02:21:58.494203Z","iopub.status.idle":"2023-03-26T02:21:58.897303Z","shell.execute_reply.started":"2023-03-26T02:21:58.494163Z","shell.execute_reply":"2023-03-26T02:21:58.896111Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df['session_id'] = df['session_id'].astype('int16')","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.902427Z","iopub.execute_input":"2023-03-26T02:21:58.904885Z","iopub.status.idle":"2023-03-26T02:21:58.917902Z","shell.execute_reply.started":"2023-03-26T02:21:58.904842Z","shell.execute_reply":"2023-03-26T02:21:58.916842Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Splitting data ","metadata":{}},{"cell_type":"code","source":"X = df.session_id\ny = df.correct","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.922961Z","iopub.execute_input":"2023-03-26T02:21:58.925827Z","iopub.status.idle":"2023-03-26T02:21:58.932929Z","shell.execute_reply.started":"2023-03-26T02:21:58.925774Z","shell.execute_reply":"2023-03-26T02:21:58.931840Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.938189Z","iopub.execute_input":"2023-03-26T02:21:58.939276Z","iopub.status.idle":"2023-03-26T02:21:58.949812Z","shell.execute_reply.started":"2023-03-26T02:21:58.939236Z","shell.execute_reply":"2023-03-26T02:21:58.948395Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Standardize the data","metadata":{}},{"cell_type":"code","source":"from sklearn.preprocessing import StandardScaler","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.951348Z","iopub.execute_input":"2023-03-26T02:21:58.951957Z","iopub.status.idle":"2023-03-26T02:21:58.958128Z","shell.execute_reply.started":"2023-03-26T02:21:58.951916Z","shell.execute_reply":"2023-03-26T02:21:58.955887Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"ss = StandardScaler()\n\n# convert X_train and X_test to numpy arrays and reshape them\nX_train_np = X_train.to_numpy().reshape(-1, 1)\nX_test_np = X_test.to_numpy().reshape(-1, 1)\n\n# apply the StandardScaler to the numpy arrays\nX_train_scaled = ss.fit_transform(X_train_np)\nX_test_scaled = ss.transform(X_test_np)\n\n# convert the scaled numpy arrays back to pandas Series objects\nX_train = pd.Series(X_train_scaled.reshape(-1))\nX_test = pd.Series(X_test_scaled.reshape(-1))","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.960357Z","iopub.execute_input":"2023-03-26T02:21:58.961467Z","iopub.status.idle":"2023-03-26T02:21:58.974959Z","shell.execute_reply.started":"2023-03-26T02:21:58.961424Z","shell.execute_reply":"2023-03-26T02:21:58.973865Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pip install lazypredict","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:21:58.977059Z","iopub.execute_input":"2023-03-26T02:21:58.977527Z","iopub.status.idle":"2023-03-26T02:22:09.741110Z","shell.execute_reply.started":"2023-03-26T02:21:58.977486Z","shell.execute_reply":"2023-03-26T02:22:09.739625Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"# Model Training","metadata":{}},{"cell_type":"code","source":"from lazypredict.Supervised import LazyClassifier","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:22:09.743430Z","iopub.execute_input":"2023-03-26T02:22:09.743886Z","iopub.status.idle":"2023-03-26T02:22:12.711567Z","shell.execute_reply.started":"2023-03-26T02:22:09.743836Z","shell.execute_reply":"2023-03-26T02:22:12.710343Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"clf = LazyClassifier(verbose=0,ignore_warnings=True, custom_metric=None)","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:22:12.713479Z","iopub.execute_input":"2023-03-26T02:22:12.713885Z","iopub.status.idle":"2023-03-26T02:22:12.721385Z","shell.execute_reply.started":"2023-03-26T02:22:12.713840Z","shell.execute_reply":"2023-03-26T02:22:12.720099Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"#models,predictions = clf.fit(X_train, X_test, y_train, y_test)\nmodels,predictions = clf.fit(X_train.to_frame(), X_test.to_frame(), y_train, y_test)","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:22:12.723280Z","iopub.execute_input":"2023-03-26T02:22:12.723751Z","iopub.status.idle":"2023-03-26T02:22:48.457017Z","shell.execute_reply.started":"2023-03-26T02:22:12.723685Z","shell.execute_reply":"2023-03-26T02:22:48.456048Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"models","metadata":{"execution":{"iopub.status.busy":"2023-03-26T02:22:48.459263Z","iopub.execute_input":"2023-03-26T02:22:48.460063Z","iopub.status.idle":"2023-03-26T02:22:48.476635Z","shell.execute_reply.started":"2023-03-26T02:22:48.459999Z","shell.execute_reply":"2023-03-26T02:22:48.475918Z"},"trusted":true},"execution_count":null,"outputs":[]}]}