{"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)\nimport seaborn as sns# dyal les graphes bhalha bhal matplotlib hire hya tat3ti des visual zwinine hssan man lakhra \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-01-09T07:48:24.423094Z","iopub.execute_input":"2023-01-09T07:48:24.423631Z","iopub.status.idle":"2023-01-09T07:48:25.855664Z","shell.execute_reply.started":"2023-01-09T07:48:24.423579Z","shell.execute_reply":"2023-01-09T07:48:25.854408Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"!ls","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:48:45.808637Z","iopub.execute_input":"2023-01-09T07:48:45.809054Z","iopub.status.idle":"2023-01-09T07:48:46.934902Z","shell.execute_reply.started":"2023-01-09T07:48:45.809019Z","shell.execute_reply":"2023-01-09T07:48:46.932999Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"open('/kaggle/input/emsi-5iir-ds/train.csv')","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:48:48.138709Z","iopub.execute_input":"2023-01-09T07:48:48.139160Z","iopub.status.idle":"2023-01-09T07:48:48.151606Z","shell.execute_reply.started":"2023-01-09T07:48:48.139119Z","shell.execute_reply":"2023-01-09T07:48:48.150589Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"open('/kaggle/input/emsi-5iir-ds/train.csv').readlines()[2]","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:48:50.115282Z","iopub.execute_input":"2023-01-09T07:48:50.116296Z","iopub.status.idle":"2023-01-09T07:48:54.947409Z","shell.execute_reply.started":"2023-01-09T07:48:50.116259Z","shell.execute_reply":"2023-01-09T07:48:54.946384Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.read_csv('/kaggle/input/emsi-5iir-ds/train.csv')","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:48:54.949217Z","iopub.execute_input":"2023-01-09T07:48:54.949602Z","iopub.status.idle":"2023-01-09T07:49:00.189635Z","shell.execute_reply.started":"2023-01-09T07:48:54.949568Z","shell.execute_reply":"2023-01-09T07:49:00.188438Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df=pd.read_csv('/kaggle/input/emsi-5iir-ds/train.csv')","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:00.192108Z","iopub.execute_input":"2023-01-09T07:49:00.193261Z","iopub.status.idle":"2023-01-09T07:49:05.000708Z","shell.execute_reply.started":"2023-01-09T07:49:00.193212Z","shell.execute_reply":"2023-01-09T07:49:04.999563Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.head(100)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:05.308154Z","iopub.execute_input":"2023-01-09T07:49:05.308596Z","iopub.status.idle":"2023-01-09T07:49:05.342509Z","shell.execute_reply.started":"2023-01-09T07:49:05.308561Z","shell.execute_reply":"2023-01-09T07:49:05.341367Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.columns","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:07.811977Z","iopub.execute_input":"2023-01-09T07:49:07.812406Z","iopub.status.idle":"2023-01-09T07:49:07.821167Z","shell.execute_reply.started":"2023-01-09T07:49:07.812352Z","shell.execute_reply":"2023-01-09T07:49:07.819878Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.iloc[10] ","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:09.316444Z","iopub.execute_input":"2023-01-09T07:49:09.316826Z","iopub.status.idle":"2023-01-09T07:49:09.326724Z","shell.execute_reply.started":"2023-01-09T07:49:09.316794Z","shell.execute_reply":"2023-01-09T07:49:09.325495Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sns.heatmap(df.corr())#bach tchouf la correlation ","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:11.723680Z","iopub.execute_input":"2023-01-09T07:49:11.724376Z","iopub.status.idle":"2023-01-09T07:49:14.882608Z","shell.execute_reply.started":"2023-01-09T07:49:11.724323Z","shell.execute_reply":"2023-01-09T07:49:14.881319Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"","metadata":{}},{"cell_type":"markdown","source":"donc ma3adena tachi haja correle hna les variables independantes donc ana limafaheme walo this shit That Doesn't Make Sense :)","metadata":{}},{"cell_type":"code","source":"df.corr()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:14.884687Z","iopub.execute_input":"2023-01-09T07:49:14.885084Z","iopub.status.idle":"2023-01-09T07:49:17.587088Z","shell.execute_reply.started":"2023-01-09T07:49:14.885047Z","shell.execute_reply":"2023-01-09T07:49:17.585960Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df.corr()['target'] #what the heck ","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:20.675413Z","iopub.execute_input":"2023-01-09T07:49:20.675852Z","iopub.status.idle":"2023-01-09T07:49:23.361186Z","shell.execute_reply.started":"2023-01-09T07:49:20.675813Z","shell.execute_reply":"2023-01-09T07:49:23.359789Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"daba 9bal khassna nfham kola columns ache tat3ni et 9bal ache nahya la competition savoir wache la macine f etat 1 ola 0  donc :","metadata":{}},{"cell_type":"markdown","source":"fichier train howa li an3tiwe la machine t3alaem mano  o test.csv howa li at3ti la machine tchouf wache lmodel khedam o lala donc tal hna mafahmine ","metadata":{}},{"cell_type":"code","source":"pd.read_csv('/kaggle/input/emsi-5iir-ds/test.csv')","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:25.315402Z","iopub.execute_input":"2023-01-09T07:49:25.315821Z","iopub.status.idle":"2023-01-09T07:49:33.055489Z","shell.execute_reply.started":"2023-01-09T07:49:25.315788Z","shell.execute_reply":"2023-01-09T07:49:33.054134Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target_correlation =df.corr()['target']\ntarget_correlation[target_correlation>0.4]","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:35.436234Z","iopub.execute_input":"2023-01-09T07:49:35.437305Z","iopub.status.idle":"2023-01-09T07:49:38.206154Z","shell.execute_reply.started":"2023-01-09T07:49:35.437258Z","shell.execute_reply":"2023-01-09T07:49:38.204200Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"7na hna galna 3tina target correlation li kbare man 0.4 ","metadata":{}},{"cell_type":"markdown","source":"donc makayna ta waheda n3awedo n3tiwe  chi valeur waheda khera sghare  ","metadata":{}},{"cell_type":"code","source":"target_correlation[target_correlation>0.1] .index","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:40.082754Z","iopub.execute_input":"2023-01-09T07:49:40.083392Z","iopub.status.idle":"2023-01-09T07:49:40.090808Z","shell.execute_reply.started":"2023-01-09T07:49:40.083340Z","shell.execute_reply":"2023-01-09T07:49:40.089714Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"donc la valeur dyal correlation lmajehda 3adena m3a target hya dyal f_21","metadata":{}},{"cell_type":"markdown","source":"3adena faible correlation bhal ma3adenach correalation ga3 bmera ","metadata":{}},{"cell_type":"markdown","source":"donc hadi gadi nssamiwhome top_correalation_features","metadata":{}},{"cell_type":"code","source":"sns.heatmap(df.corr().loc[target_correlation[target_correlation>0.1].index])","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:42.723859Z","iopub.execute_input":"2023-01-09T07:49:42.724347Z","iopub.status.idle":"2023-01-09T07:49:45.762897Z","shell.execute_reply.started":"2023-01-09T07:49:42.724297Z","shell.execute_reply":"2023-01-09T07:49:45.761556Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"corr_mat = df.corr()\ntarget_correalation=corr_mat ['target']\ntop_correlation_features= target_correlation[target_correlation.abs()>0.1].index\n#gadine diro be3da la matrice de correlation l3adya gadine nssamiwha correlation_mat\n\nsns.heatmap(corr_mat)\n","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:47.875794Z","iopub.execute_input":"2023-01-09T07:49:47.876213Z","iopub.status.idle":"2023-01-09T07:49:50.986545Z","shell.execute_reply.started":"2023-01-09T07:49:47.876178Z","shell.execute_reply":"2023-01-09T07:49:50.985416Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"gadine localisiwe hire dike li3andha correlation kbira m3a target wali galna hya f_21 ","metadata":{}},{"cell_type":"code","source":"corr_mat = df.corr()\ntarget_correalation=corr_mat ['target']\ntop_correlation_features= target_correlation[target_correlation.abs()>0.1].index\nsns.heatmap(corr_mat.loc[top_correlation_features, top_correlation_features])","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:53.701444Z","iopub.execute_input":"2023-01-09T07:49:53.702276Z","iopub.status.idle":"2023-01-09T07:49:56.690877Z","shell.execute_reply.started":"2023-01-09T07:49:53.702221Z","shell.execute_reply":"2023-01-09T07:49:56.689932Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"o kima galna akhbare valeur de correlation hya dyal f_21 li hya 0.130887","metadata":{}},{"cell_type":"code","source":"target_correlation[target_correlation.abs()>0.0]","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:49:59.809900Z","iopub.execute_input":"2023-01-09T07:49:59.810327Z","iopub.status.idle":"2023-01-09T07:49:59.821252Z","shell.execute_reply.started":"2023-01-09T07:49:59.810292Z","shell.execute_reply":"2023-01-09T07:49:59.819816Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"il exist des correalations negatifs  walakine faible mote faible ","metadata":{}},{"cell_type":"markdown","source":"hda hda f_27 makaynach correlation dyalhaaaa 3lach ya tora\nwa9ila lblan dayre 3liaha ","metadata":{}},{"cell_type":"code","source":"df.f_27.value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:02.563694Z","iopub.execute_input":"2023-01-09T07:50:02.564967Z","iopub.status.idle":"2023-01-09T07:50:03.566075Z","shell.execute_reply.started":"2023-01-09T07:50:02.564912Z","shell.execute_reply":"2023-01-09T07:50:03.564992Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"donc hna khassena nhawlo hade les valeurs ldes valeurs numeriques abche n9arnohome donc on va ","metadata":{}},{"cell_type":"code","source":"df.f_27","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:05.347978Z","iopub.execute_input":"2023-01-09T07:50:05.348396Z","iopub.status.idle":"2023-01-09T07:50:05.357914Z","shell.execute_reply.started":"2023-01-09T07:50:05.348349Z","shell.execute_reply":"2023-01-09T07:50:05.356519Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"raw","source":"svp lach kayn  hna 899999 enregistrement o hna f data frame kolha matal3A lina 700000 mafhamtch \nc est bon fhamte df.f_27 tatraja3 la colonne coleha  mrateba \n0    1\n1    2\n2    3\n3    3\n4    4\n5    5\nName: f_27, dtype: int64\nbhale haka \nwalakine lekhra \ndf.f_27.value_counts() tatrade le nombre d occurrences de chaque valeur unique fla colonne\n\nexample:\ndf = pd.DataFrame({'f_27': [1, 2, 3, 3, 4, 5], 'f_28': [6, 7, 8, 9, 10, 11]})\n\nla lancina df.f_27.value_counts()\nresult hya \n3    2\n5    1\n4    1\n2    1\n1    1 \n nombre de fois libane fihe kola element  ","metadata":{}},{"cell_type":"code","source":"df.f_27.value_counts()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:10.291877Z","iopub.execute_input":"2023-01-09T07:50:10.292276Z","iopub.status.idle":"2023-01-09T07:50:11.207258Z","shell.execute_reply.started":"2023-01-09T07:50:10.292243Z","shell.execute_reply":"2023-01-09T07:50:11.205987Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"la transformation dyal hade les donnees l des donnees numerique kayna wahed la methode smitha one-hot encoding \n donc comment sa marche :","metadata":{}},{"cell_type":"code","source":"df.select_dtypes(include=['object'])","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:13.347719Z","iopub.execute_input":"2023-01-09T07:50:13.348132Z","iopub.status.idle":"2023-01-09T07:50:13.376000Z","shell.execute_reply.started":"2023-01-09T07:50:13.348099Z","shell.execute_reply":"2023-01-09T07:50:13.374724Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"hna affichina les objets les le type dyalhome char donc apres gadi ndiro la fonction get_dummies() ligadi thowalhome ldes valeurs 1 et 0","metadata":{}},{"cell_type":"code","source":"df.select_dtypes(include=['object'])","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:15.599119Z","iopub.execute_input":"2023-01-09T07:50:15.600149Z","iopub.status.idle":"2023-01-09T07:50:15.626911Z","shell.execute_reply.started":"2023-01-09T07:50:15.600110Z","shell.execute_reply":"2023-01-09T07:50:15.625937Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"gadine ndiro echantionnage ","metadata":{}},{"cell_type":"code","source":"df.select_dtypes(include=['object']).head(1000)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:18.062989Z","iopub.execute_input":"2023-01-09T07:50:18.063850Z","iopub.status.idle":"2023-01-09T07:50:18.091283Z","shell.execute_reply.started":"2023-01-09T07:50:18.063810Z","shell.execute_reply":"2023-01-09T07:50:18.089976Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"pd.get_dummies(df.select_dtypes(include=['object']).head(100))","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:20.578937Z","iopub.execute_input":"2023-01-09T07:50:20.579787Z","iopub.status.idle":"2023-01-09T07:50:20.631637Z","shell.execute_reply.started":"2023-01-09T07:50:20.579727Z","shell.execute_reply":"2023-01-09T07:50:20.628641Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"donc c est bon howalnahome ","metadata":{}},{"cell_type":"code","source":"cat_variables = pd.get_dummies(df.select_dtypes(include=['object']).head())\ncat_variables.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:22.937746Z","iopub.execute_input":"2023-01-09T07:50:22.938152Z","iopub.status.idle":"2023-01-09T07:50:22.975503Z","shell.execute_reply.started":"2023-01-09T07:50:22.938120Z","shell.execute_reply":"2023-01-09T07:50:22.974296Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"df[[c for c in df not in cat_variables ]] hadi tat3tina Ga3 les colonnes lif dataframe dyalena numerique limakayninche fhadik cat_variable","metadata":{}},{"cell_type":"code","source":"cat_variables=(df.select_dtypes(include=['object']).head()).columns\ncat_df=pd.get_dummies(df[cat_variables].head(10))\ncat_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:25.235468Z","iopub.execute_input":"2023-01-09T07:50:25.235891Z","iopub.status.idle":"2023-01-09T07:50:25.294938Z","shell.execute_reply.started":"2023-01-09T07:50:25.235857Z","shell.execute_reply":"2023-01-09T07:50:25.293754Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"hadi g3ate fiha 2 jours walhamdo lilah matssowalnich 3liha kifach derte liha la zehiro o sidi rebi o redate lwalida homa likhadmoha  ","metadata":{}},{"cell_type":"markdown","source":"daba hna gadine nakhdo ga3 les valeurs numeriuques li3adena oli hna","metadata":{}},{"cell_type":"code","source":"df[[c for c in df.columns if c not in cat_variables]]","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:27.046814Z","iopub.execute_input":"2023-01-09T07:50:27.047230Z","iopub.status.idle":"2023-01-09T07:50:27.389507Z","shell.execute_reply.started":"2023-01-09T07:50:27.047193Z","shell.execute_reply":"2023-01-09T07:50:27.388220Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"la colonne f27 makaynache donc correct \nhade result gadi nhateha f wahed la variable nssimwha bhal la video num_df ","metadata":{}},{"cell_type":"code","source":"num_df= df[[c for c in df.columns if c not in cat_variables]]\nnum_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:30.521231Z","iopub.execute_input":"2023-01-09T07:50:30.522001Z","iopub.status.idle":"2023-01-09T07:50:30.628435Z","shell.execute_reply.started":"2023-01-09T07:50:30.521963Z","shell.execute_reply":"2023-01-09T07:50:30.627580Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"donc hna apres mni howalena la colonnes f_27 ldes nombres  a laide de la methode one hot_coding fin sta3malna la fonction get_dummies \ndonc hna gadine nchoufou wache kayna chi correlation entre hade la colonnes et notre target\n\n gadi nsta3mlo wahed la fonction mais 9bal khassena n3ayto 3la bibliotheque scipy o gadine n3ayto 3la la fonction dyalena stats.chisquare mais mabghatch tekhdam  donc gadine nkhademo l3adya  lihya correlation numerique ","metadata":{}},{"cell_type":"code","source":"pd.concat([cat_df,df[['target']]]).corr()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:32.909849Z","iopub.execute_input":"2023-01-09T07:50:32.910639Z","iopub.status.idle":"2023-01-09T07:50:33.210612Z","shell.execute_reply.started":"2023-01-09T07:50:32.910593Z","shell.execute_reply":"2023-01-09T07:50:33.208446Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"masde9ch hade lblan \ngadi nconcatener deux dataframe ","metadata":{}},{"cell_type":"code","source":"joined_df = pd.concat([cat_df, num_df])\njoined_df.head()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:35.514634Z","iopub.execute_input":"2023-01-09T07:50:35.515080Z","iopub.status.idle":"2023-01-09T07:50:35.772764Z","shell.execute_reply.started":"2023-01-09T07:50:35.515041Z","shell.execute_reply":"2023-01-09T07:50:35.771796Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"joined_df = pd.concat([cat_df, num_df] , axis=1)\njoined_df.head().T","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:38.461081Z","iopub.execute_input":"2023-01-09T07:50:38.461507Z","iopub.status.idle":"2023-01-09T07:50:38.670869Z","shell.execute_reply.started":"2023-01-09T07:50:38.461472Z","shell.execute_reply":"2023-01-09T07:50:38.669446Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"daba bache nbdawe ngado lmodel dyalena khassna nchoufou lmodel dyalena wache fih des cellules manquante \ngadi nkhademou b df.isna()\ndonc ","metadata":{}},{"cell_type":"code","source":"df.isna()","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:41.861322Z","iopub.execute_input":"2023-01-09T07:50:41.861768Z","iopub.status.idle":"2023-01-09T07:50:42.019919Z","shell.execute_reply.started":"2023-01-09T07:50:41.861731Z","shell.execute_reply":"2023-01-09T07:50:42.018581Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"les valeurs kolehom kaynine hite kolechi fihome false donc gadine njarbou hade L3iba bbnissba lhadouk li mabayninche gadine n3tiwhome wahed la valeur 1","metadata":{}},{"cell_type":"code","source":"df.isna().sum(axis=0).sort_values(ascending=False)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:44.161044Z","iopub.execute_input":"2023-01-09T07:50:44.161479Z","iopub.status.idle":"2023-01-09T07:50:44.263478Z","shell.execute_reply.started":"2023-01-09T07:50:44.161443Z","shell.execute_reply":"2023-01-09T07:50:44.262143Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"donc ma3adenach ta chi waheda lifiha des champs khawyine","metadata":{}},{"cell_type":"markdown","source":"f le cas koune kanou 3adena des champs vides tan diro wahed la3eba lihya tandiro la mediane  ta3 koola colonne o dik la mediane tan atribiwha ldouk les champs mais hade la3ba ki gale MR.ahmed mamzianache walakine hssan matkhali lkhwa ","metadata":{}},{"cell_type":"code","source":"values = joined_df.f_21\nvalues.plot.hist(bins=10)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:46.685310Z","iopub.execute_input":"2023-01-09T07:50:46.685750Z","iopub.status.idle":"2023-01-09T07:50:47.083567Z","shell.execute_reply.started":"2023-01-09T07:50:46.685714Z","shell.execute_reply":"2023-01-09T07:50:47.082268Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## Modeling.","metadata":{}},{"cell_type":"code","source":"joined_df.sample(3)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:49.270698Z","iopub.execute_input":"2023-01-09T07:50:49.271110Z","iopub.status.idle":"2023-01-09T07:50:49.599657Z","shell.execute_reply.started":"2023-01-09T07:50:49.271079Z","shell.execute_reply":"2023-01-09T07:50:49.598773Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"joined_df hya dataframe liconcatena  fiha hadchi kamel dyalena ","metadata":{}},{"cell_type":"code","source":"features_df = joined_df[['f_21','target']]\ntarget = joined_df.target\nfeatures_df.sample(3)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:51.679378Z","iopub.execute_input":"2023-01-09T07:50:51.680213Z","iopub.status.idle":"2023-01-09T07:50:51.726464Z","shell.execute_reply.started":"2023-01-09T07:50:51.680177Z","shell.execute_reply":"2023-01-09T07:50:51.725232Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"target_correlation[target_correlation.abs()>0.0]\n","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:53.897677Z","iopub.execute_input":"2023-01-09T07:50:53.898060Z","iopub.status.idle":"2023-01-09T07:50:53.907694Z","shell.execute_reply.started":"2023-01-09T07:50:53.898028Z","shell.execute_reply":"2023-01-09T07:50:53.906430Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"gadi nakhdo deux vriables li3andhome une grande correaltion m3A target donc gadi nakhdo f_21 li3andha une valeur de 0.130887 et f_24      0.086350 ","metadata":{}},{"cell_type":"code","source":"from sklearn. preprocessing import normalize\nfeatures_df = joined_df[['f_21','f_24']]\ntarget = joined_df.target\nfeatures_df.sample(3)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:50:56.014961Z","iopub.execute_input":"2023-01-09T07:50:56.015371Z","iopub.status.idle":"2023-01-09T07:50:56.130009Z","shell.execute_reply.started":"2023-01-09T07:50:56.015322Z","shell.execute_reply":"2023-01-09T07:50:56.129088Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import LinearRegression\n\nmodel = LinearRegression()\nmodel.fit(features_df, target)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:51:00.544787Z","iopub.execute_input":"2023-01-09T07:51:00.546211Z","iopub.status.idle":"2023-01-09T07:51:00.771462Z","shell.execute_reply.started":"2023-01-09T07:51:00.546155Z","shell.execute_reply":"2023-01-09T07:51:00.769768Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":" predictions = model.predict(features_df)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:51:07.758423Z","iopub.execute_input":"2023-01-09T07:51:07.759779Z","iopub.status.idle":"2023-01-09T07:51:07.772448Z","shell.execute_reply.started":"2023-01-09T07:51:07.759729Z","shell.execute_reply":"2023-01-09T07:51:07.770086Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"apres gadine nchoufou lmodel ta3na chhal mzyan ","metadata":{}},{"cell_type":"code","source":"from sklearn.metrics import mean_squared_error \nmean_squared_error(predictions, target)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:51:15.617258Z","iopub.execute_input":"2023-01-09T07:51:15.617733Z","iopub.status.idle":"2023-01-09T07:51:15.631321Z","shell.execute_reply.started":"2023-01-09T07:51:15.617675Z","shell.execute_reply":"2023-01-09T07:51:15.629933Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"normalement khassena n9arno rassena bchi haja donc gadin n9arno rassena bwahed lpredicteure mkalakh ","metadata":{}},{"cell_type":"code","source":"from sklearn.dummy import DummyRegressor\nbaseline = DummyRegressor(strategy='mean')\nbaseline.fit(features_df,target)\nmean_squared_error(baseline.predict(features_df),target)\n\n","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:51:18.726468Z","iopub.execute_input":"2023-01-09T07:51:18.726902Z","iopub.status.idle":"2023-01-09T07:51:18.747281Z","shell.execute_reply.started":"2023-01-09T07:51:18.726863Z","shell.execute_reply":"2023-01-09T07:51:18.745825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"     lol\n0.2498174198506172>0.24396014653277298\n donc hmd  be3da machi khlakh man dummy predictor \n","metadata":{}},{"cell_type":"markdown","source":"hadchi galate lidarena hite sta3emalna les donnees dyawlena f training o f test donc gadin ndiro wahed lblan akhore  hite hna khedemna hire b deux  fonctionnalites \ngadi ndiro lblan lakhore lihowa n9assemo dataset dyalena \ntjrs man sklearn gadi njibo dik la fonction \n\n","metadata":{}},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n#hade la fonction tattakhede features dyalena o tat9assemhome ldeux parties \n#les entrees dyal lmodele  gadine nssamiwhome X o les sorties dyalmodel gadine nssamiwhome Y\nx_train, x_test, y_train, y_test= train_test_split(features_df,target, test_size=0.25, random_state=0)\n","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:51:35.604577Z","iopub.execute_input":"2023-01-09T07:51:35.605293Z","iopub.status.idle":"2023-01-09T07:51:35.738643Z","shell.execute_reply.started":"2023-01-09T07:51:35.605246Z","shell.execute_reply":"2023-01-09T07:51:35.737429Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_train","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:51:39.116038Z","iopub.execute_input":"2023-01-09T07:51:39.116784Z","iopub.status.idle":"2023-01-09T07:51:39.130030Z","shell.execute_reply.started":"2023-01-09T07:51:39.116745Z","shell.execute_reply":"2023-01-09T07:51:39.128857Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"x_test","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:51:41.979215Z","iopub.execute_input":"2023-01-09T07:51:41.979628Z","iopub.status.idle":"2023-01-09T07:51:41.992958Z","shell.execute_reply.started":"2023-01-09T07:51:41.979594Z","shell.execute_reply":"2023-01-09T07:51:41.991719Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"daba hna 9ssamena training o testing l deux dataset donc test c est que 25% man datafram dyalena \n o hadchi aleatoire macchi 25 lowline o la lakhrine mkhalate dakchi mohime 25%  man dataframe daba gadine n3awedo nafsse laja lidarena 9bal  walakine hade lmeragadine ntiniwe b X_TRAIN O Y_TRAIN","metadata":{}},{"cell_type":"code","source":"from sklearn.linear_model import LinearRegression\n\nmodel = LinearRegression()\nmodel.fit(x_train , y_train)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:51:44.482715Z","iopub.execute_input":"2023-01-09T07:51:44.483408Z","iopub.status.idle":"2023-01-09T07:51:44.526688Z","shell.execute_reply.started":"2023-01-09T07:51:44.483338Z","shell.execute_reply":"2023-01-09T07:51:44.525553Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = model.predict(x_test)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:51:52.181196Z","iopub.execute_input":"2023-01-09T07:51:52.181609Z","iopub.status.idle":"2023-01-09T07:51:52.191286Z","shell.execute_reply.started":"2023-01-09T07:51:52.181574Z","shell.execute_reply":"2023-01-09T07:51:52.189709Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"input homa les x_test o  gadi nhatohome f y_prediction apres gadine ncompariwe y_test m3a y_prediction dyalena ","metadata":{}},{"cell_type":"code","source":"from sklearn.metrics import mean_squared_error \nnp.sqrt(mean_squared_error(y_test, y_pred))","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:51:55.699717Z","iopub.execute_input":"2023-01-09T07:51:55.700148Z","iopub.status.idle":"2023-01-09T07:51:55.709256Z","shell.execute_reply.started":"2023-01-09T07:51:55.700111Z","shell.execute_reply":"2023-01-09T07:51:55.707783Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"o n3awedo n9arenohome m3a dummy predector ","metadata":{}},{"cell_type":"code","source":"from sklearn.dummy import DummyRegressor\nbaseline = DummyRegressor(strategy='mean')\nbaseline.fit(x_train,y_train)\nnp.sqrt(mean_squared_error(baseline.predict(x_test),y_test))","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:51:57.930938Z","iopub.execute_input":"2023-01-09T07:51:57.931407Z","iopub.status.idle":"2023-01-09T07:51:57.944320Z","shell.execute_reply.started":"2023-01-09T07:51:57.931349Z","shell.execute_reply":"2023-01-09T07:51:57.943120Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import matplotlib.pyplot as plt\nplt.scatter(y_test, y_pred)\nplt.xlabel(\"target\")\nplt.ylabel(\"predict target\")\nplt.plot([10.,14.],[10.,14.],'--')","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:52:00.663760Z","iopub.execute_input":"2023-01-09T07:52:00.664156Z","iopub.status.idle":"2023-01-09T07:52:01.687919Z","shell.execute_reply.started":"2023-01-09T07:52:00.664122Z","shell.execute_reply":"2023-01-09T07:52:01.686918Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.coef_","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:52:05.420813Z","iopub.execute_input":"2023-01-09T07:52:05.421200Z","iopub.status.idle":"2023-01-09T07:52:05.428849Z","shell.execute_reply.started":"2023-01-09T07:52:05.421168Z","shell.execute_reply":"2023-01-09T07:52:05.427702Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.intercept_","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:52:07.782350Z","iopub.execute_input":"2023-01-09T07:52:07.782793Z","iopub.status.idle":"2023-01-09T07:52:07.790513Z","shell.execute_reply.started":"2023-01-09T07:52:07.782755Z","shell.execute_reply":"2023-01-09T07:52:07.789165Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"daba hna gadine nkhademo bga3 les features dyalna ","metadata":{}},{"cell_type":"code","source":"# from sklearn.preprocessing import normalize\n# features_df = joined_df.copy().fillna(0.0)\n# target = features_df.pop('target')\n# del features_df['target']\n# features_df.sample(3)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T22:06:53.956406Z","iopub.execute_input":"2023-01-08T22:06:53.956806Z","iopub.status.idle":"2023-01-08T22:06:53.963058Z","shell.execute_reply.started":"2023-01-08T22:06:53.956760Z","shell.execute_reply":"2023-01-08T22:06:53.961986Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.preprocessing import normalize\n\n# Make a copy of the joined_df DataFrame\nfeatures_df = joined_df.copy().fillna(0.0)\n\n# Remove the 'target' column from features_df and store it in a separate Series\ntarget = features_df.pop('target')\n\n# Normalize the features_df data\nfeatures_df = normalize(features_df)\n\n# View a random sample of 3 rows from features_df\n#features_df.sample(3)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:52:17.446136Z","iopub.execute_input":"2023-01-09T07:52:17.446581Z","iopub.status.idle":"2023-01-09T07:52:18.243085Z","shell.execute_reply.started":"2023-01-09T07:52:17.446546Z","shell.execute_reply":"2023-01-09T07:52:18.241954Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train=pd.read_csv('/kaggle/input/emsi-5iir-ds/train.csv')\ntrain.head()\ny=train['target']\nX = train.drop([\"id\",'f_27'],axis=1)\ny.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-09T08:21:08.981547Z","iopub.execute_input":"2023-01-09T08:21:08.981935Z","iopub.status.idle":"2023-01-09T08:21:14.392747Z","shell.execute_reply.started":"2023-01-09T08:21:08.981901Z","shell.execute_reply":"2023-01-09T08:21:14.391520Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"X.shape","metadata":{"execution":{"iopub.status.busy":"2023-01-09T08:20:09.935869Z","iopub.execute_input":"2023-01-09T08:20:09.936437Z","iopub.status.idle":"2023-01-09T08:20:09.944850Z","shell.execute_reply.started":"2023-01-09T08:20:09.936384Z","shell.execute_reply":"2023-01-09T08:20:09.943647Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.model_selection import train_test_split\n#hade la fonction tattakhede features dyalena o tat9assemhome ldeux parties \n#les entrees dyal lmodele  gadine nssamiwhome X o les sorties dyalmodel gadine nssamiwhome Y\nX_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.4, test_size=0.1)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T08:21:39.016913Z","iopub.execute_input":"2023-01-09T08:21:39.017329Z","iopub.status.idle":"2023-01-09T08:21:39.256939Z","shell.execute_reply.started":"2023-01-09T08:21:39.017297Z","shell.execute_reply":"2023-01-09T08:21:39.255652Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.dummy import DummyRegressor\nbaseline = DummyRegressor(strategy='mean')\nbaseline.fit(X_train,y_train)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T08:22:33.541107Z","iopub.execute_input":"2023-01-09T08:22:33.541552Z","iopub.status.idle":"2023-01-09T08:22:33.551672Z","shell.execute_reply.started":"2023-01-09T08:22:33.541513Z","shell.execute_reply":"2023-01-09T08:22:33.550444Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"np.sqrt(mean_squared_error(baseline.predict(X_test),y_test)) ","metadata":{"execution":{"iopub.status.busy":"2023-01-09T08:23:08.786478Z","iopub.execute_input":"2023-01-09T08:23:08.786854Z","iopub.status.idle":"2023-01-09T08:23:08.796101Z","shell.execute_reply.started":"2023-01-09T08:23:08.786823Z","shell.execute_reply":"2023-01-09T08:23:08.794891Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.linear_model import LinearRegression ,LassoCV, RidgeCV \n\nmodel = LinearRegression()\nmodel.fit(x_train , y_train)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T08:08:11.963330Z","iopub.execute_input":"2023-01-09T08:08:11.964059Z","iopub.status.idle":"2023-01-09T08:08:13.263694Z","shell.execute_reply.started":"2023-01-09T08:08:11.964004Z","shell.execute_reply":"2023-01-09T08:08:13.262349Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"y_pred = model.predict(x_test)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T08:08:21.191476Z","iopub.execute_input":"2023-01-09T08:08:21.191863Z","iopub.status.idle":"2023-01-09T08:08:21.215777Z","shell.execute_reply.started":"2023-01-09T08:08:21.191831Z","shell.execute_reply":"2023-01-09T08:08:21.213941Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"from sklearn.metrics import mean_squared_error \nnp.sqrt(mean_squared_error(y_test, y_pred))","metadata":{"execution":{"iopub.status.busy":"2023-01-09T08:08:25.390972Z","iopub.execute_input":"2023-01-09T08:08:25.391469Z","iopub.status.idle":"2023-01-09T08:08:25.400871Z","shell.execute_reply.started":"2023-01-09T08:08:25.391425Z","shell.execute_reply":"2023-01-09T08:08:25.399649Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"model.coef_","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:52:45.386795Z","iopub.execute_input":"2023-01-09T07:52:45.387275Z","iopub.status.idle":"2023-01-09T07:52:45.394918Z","shell.execute_reply.started":"2023-01-09T07:52:45.387237Z","shell.execute_reply":"2023-01-09T07:52:45.393639Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"hadechi li gadire ndiro hna man ba3ede gadine njibdo les columns li3andhom wahed wahed l impact","metadata":{}},{"cell_type":"code","source":"# features_df.any[np.abs(model.coef_)>0.0001]","metadata":{"execution":{"iopub.status.busy":"2023-01-08T22:06:58.714210Z","iopub.execute_input":"2023-01-08T22:06:58.715775Z","iopub.status.idle":"2023-01-08T22:06:58.724580Z","shell.execute_reply.started":"2023-01-08T22:06:58.715704Z","shell.execute_reply":"2023-01-08T22:06:58.722807Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# indices = np.where(np.abs(model.coef_) > 0.0001)[0]\n# selected_columns = features_df.columns.iloc[indices]","metadata":{"execution":{"iopub.status.busy":"2023-01-08T22:06:58.726631Z","iopub.execute_input":"2023-01-08T22:06:58.727568Z","iopub.status.idle":"2023-01-08T22:06:58.736549Z","shell.execute_reply.started":"2023-01-08T22:06:58.727497Z","shell.execute_reply":"2023-01-08T22:06:58.734423Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# # Convertir model.coef_ en un DataFrame avec une colonne nommée 'coef'\n# coef_df = pd.DataFrame({'coef': model.coef_})\n\n# # Sélectionner les colonnes du DataFrame features_df qui ont une valeur absolue de coefficient supérieure à 0,0001 dans coef_df\n# indices = np.where(np.abs(coef_df['coef']) > 0.0001)[0]\n# selected_columns = features_df.columns.iloc[indices]","metadata":{"execution":{"iopub.status.busy":"2023-01-08T22:06:58.738825Z","iopub.execute_input":"2023-01-08T22:06:58.739923Z","iopub.status.idle":"2023-01-08T22:06:58.750291Z","shell.execute_reply.started":"2023-01-08T22:06:58.739843Z","shell.execute_reply":"2023-01-08T22:06:58.748728Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"hna ma3raftche l ereur a monsieur donc an douze lhaja khera ","metadata":{}},{"cell_type":"code","source":"model.intercept_","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:52:56.315689Z","iopub.execute_input":"2023-01-09T07:52:56.316475Z","iopub.status.idle":"2023-01-09T07:52:56.322648Z","shell.execute_reply.started":"2023-01-09T07:52:56.316434Z","shell.execute_reply":"2023-01-09T07:52:56.321514Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"def preprocess(raw_df):\n    df=raw_df.copy()\n    if'targetlog' in df.columns:\n        df['targetlog']=np.log(df.target)\n    cat_variables= df.select_dtypes(include=['object']).columns\n    cat_df =pd.get_dummies(df[cat_variables])\n    num_df= df[[c for c in df.columns if c not in cat_variables]].fillna(0.0)\n    return pd.concat([cat_df, num_df], axis=1)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T07:52:59.413100Z","iopub.execute_input":"2023-01-09T07:52:59.414265Z","iopub.status.idle":"2023-01-09T07:52:59.420929Z","shell.execute_reply.started":"2023-01-09T07:52:59.414181Z","shell.execute_reply":"2023-01-09T07:52:59.420006Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"Crée une copie du DataFrame d'origine nommée df.\nAjoute une nouvelle colonne au DataFrame df appelée 'targetlog' qui contient la valeur logarithmique de la colonne 'target'.\nSélectionne les colonnes du type 'object' (c'est-à-dire les colonnes catégorielles) dans df et les stocke dans une variable cat_variables.\nCrée un DataFrame appelé cat_df en utilisant la fonction pd.get_dummies() pour encoder les colonnes catégorielles en variables binaires (un appelé \"dummy variables\").\nCrée un DataFrame appelé num_df qui contient toutes les colonnes du DataFrame df qui ne sont pas des colonnes catégorielles. Toutes les valeurs manquantes sont remplacées par 0.0.\nConcatène le DataFrame cat_df et le DataFrame num_df en utilisant la fonction pd.concat() et retourne le résultat.","metadata":{}},{"cell_type":"markdown","source":"## Submission.","metadata":{}},{"cell_type":"code","source":"features_df = train_df.copy()\ntarget =features_df.pop('targetLog')\ndel features_df['taget']\n\nmodel = RidgeCV()\nmodel.fit(x_train , y_train)","metadata":{"execution":{"iopub.status.busy":"2023-01-09T08:08:33.151332Z","iopub.execute_input":"2023-01-09T08:08:33.151755Z","iopub.status.idle":"2023-01-09T08:08:33.170605Z","shell.execute_reply.started":"2023-01-09T08:08:33.151719Z","shell.execute_reply":"2023-01-09T08:08:33.169310Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"test_df=pd.read_csv('/kaggle/input/emsi-5iir-ds/test.csv')\nsubmission = test_df[['id']]\nx_test = test_df.drop([\"id\",'f_27'],axis=1)\nsubmission['target'] =  baseline.predict(x_test);\nsubmission['target']","metadata":{"execution":{"iopub.status.busy":"2023-01-09T08:24:01.096686Z","iopub.execute_input":"2023-01-09T08:24:01.097094Z","iopub.status.idle":"2023-01-09T08:24:05.809593Z","shell.execute_reply.started":"2023-01-09T08:24:01.097063Z","shell.execute_reply":"2023-01-09T08:24:05.808332Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submission.csv', index=False)\nsubmission\nfrom IPython.display import HTML\nimport pandas as pd\nimport numpy as np\n\ndef create_download_link(title = \"Download CSV file\", filename = \"data.csv\"):  \n    html = '<a href={filename}>{title}</a>'\n    html = html.format(title=title,filename=filename)\n    return HTML(html)\ncreate_download_link(filename='submission.csv')","metadata":{"execution":{"iopub.status.busy":"2023-01-09T08:24:20.090708Z","iopub.execute_input":"2023-01-09T08:24:20.091246Z","iopub.status.idle":"2023-01-09T08:24:21.688617Z","shell.execute_reply.started":"2023-01-09T08:24:20.091195Z","shell.execute_reply":"2023-01-09T08:24:21.687410Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"predicted_target = np.exp(model.predict(test_df))","metadata":{"execution":{"iopub.status.busy":"2023-01-08T22:59:37.800963Z","iopub.execute_input":"2023-01-08T22:59:37.801484Z","iopub.status.idle":"2023-01-08T22:59:37.824578Z","shell.execute_reply.started":"2023-01-08T22:59:37.801444Z","shell.execute_reply":"2023-01-08T22:59:37.822586Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"sub_df= pd.DataFrame(dict(Id=test_df.Id , target=predicted_target))","metadata":{"execution":{"iopub.status.busy":"2023-01-08T22:59:35.993701Z","iopub.execute_input":"2023-01-08T22:59:35.995077Z","iopub.status.idle":"2023-01-08T22:59:36.016816Z","shell.execute_reply.started":"2023-01-08T22:59:35.995028Z","shell.execute_reply":"2023-01-08T22:59:36.014981Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"submission.to_csv('submissionF.csv', index = False)","metadata":{"execution":{"iopub.status.busy":"2023-01-08T22:59:33.236071Z","iopub.execute_input":"2023-01-08T22:59:33.236606Z","iopub.status.idle":"2023-01-08T22:59:33.263049Z","shell.execute_reply.started":"2023-01-08T22:59:33.236561Z","shell.execute_reply":"2023-01-08T22:59:33.260965Z"},"trusted":true},"execution_count":null,"outputs":[]}]}