{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.14","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":81933,"databundleVersionId":9643020,"sourceType":"competition"}],"dockerImageVersionId":30775,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import pandas as pd\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport seaborn as sns\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.tree import DecisionTreeRegressor\nfrom sklearn.ensemble import RandomForestRegressor\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.preprocessing import MinMaxScaler\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.model_selection import cross_val_score\n","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2024-10-15T09:41:21.290697Z","iopub.execute_input":"2024-10-15T09:41:21.291083Z","iopub.status.idle":"2024-10-15T09:41:24.736824Z","shell.execute_reply.started":"2024-10-15T09:41:21.291045Z","shell.execute_reply":"2024-10-15T09:41:24.735229Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df=pd.read_csv(\"/kaggle/input/child-mind-institute-problematic-internet-use/train.csv\")","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:24.739440Z","iopub.execute_input":"2024-10-15T09:41:24.740196Z","iopub.status.idle":"2024-10-15T09:41:24.815054Z","shell.execute_reply.started":"2024-10-15T09:41:24.740120Z","shell.execute_reply":"2024-10-15T09:41:24.813990Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.set_option(\"display.max_columns\", None)","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:24.816487Z","iopub.execute_input":"2024-10-15T09:41:24.817474Z","iopub.status.idle":"2024-10-15T09:41:24.822284Z","shell.execute_reply.started":"2024-10-15T09:41:24.817424Z","shell.execute_reply":"2024-10-15T09:41:24.821060Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:24.824887Z","iopub.execute_input":"2024-10-15T09:41:24.825307Z","iopub.status.idle":"2024-10-15T09:41:24.849514Z","shell.execute_reply.started":"2024-10-15T09:41:24.825257Z","shell.execute_reply":"2024-10-15T09:41:24.848197Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head(3)","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:24.851093Z","iopub.execute_input":"2024-10-15T09:41:24.851603Z","iopub.status.idle":"2024-10-15T09:41:24.932289Z","shell.execute_reply.started":"2024-10-15T09:41:24.851548Z","shell.execute_reply":"2024-10-15T09:41:24.930539Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"fill_mode = [\n    \"Basic_Demos-Enroll_Season\",\n    \"Basic_Demos-Sex\",\n    \"CGAS-Season\",\n    \"Physical-Season\",\n    \"Fitness_Endurance-Season\",\n    \"FGC-Season\",\n    \"FGC-FGC_CU_Zone\",\n    \"FGC-FGC_GSND_Zone\",\n    \"FGC-FGC_GSD_Zone\",\n    \"FGC-FGC_PU_Zone\",\n    \"FGC-FGC_SRL_Zone\",\n    \"FGC-FGC_SRR_Zone\",\n    \"FGC-FGC_TL_Zone\",\n    \"BIA-Season\",\n    \"BIA-BIA_Activity_Level_num\",\n    \"BIA-BIA_Frame_num\",\n    \"PAQ_A-Season\",\n    \"PAQ_C-Season\",\n    \"PCIAT-Season\",\n    \"PCIAT-PCIAT_01\",\n    \"PCIAT-PCIAT_02\",\n    \"PCIAT-PCIAT_03\",\n    \"PCIAT-PCIAT_04\",\n    \"PCIAT-PCIAT_05\",\n    \"PCIAT-PCIAT_06\",\n    \"PCIAT-PCIAT_07\",\n    \"PCIAT-PCIAT_08\",\n    \"PCIAT-PCIAT_09\",\n    \"PCIAT-PCIAT_10\",\n    \"PCIAT-PCIAT_11\",\n    \"PCIAT-PCIAT_12\",\n    \"PCIAT-PCIAT_13\",\n    \"PCIAT-PCIAT_14\",\n    \"PCIAT-PCIAT_15\",\n    \"PCIAT-PCIAT_16\",\n    \"PCIAT-PCIAT_17\",\n    \"PCIAT-PCIAT_18\",\n    \"PCIAT-PCIAT_19\",\n    \"PCIAT-PCIAT_20\",\n    \"SDS-Season\",\n    \"PreInt_EduHx-Season\",\n    \"PreInt_EduHx-computerinternet_hoursday\"\n]","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:24.934109Z","iopub.execute_input":"2024-10-15T09:41:24.934623Z","iopub.status.idle":"2024-10-15T09:41:24.944528Z","shell.execute_reply.started":"2024-10-15T09:41:24.934568Z","shell.execute_reply":"2024-10-15T09:41:24.942212Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for column in fill_mode:\n    mode_value = df[column].mode()[0]  # Mod değerini hesapla\n    df[column] = df[column].fillna(mode_value)  # NaN değerlerini mod ile doldur","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:24.945999Z","iopub.execute_input":"2024-10-15T09:41:24.946568Z","iopub.status.idle":"2024-10-15T09:41:24.997348Z","shell.execute_reply.started":"2024-10-15T09:41:24.946515Z","shell.execute_reply":"2024-10-15T09:41:24.996198Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:24.998725Z","iopub.execute_input":"2024-10-15T09:41:24.999082Z","iopub.status.idle":"2024-10-15T09:41:25.016191Z","shell.execute_reply.started":"2024-10-15T09:41:24.999045Z","shell.execute_reply":"2024-10-15T09:41:25.014876Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head(10)","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.017638Z","iopub.execute_input":"2024-10-15T09:41:25.018098Z","iopub.status.idle":"2024-10-15T09:41:25.148262Z","shell.execute_reply.started":"2024-10-15T09:41:25.018047Z","shell.execute_reply":"2024-10-15T09:41:25.147071Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"for col in df.columns:\n    if df[col].isnull().any():  \n        mean_e = df[col].mean()\n        df[col] = df[col].fillna(mean_e)","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.153340Z","iopub.execute_input":"2024-10-15T09:41:25.154031Z","iopub.status.idle":"2024-10-15T09:41:25.191868Z","shell.execute_reply.started":"2024-10-15T09:41:25.153983Z","shell.execute_reply":"2024-10-15T09:41:25.190770Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head(15)","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.193281Z","iopub.execute_input":"2024-10-15T09:41:25.193719Z","iopub.status.idle":"2024-10-15T09:41:25.308446Z","shell.execute_reply.started":"2024-10-15T09:41:25.193671Z","shell.execute_reply":"2024-10-15T09:41:25.307206Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.isnull().sum()","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.309914Z","iopub.execute_input":"2024-10-15T09:41:25.310371Z","iopub.status.idle":"2024-10-15T09:41:25.331648Z","shell.execute_reply.started":"2024-10-15T09:41:25.310322Z","shell.execute_reply":"2024-10-15T09:41:25.330398Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.333210Z","iopub.execute_input":"2024-10-15T09:41:25.333707Z","iopub.status.idle":"2024-10-15T09:41:25.370318Z","shell.execute_reply.started":"2024-10-15T09:41:25.333654Z","shell.execute_reply":"2024-10-15T09:41:25.369214Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"original_ids=df[\"id\"]","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.371836Z","iopub.execute_input":"2024-10-15T09:41:25.372231Z","iopub.status.idle":"2024-10-15T09:41:25.377155Z","shell.execute_reply.started":"2024-10-15T09:41:25.372191Z","shell.execute_reply":"2024-10-15T09:41:25.375945Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"le=LabelEncoder()\ndf[\"id\"]=le.fit_transform(df[\"id\"])\ndf[\"Basic_Demos-Enroll_Season\"]=le.fit_transform(df[\"Basic_Demos-Enroll_Season\"])\ndf[\"CGAS-Season\"]=le.fit_transform(df[\"CGAS-Season\"])\ndf[\"Physical-Season\"]=le.fit_transform(df[\"Physical-Season\"])\ndf[\"Fitness_Endurance-Season\"]=le.fit_transform(df[\"Fitness_Endurance-Season\"])\ndf[\"FGC-Season\"]=le.fit_transform(df[\"FGC-Season\"])\ndf[\"BIA-Season\"]=le.fit_transform(df[\"BIA-Season\"])\ndf[\"PAQ_A-Season\"]=le.fit_transform(df[\"PAQ_A-Season\"])\ndf[\"PAQ_C-Season\"]=le.fit_transform(df[\"PAQ_C-Season\"])\ndf[\"PCIAT-Season\"]=le.fit_transform(df[\"PCIAT-Season\"])\ndf[\"SDS-Season\"]=le.fit_transform(df[\"SDS-Season\"])\ndf[\"PreInt_EduHx-Season\"]=le.fit_transform(df[\"PreInt_EduHx-Season\"])","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.378489Z","iopub.execute_input":"2024-10-15T09:41:25.378878Z","iopub.status.idle":"2024-10-15T09:41:25.409689Z","shell.execute_reply.started":"2024-10-15T09:41:25.378841Z","shell.execute_reply":"2024-10-15T09:41:25.408447Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.411182Z","iopub.execute_input":"2024-10-15T09:41:25.412305Z","iopub.status.idle":"2024-10-15T09:41:25.438073Z","shell.execute_reply.started":"2024-10-15T09:41:25.412261Z","shell.execute_reply":"2024-10-15T09:41:25.436973Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.info()","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.439404Z","iopub.execute_input":"2024-10-15T09:41:25.440496Z","iopub.status.idle":"2024-10-15T09:41:25.459277Z","shell.execute_reply.started":"2024-10-15T09:41:25.440453Z","shell.execute_reply":"2024-10-15T09:41:25.458205Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"scaler=MinMaxScaler()\nnormalized_data=scaler.fit_transform(df)","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.460846Z","iopub.execute_input":"2024-10-15T09:41:25.461219Z","iopub.status.idle":"2024-10-15T09:41:25.484866Z","shell.execute_reply.started":"2024-10-15T09:41:25.461182Z","shell.execute_reply":"2024-10-15T09:41:25.483396Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"scalerr=StandardScaler()\nstandardized_data=scalerr.fit_transform(df)","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.487281Z","iopub.execute_input":"2024-10-15T09:41:25.487820Z","iopub.status.idle":"2024-10-15T09:41:25.523615Z","shell.execute_reply.started":"2024-10-15T09:41:25.487717Z","shell.execute_reply":"2024-10-15T09:41:25.522400Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"lr=LinearRegression()\ndt=DecisionTreeRegressor()\nrf=RandomForestRegressor()\ny=df[\"sii\"]\nx=df.drop(\"sii\",axis=1)\nx_train,x_test,y_train,y_test=train_test_split(x,y,random_state=6,train_size=0.7)","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.525317Z","iopub.execute_input":"2024-10-15T09:41:25.525763Z","iopub.status.idle":"2024-10-15T09:41:25.555404Z","shell.execute_reply.started":"2024-10-15T09:41:25.525715Z","shell.execute_reply":"2024-10-15T09:41:25.554181Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"mode=lr.fit(x,y)\nmode.score(x,y)","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.557099Z","iopub.execute_input":"2024-10-15T09:41:25.557570Z","iopub.status.idle":"2024-10-15T09:41:25.691920Z","shell.execute_reply.started":"2024-10-15T09:41:25.557518Z","shell.execute_reply":"2024-10-15T09:41:25.690610Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model=lr.fit(x_train,y_train)\nmodel.score(x_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.694213Z","iopub.execute_input":"2024-10-15T09:41:25.695744Z","iopub.status.idle":"2024-10-15T09:41:25.840401Z","shell.execute_reply.started":"2024-10-15T09:41:25.695682Z","shell.execute_reply":"2024-10-15T09:41:25.839252Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"modell=dt.fit(x_train,y_train)\nmodell.score(x_test,y_test)\n","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.842566Z","iopub.execute_input":"2024-10-15T09:41:25.844097Z","iopub.status.idle":"2024-10-15T09:41:25.937453Z","shell.execute_reply.started":"2024-10-15T09:41:25.844045Z","shell.execute_reply":"2024-10-15T09:41:25.936322Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"modelll=rf.fit(x_train,y_train)\nmodelll.score(x_test,y_test)","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:25.939066Z","iopub.execute_input":"2024-10-15T09:41:25.939757Z","iopub.status.idle":"2024-10-15T09:41:27.208733Z","shell.execute_reply.started":"2024-10-15T09:41:25.939694Z","shell.execute_reply":"2024-10-15T09:41:27.207652Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\ncv_scores = cross_val_score(model, x, y, cv=5) ","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:27.209846Z","iopub.execute_input":"2024-10-15T09:41:27.210191Z","iopub.status.idle":"2024-10-15T09:41:27.779478Z","shell.execute_reply.started":"2024-10-15T09:41:27.210155Z","shell.execute_reply":"2024-10-15T09:41:27.778200Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"print(\"Çapraz Doğrulama Skorları:\", cv_scores)\nprint(\"Ortalama Skor:\", cv_scores.mean())","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:27.781277Z","iopub.execute_input":"2024-10-15T09:41:27.783138Z","iopub.status.idle":"2024-10-15T09:41:27.792117Z","shell.execute_reply.started":"2024-10-15T09:41:27.783073Z","shell.execute_reply":"2024-10-15T09:41:27.791032Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\npredictions = df[\"sii\"].round().astype(int)\n\nsubmission_df = pd.DataFrame({\n    'id': original_ids, \n    'sii': predictions\n})\n\n# Dosyanın kaydedilmesi\nsubmission_df.to_csv('submission.csv', index=False)","metadata":{"execution":{"iopub.status.busy":"2024-10-15T09:41:27.794402Z","iopub.execute_input":"2024-10-15T09:41:27.796207Z","iopub.status.idle":"2024-10-15T09:41:27.826038Z","shell.execute_reply.started":"2024-10-15T09:41:27.796155Z","shell.execute_reply":"2024-10-15T09:41:27.824713Z"},"trusted":true},"execution_count":null,"outputs":[]}]}