{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.12.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[],"dockerImageVersionId":28755,"isInternetEnabled":false,"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)\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\n\n# Use the kagglehub client library to attach Kaggle resources like competitions, datasets, and models to your session\n# Learn more about kagglehub: https://github.com/Kaggle/kagglehub/blob/main/README.md\n\nimport kagglehub\n# kagglehub.dataset_download('<owner>/<dataset-slug>')","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"execution":{"iopub.status.busy":"2026-09-20T01:57:15.146029Z","iopub.execute_input":"2026-09-20T01:57:15.146325Z","iopub.status.idle":"2026-09-20T01:57:17.69421Z","shell.execute_reply.started":"2026-09-20T01:57:15.146296Z","shell.execute_reply":"2026-09-20T01:57:17.693171Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:49:10.065223Z","iopub.execute_input":"2026-09-20T02:49:10.065573Z","iopub.status.idle":"2026-09-20T02:49:10.072449Z","shell.execute_reply.started":"2026-09-20T02:49:10.065544Z","shell.execute_reply":"2026-09-20T02:49:10.071107Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df = pd.read_csv(\"/kaggle/input/competitions/covid-19-bioinformatics-scrna-target-challenge-bhi/covid-selected-data.csv\")\nlaballed_df = pd.read_csv(\"/kaggle/input/competitions/covid-19-bioinformatics-scrna-target-challenge-bhi/covid-selected-data-labels.csv\")","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:49:12.237203Z","iopub.execute_input":"2026-09-20T02:49:12.237556Z","iopub.status.idle":"2026-09-20T02:49:22.595332Z","shell.execute_reply.started":"2026-09-20T02:49:12.237525Z","shell.execute_reply":"2026-09-20T02:49:22.594261Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.info()\nlaballed_df.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:42:46.210406Z","iopub.execute_input":"2026-09-20T02:42:46.210731Z","iopub.status.idle":"2026-09-20T02:42:46.385656Z","shell.execute_reply.started":"2026-09-20T02:42:46.210704Z","shell.execute_reply":"2026-09-20T02:42:46.384694Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.head(5)\nlaballed_df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:05:40.255899Z","iopub.execute_input":"2026-09-20T02:05:40.256336Z","iopub.status.idle":"2026-09-20T02:05:40.26637Z","shell.execute_reply.started":"2026-09-20T02:05:40.256302Z","shell.execute_reply":"2026-09-20T02:05:40.265352Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"df.rename(columns = {'Unnamed: 0': 'Samples'}, inplace = True)\nlaballed_df.rename(columns = {'Unnamed: 0': 'Samples'}, inplace = True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:49:28.834089Z","iopub.execute_input":"2026-09-20T02:49:28.834499Z","iopub.status.idle":"2026-09-20T02:49:28.842515Z","shell.execute_reply.started":"2026-09-20T02:49:28.834467Z","shell.execute_reply":"2026-09-20T02:49:28.841114Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"complt_df = pd.merge(df, laballed_df, on = 'Samples')","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:49:31.887313Z","iopub.execute_input":"2026-09-20T02:49:31.887637Z","iopub.status.idle":"2026-09-20T02:49:32.013729Z","shell.execute_reply.started":"2026-09-20T02:49:31.88761Z","shell.execute_reply":"2026-09-20T02:49:32.012771Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure()\nsns.histplot(complt_df['type'], kde = True)\nplt.title('Conditions of Disease')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:49:35.72447Z","iopub.execute_input":"2026-09-20T02:49:35.724906Z","iopub.status.idle":"2026-09-20T02:49:36.09055Z","shell.execute_reply.started":"2026-09-20T02:49:35.724875Z","shell.execute_reply":"2026-09-20T02:49:36.089513Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\ntrain_df, test_df = train_test_split(complt_df, test_size = 0.1, random_state = 42)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:49:40.097485Z","iopub.execute_input":"2026-09-20T02:49:40.09782Z","iopub.status.idle":"2026-09-20T02:49:40.299879Z","shell.execute_reply.started":"2026-09-20T02:49:40.097793Z","shell.execute_reply":"2026-09-20T02:49:40.298984Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:49:42.93824Z","iopub.execute_input":"2026-09-20T02:49:42.938577Z","iopub.status.idle":"2026-09-20T02:49:43.000521Z","shell.execute_reply.started":"2026-09-20T02:49:42.938546Z","shell.execute_reply":"2026-09-20T02:49:42.999476Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_df.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:49:45.624048Z","iopub.execute_input":"2026-09-20T02:49:45.624438Z","iopub.status.idle":"2026-09-20T02:49:45.79139Z","shell.execute_reply.started":"2026-09-20T02:49:45.624409Z","shell.execute_reply":"2026-09-20T02:49:45.790378Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure()\nsns.histplot(train_df['type'], kde = True)\nplt.title('Conditions of Disease')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:49:49.406575Z","iopub.execute_input":"2026-09-20T02:49:49.406926Z","iopub.status.idle":"2026-09-20T02:49:49.71732Z","shell.execute_reply.started":"2026-09-20T02:49:49.406896Z","shell.execute_reply":"2026-09-20T02:49:49.716394Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"plt.figure()\nsns.histplot(test_df['type'], kde = True)\nplt.title('Conditions of Disease')\nplt.show()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:49:53.054588Z","iopub.execute_input":"2026-09-20T02:49:53.055808Z","iopub.status.idle":"2026-09-20T02:49:53.274578Z","shell.execute_reply.started":"2026-09-20T02:49:53.055758Z","shell.execute_reply":"2026-09-20T02:49:53.273596Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.preprocessing import LabelEncoder\nlb = LabelEncoder()\ntrain_df['type'] = lb.fit_transform(train_df['type'])\ntest_df['type'] = lb.fit_transform(test_df['type'])\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:49:57.22743Z","iopub.execute_input":"2026-09-20T02:49:57.227792Z","iopub.status.idle":"2026-09-20T02:49:57.241809Z","shell.execute_reply.started":"2026-09-20T02:49:57.227761Z","shell.execute_reply":"2026-09-20T02:49:57.240758Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"train_df.drop(columns = ['Samples'], inplace = True)\nsample_names = test_df['Samples'].copy()\ntest_df.drop(columns = ['Samples'], inplace = True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:49:59.836468Z","iopub.execute_input":"2026-09-20T02:49:59.83679Z","iopub.status.idle":"2026-09-20T02:49:59.952479Z","shell.execute_reply.started":"2026-09-20T02:49:59.836764Z","shell.execute_reply":"2026-09-20T02:49:59.951509Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X = train_df.drop(columns = ['type'])\ny = train_df['type']\nX_train, X_test, y_train, y_test = train_test_split(X,y, test_size = 0.2, random_state = 42)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:50:03.304412Z","iopub.execute_input":"2026-09-20T02:50:03.304787Z","iopub.status.idle":"2026-09-20T02:50:03.636655Z","shell.execute_reply.started":"2026-09-20T02:50:03.304747Z","shell.execute_reply":"2026-09-20T02:50:03.635677Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"X_train.info()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T02:50:23.866101Z","iopub.execute_input":"2026-09-20T02:50:23.866494Z","iopub.status.idle":"2026-09-20T02:50:23.927784Z","shell.execute_reply.started":"2026-09-20T02:50:23.866464Z","shell.execute_reply":"2026-09-20T02:50:23.926747Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.ensemble import RandomForestClassifier\nfrom sklearn.metrics import roc_auc_score\nrb = RandomForestClassifier()\n\nrb.fit(X_train, y_train)\n\npred = rb.predict_proba(X_test)\nroc_auc = roc_auc_score(y_test, pred, multi_class='ovr')\nprint(\"ROC Report of sklearn:\", roc_auc)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T03:06:23.250936Z","iopub.execute_input":"2026-09-20T03:06:23.251298Z","iopub.status.idle":"2026-09-20T03:09:14.384629Z","shell.execute_reply.started":"2026-09-20T03:06:23.251267Z","shell.execute_reply":"2026-09-20T03:09:14.383544Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.metrics import classification_report\ny_pred = rb.predict(X_test)\nprint(\"Classification Report:\\n\", classification_report(y_test, y_pred))","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T03:24:36.898651Z","iopub.execute_input":"2026-09-20T03:24:36.903201Z","iopub.status.idle":"2026-09-20T03:24:37.106403Z","shell.execute_reply.started":"2026-09-20T03:24:36.903039Z","shell.execute_reply":"2026-09-20T03:24:37.104928Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"from sklearn.model_selection import cross_val_score\nscores = cross_val_score(rb, X, y, cv=5, scoring='accuracy')\nprint(\"Cross-validated accuracies:\", scores)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T03:29:02.519239Z","iopub.execute_input":"2026-09-20T03:29:02.51966Z","iopub.status.idle":"2026-09-20T03:43:22.802263Z","shell.execute_reply.started":"2026-09-20T03:29:02.519628Z","shell.execute_reply":"2026-09-20T03:43:22.801033Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_df.drop(columns = ('type'), inplace = True)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T03:48:45.870716Z","iopub.execute_input":"2026-09-20T03:48:45.87107Z","iopub.status.idle":"2026-09-20T03:48:45.891261Z","shell.execute_reply.started":"2026-09-20T03:48:45.87104Z","shell.execute_reply":"2026-09-20T03:48:45.889785Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"test_pred = rb.predict(test_df)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T03:49:03.592509Z","iopub.execute_input":"2026-09-20T03:49:03.592851Z","iopub.status.idle":"2026-09-20T03:49:03.721552Z","shell.execute_reply.started":"2026-09-20T03:49:03.592825Z","shell.execute_reply":"2026-09-20T03:49:03.720501Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"Decoded_result = lb.inverse_transform(test_pred)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T04:23:30.784144Z","iopub.execute_input":"2026-09-20T04:23:30.785506Z","iopub.status.idle":"2026-09-20T04:23:30.793905Z","shell.execute_reply.started":"2026-09-20T04:23:30.785464Z","shell.execute_reply":"2026-09-20T04:23:30.792952Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission_df = pd.DataFrame({\n    'Sample': sample_names,\n    'type': Decoded_result\n})\n\nsubmission_df.head()","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T04:23:36.7349Z","iopub.execute_input":"2026-09-20T04:23:36.735295Z","iopub.status.idle":"2026-09-20T04:23:36.750335Z","shell.execute_reply.started":"2026-09-20T04:23:36.735264Z","shell.execute_reply":"2026-09-20T04:23:36.749541Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"submission_df.to_csv('submission.csv', index=False)","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2026-09-20T04:24:29.813764Z","iopub.execute_input":"2026-09-20T04:24:29.814096Z","iopub.status.idle":"2026-09-20T04:24:29.838816Z","shell.execute_reply.started":"2026-09-20T04:24:29.814069Z","shell.execute_reply":"2026-09-20T04:24:29.837497Z"}},"outputs":[],"execution_count":null}]}