{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"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 in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nfrom statistics import mode \n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"train_df = pd.read_csv(\"../input/train.csv\")\ntest_df = pd.read_csv(\"../input/test.csv\")\nmerchants_df = pd.read_csv(\"../input/merchants.csv\")\nnew_merchant_transactions_df = pd.read_csv(\"../input/new_merchant_transactions.csv\", )\nhistorical_transactions_df = pd.read_csv(\"../input/historical_transactions.csv\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a1c895390c4ffabb980716bf3f67eff8bd7605a7"},"cell_type":"code","source":"def reduce_mem_usage(df):\n    \"\"\" iterate through all the columns of a dataframe and modify the data type\n        to reduce memory usage.        \n    \"\"\"\n    start_mem = df.memory_usage().sum() / 1024**2\n    print('Memory usage of dataframe is {:.2f} MB'.format(start_mem))\n    \n    for col in df.columns:\n        col_type = df[col].dtype\n        \n        if col_type != object:\n            c_min = df[col].min()\n            c_max = df[col].max()\n            if str(col_type)[:3] == 'int':\n                if c_min > np.iinfo(np.int8).min and c_max < np.iinfo(np.int8).max:\n                    df[col] = df[col].astype(np.int8)\n                elif c_min > np.iinfo(np.int16).min and c_max < np.iinfo(np.int16).max:\n                    df[col] = df[col].astype(np.int16)\n                elif c_min > np.iinfo(np.int32).min and c_max < np.iinfo(np.int32).max:\n                    df[col] = df[col].astype(np.int32)\n                elif c_min > np.iinfo(np.int64).min and c_max < np.iinfo(np.int64).max:\n                    df[col] = df[col].astype(np.int64)  \n            else:\n                if c_min > np.finfo(np.float16).min and c_max < np.finfo(np.float16).max:\n                    df[col] = df[col].astype(np.float16)\n                elif c_min > np.finfo(np.float32).min and c_max < np.finfo(np.float32).max:\n                    df[col] = df[col].astype(np.float32)\n                else:\n                    df[col] = df[col].astype(np.float64)\n        else:\n            df[col] = df[col].astype('category')\n\n    end_mem = df.memory_usage().sum() / 1024**2\n    print('Memory usage after optimization is: {:.2f} MB'.format(end_mem))\n    print('Decreased by {:.1f}%'.format(100 * (start_mem - end_mem) / start_mem))\n    \n    return df","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5edb254c90b3f42f764e4fc0429ddc79bfaa712b"},"cell_type":"code","source":"historical_transactions_df = reduce_mem_usage(historical_transactions_df)\nnew_merchant_transactions_df = reduce_mem_usage(new_merchant_transactions_df)\nmerchants_df = reduce_mem_usage(merchants_df)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c60cd227849bbf27a44e88f811ee393e746e480d"},"cell_type":"code","source":"train_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"ac36aedda129a8762388aeab0806c162461dec76"},"cell_type":"code","source":"train_df.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"eb49e32064b43d639c262175a443f87693d04db6"},"cell_type":"code","source":"test_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4d6b70c9c50d844161a0caa78e5d8f8f5bc65e6e"},"cell_type":"code","source":"test_df.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f75c1a4eead061cb107a9491abe989e49eb29dc9"},"cell_type":"code","source":"merchants_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f1f83e12f3dde58ebaf366302ec7ea3ae42e2f21"},"cell_type":"code","source":"merchants_df.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"088f5bd03c1c6786d9a11f0fcd8ee9fb34e98e42"},"cell_type":"code","source":"new_merchant_transactions_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"979aa0425f8ee7a387dc337d6dd3b89379de6f5c"},"cell_type":"code","source":"historical_transactions_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"aacde9f43b7e8398d3cf4a650409c071b2830f17"},"cell_type":"code","source":"historical_transactions_df.isna().sum()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"740b20c081171734731d1fc24d322fcbee549188"},"cell_type":"code","source":"historical_transactions_df['category_3'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a4982b6602025fa9c9058525a878b2a1d7b5a9db"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0614e5ba0e5f8da16d0e1375d01b626fceb235d7"},"cell_type":"code","source":"new_merchant_transactions_df.isna().sum()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"aa09f0c57d028149119bee1962104fcd9f141e5c"},"cell_type":"code","source":"new_merchant_transactions_df['category_3'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9f0aff375a98937c16b46bfb751e87467e0bf095"},"cell_type":"code","source":"new_merchant_transactions_df.head(2)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"411516f95e63a03cf50763b56a1a6246b2d0d26e"},"cell_type":"code","source":"#historical_transactions_df.isna().sum()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3efa452802f07d3da4aa2381cd8e6c8d39808450"},"cell_type":"code","source":"new_merchant_transactions_df['category_2'].fillna(1.0, inplace=True)\nnew_merchant_transactions_df['category_3'].fillna('A', inplace=True)\n\nhistorical_transactions_df['category_2'].fillna(1.0, inplace=True)\nhistorical_transactions_df['category_3'].fillna('A', inplace=True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"af3ba5d1a47669c0612eba79fc58120dc7d6fbff"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9d3c875eb985afaae1935538eaa002abbc7c4590"},"cell_type":"code","source":"#del historical_transactions_df['category_2']\n#del historical_transactions_df['category_3']\n\n#del new_merchant_transactions_df['category_2']\n#del new_merchant_transactions_df['category_3']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"593e9dac8cfc0526a74d99264df5063885534eb8"},"cell_type":"code","source":"historical_transactions_df = historical_transactions_df.dropna()\nnew_merchant_transactions_df = new_merchant_transactions_df.dropna()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"757249283a52e4884ad8c7b6e9f632c63675bf75"},"cell_type":"code","source":"train_df.head(2)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e424f12788748b634fecf1be5cc838351f3e669f"},"cell_type":"code","source":"test_df.head(2)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7537ffe9d01c6f6f8521bdfc09fd9382fca9da9e"},"cell_type":"code","source":"train_df['first_active_month'] = pd.to_datetime(train_df['first_active_month'])\ntest_df['first_active_month'] = pd.to_datetime(test_df['first_active_month'])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0789cc1c6ca1b396c023afe417ea58004e17b199"},"cell_type":"code","source":"train_df.dtypes","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e8d07cf1f75b419e538f2fde054671483119f1f7"},"cell_type":"code","source":"#hist_trans_df_group = historical_transactions_df.groupby('card_id')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9cc71b418d0f075d09c4b57ab6295a4b8d1671cb"},"cell_type":"code","source":"historical_transactions_df.head(2)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7c52d3db56f4b8bc1f383f358e740f3fa2123230"},"cell_type":"code","source":"new_merchant_transactions_df.head(2)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0104c502a982833008dd2d4dc2dc71b37879130f"},"cell_type":"code","source":"def binarize(df):\n    for col in ['authorized_flag', 'category_1']:\n        df[col] = df[col].map({'Y':1, 'N':0})\n    return df\n\nhistorical_transactions_df = binarize(historical_transactions_df)\nnew_merchant_transactions_df = binarize(new_merchant_transactions_df)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"fe76491e42f9776ee479aacbe82ab3819e0e7135"},"cell_type":"code","source":"historical_transactions_df['category_3'] = historical_transactions_df['category_3'].astype('category').cat.codes\nnew_merchant_transactions_df['category_3'] = new_merchant_transactions_df['category_3'].astype('category').cat.codes","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8561dc8856a37a6d0180a2c76e832d3cd27cf469"},"cell_type":"code","source":"historical_transactions_df.head(2)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"774a4dc529c5424fbb32297b490f434e577d5198"},"cell_type":"code","source":"new_merchant_transactions_df.head(2)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0cb24007c906471e9b12467c3d785d6a7328aaee"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f63f5ea1055d81b4956ceb8f2dc100c6090db2aa"},"cell_type":"code","source":"transactions = historical_transactions_df.append(new_merchant_transactions_df)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"196eb3aa1977be15e6eccaabeb68a6f1e8dc38a7"},"cell_type":"code","source":"historical_transactions_df.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3cae04d3126e7d8a2023b8738930cf58d520eb4c"},"cell_type":"code","source":"new_merchant_transactions_df.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e9f3011e0d1fe5d8f5a1c6bb05e0cde48735f781"},"cell_type":"code","source":"transactions.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"96d482f33cd18f359d9bb29c5a62538922d2a23e"},"cell_type":"code","source":"del historical_transactions_df\ndel new_merchant_transactions_df","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d7234d06462a00e3fbfe4896a9184afb18a0d934"},"cell_type":"code","source":"#transactions = reduce_mem_usage(transactions)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8cdcfb60e9f0d7728722cc46a51518888c8aa259"},"cell_type":"code","source":"from scipy import stats","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8085a3a8d5bf496356ab6db16a61345db7a35653"},"cell_type":"code","source":"def aggregate_transactions(history):\n    history.loc[:, 'purchase_date'] = pd.DatetimeIndex(history['purchase_date']).\\\n                                      astype(np.int64) * 1e-9\n    agg_func = {\n    \n    'authorized_flag': ['sum', 'mean', lambda x: tuple(stats.mode(x)[0])],\n    'category_1': ['sum', 'mean', lambda x: tuple(stats.mode(x)[0])],\n    'category_2': ['sum', 'mean', lambda x: tuple(stats.mode(x)[0])],\n    'category_3': ['sum', 'mean', lambda x: tuple(stats.mode(x)[0])],\n    'merchant_id': ['nunique', lambda x: tuple(stats.mode(x)[0])],\n    'merchant_category_id': ['nunique', lambda x: tuple(stats.mode(x)[0])],\n    'state_id': ['nunique', lambda x: tuple(stats.mode(x)[0])],\n    'city_id': ['nunique', lambda x: tuple(stats.mode(x)[0])],\n    'subsector_id': ['nunique', lambda x: tuple(stats.mode(x)[0])],\n    'purchase_amount': ['sum', 'mean', 'max', 'min', 'std'],\n    'installments': ['sum', 'mean', 'max', 'min', 'std'],\n    'month_lag': [ lambda x: tuple(stats.mode(x)[0])]\n    }\n    \n    agg_history = history.groupby(['card_id']).agg(agg_func)\n    agg_history.columns = ['_'.join(col).strip() for col in agg_history.columns.values]\n    agg_history.reset_index(inplace=True)\n    \n    df = (history.groupby('card_id')\n          .size()\n          .reset_index(name='transactions_count'))\n    \n    agg_history = pd.merge(df, agg_history, on='card_id', how='left')\n    \n    return agg_history","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b232fed6095936a945251e65311b27efdb237089"},"cell_type":"code","source":"history = aggregate_transactions(transactions)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0b08bccbc3836b70b79db824448cb86056cd9503"},"cell_type":"code","source":"history.columns = ['hist_' + c if c != 'card_id' else c for c in history.columns]\nhistory[:5]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"699a69d4a14f527aa70b7dca6158bceb4ce52095"},"cell_type":"code","source":"history.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"838ed97986cc205be43f51fdec232e3c0f1cfee5"},"cell_type":"code","source":"train = pd.merge(train_df, history, on='card_id', how='left')\ntest = pd.merge(test_df, history, on='card_id', how='left')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"414e5296175b183756ff85a5dab6efcea13c243f"},"cell_type":"code","source":"train['hist_authorized_flag_<lambda>'] = train['hist_authorized_flag_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)\ntrain['hist_category_1_<lambda>'] = train['hist_category_1_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"def5ed6260d6068f4b07ea67c54b8663dc8db93d"},"cell_type":"code","source":"train['hist_category_2_<lambda>'] = train['hist_category_2_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain['hist_category_3_<lambda>'] = train['hist_category_3_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain['hist_merchant_id_<lambda>'] = train['hist_merchant_id_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain['hist_merchant_category_id_<lambda>'] = train['hist_merchant_category_id_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)\ntrain['hist_state_id_<lambda>'] = train['hist_state_id_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)\ntrain['hist_city_id_<lambda>'] = train['hist_city_id_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)\ntrain['hist_subsector_id_<lambda>'] = train['hist_subsector_id_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)\ntrain['hist_month_lag_<lambda>'] = train['hist_month_lag_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"10c97925a8942561e9bbe09d41e181c747978457"},"cell_type":"code","source":"test['hist_authorized_flag_<lambda>'] = test['hist_authorized_flag_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)\ntest['hist_category_1_<lambda>'] = test['hist_category_1_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)\ntest['hist_category_2_<lambda>'] = test['hist_category_2_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest['hist_category_3_<lambda>'] = test['hist_category_3_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\n\ntest['hist_merchant_id_<lambda>'] = test['hist_merchant_id_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest['hist_merchant_category_id_<lambda>'] = test['hist_merchant_category_id_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)\ntest['hist_state_id_<lambda>'] = test['hist_state_id_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)\ntest['hist_city_id_<lambda>'] = test['hist_city_id_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)\ntest['hist_subsector_id_<lambda>'] = test['hist_subsector_id_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)\ntest['hist_month_lag_<lambda>'] = test['hist_month_lag_<lambda>'].map(lambda x: str(x).lstrip('(').rstrip(',)')).astype(int)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1ca2d5bc1c1d373fab329566c2d21a94a8913b13"},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4db847d34b975fde43476b091879d4a896414866"},"cell_type":"code","source":"test.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"93222f036afb2f66b31bdf69296031632ccd3ed7"},"cell_type":"code","source":"test.columns","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"842ddf287ba0363de67fefa9c24e1ba29c427bef"},"cell_type":"code","source":" test.columns = ['first_active_month', 'card_id', 'feature_1', 'feature_2', 'feature_3',\n       'hist_transactions_count', 'hist_authorized_flag_sum',\n       'hist_authorized_flag_mean', 'hist_authorized_flag_mode',\n       'hist_category_1_sum', 'hist_category_1_mean',\n       'hist_category_1_mode', 'hist_category_2_sum',\n       'hist_category_2_mean', 'hist_category_2_mode',\n       'hist_category_3_sum', 'hist_category_3_mean',\n       'hist_category_3_mode', 'hist_merchant_id_nunique',\n       'hist_merchant_id_mode', 'hist_merchant_category_id_nunique',\n       'hist_merchant_category_id_mode', 'hist_state_id_nunique',\n       'hist_state_id_mode', 'hist_city_id_nunique',\n       'hist_city_id_mode', 'hist_subsector_id_nunique',\n       'hist_subsector_id_mode', 'hist_purchase_amount_sum',\n       'hist_purchase_amount_mean', 'hist_purchase_amount_max',\n       'hist_purchase_amount_min', 'hist_purchase_amount_std',\n       'hist_installments_sum', 'hist_installments_mean',\n       'hist_installments_max', 'hist_installments_min',\n       'hist_installments_std', 'hist_month_lag_mode']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"30f118b7917bc32f7603804b69c3c853f1bff045"},"cell_type":"code","source":"train.columns","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f92f3efecad0a4a975d9e858a6c0b462f538b763"},"cell_type":"code","source":"train.columns = ['first_active_month', 'card_id', 'feature_1', 'feature_2', 'feature_3',\n       'target', 'hist_transactions_count', 'hist_authorized_flag_sum',\n       'hist_authorized_flag_mean', 'hist_authorized_flag_mode',\n       'hist_category_1_sum', 'hist_category_1_mean',\n       'hist_category_1_mode', 'hist_category_2_sum',\n       'hist_category_2_mean', 'hist_category_2_mode',\n       'hist_category_3_sum', 'hist_category_3_mean',\n       'hist_category_3_mode', 'hist_merchant_id_nunique',\n       'hist_merchant_id_mode', 'hist_merchant_category_id_nunique',\n       'hist_merchant_category_id_<lambda>', 'hist_state_id_nunique',\n       'hist_state_id_mode', 'hist_city_id_nunique',\n       'hist_city_id_mode', 'hist_subsector_id_nunique',\n       'hist_subsector_id_mode', 'hist_purchase_amount_sum',\n       'hist_purchase_amount_mean', 'hist_purchase_amount_max',\n       'hist_purchase_amount_min', 'hist_purchase_amount_std',\n       'hist_installments_sum', 'hist_installments_mean',\n       'hist_installments_max', 'hist_installments_min',\n       'hist_installments_std', 'hist_month_lag_mode']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c7d8e7e83a445d5222c83fbbc932fbd0c4855dac"},"cell_type":"code","source":"train.head(2)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8aa222b88099bf4643b986e56a96eb6774176082"},"cell_type":"code","source":"test.head(2)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a6f0327968bdfa7f812b0f621c0b45f2693bf210"},"cell_type":"code","source":"del transactions","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d18c9f7de23301d0f242ed0035dbdb5548decd0c"},"cell_type":"code","source":"merchants_df.isna().sum()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4fb30e488ae1264156efba45e404ab6b9db371a6"},"cell_type":"code","source":"merchants_df['category_2'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c2016705b4d782bb9e914e51def2e1d67b3a3633"},"cell_type":"code","source":"#merchants_df['avg_sales_lag6'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c8b9a46600b8952c7e72d08a1fa220962a5b4887"},"cell_type":"code","source":"###### merchants_df['avg_sales_lag3'].fillna(1.0, inplace = True)\nmerchants_df['avg_sales_lag3'].fillna(1.0, inplace = True)\nmerchants_df['avg_sales_lag6'].fillna(1.0, inplace = True)\nmerchants_df['avg_sales_lag12'].fillna(1.0, inplace = True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"bd173e8b37a19b9a4492e004fbf82140a7b69926"},"cell_type":"code","source":"merchants_df['category_2'].fillna(1.0, inplace = True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"37209e2b40d917e7a20ba1d2b96a8869251c8f45"},"cell_type":"code","source":"merchants_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e6815852e0aff2e051609233350938b9e4098ffa"},"cell_type":"code","source":"merchants_df['category_4'].value_counts()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3b19a9d90fbc6f485e7c71d80dbb23712100eff8"},"cell_type":"code","source":"merchants_df['category_1'] = merchants_df['category_1'].astype('category').cat.codes\nmerchants_df['most_recent_sales_range'] = merchants_df['most_recent_sales_range'].astype('category').cat.codes\n\nmerchants_df['most_recent_purchases_range'] = merchants_df['most_recent_purchases_range'].astype('category').cat.codes\nmerchants_df['category_4'] = merchants_df['category_4'].astype('category').cat.codes","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"73f6d3f7c95a0a47a71bf4bc7f085e16f5c10eac"},"cell_type":"code","source":"merchants_df.apply(lambda x:len(x.unique()))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9f1d83c252b26e4b7c14d5f5fd1ae2c1d2cc1e97"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c6d17b6d8cb833f55a035247919b38be002decfb"},"cell_type":"code","source":"merchants_df.columns","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"988bfa679e43b0bfda6da7c4d1c1b776ec54e9cf"},"cell_type":"code","source":"merchants_df.apply(lambda x:len(x.unique()))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"57e7d47736868bf120a4f4f13b12dbbc1b35fa89"},"cell_type":"code","source":"def aggregate_merchants(history):\n    \n    agg_func = {\n    \n    'merchant_group_id': [lambda x: tuple(stats.mode(x)[0])],\n    'merchant_category_id': [lambda x: tuple(stats.mode(x)[0])],\n    'subsector_id': [lambda x: tuple(stats.mode(x)[0])],\n    'numerical_1': ['sum', 'mean'],\n    'numerical_2': ['sum', 'mean'],\n    'category_1': [lambda x: tuple(stats.mode(x)[0])],\n    'most_recent_sales_range': [lambda x: tuple(stats.mode(x)[0])],\n    'most_recent_purchases_range': [lambda x: tuple(stats.mode(x)[0])],\n    'avg_sales_lag3': ['sum', 'mean'],\n    'avg_purchases_lag3': ['sum', 'mean'],\n    'active_months_lag3': [lambda x: tuple(stats.mode(x)[0])],\n    'avg_sales_lag6': ['mean',lambda x: tuple(stats.mode(x)[0])],\n    'avg_purchases_lag6': ['sum', 'mean'],\n    'active_months_lag6': [lambda x: tuple(stats.mode(x)[0])],\n    'avg_sales_lag12': ['sum', 'mean'],\n    'avg_purchases_lag12': ['sum', 'mean'],\n    'active_months_lag12': [lambda x: tuple(stats.mode(x)[0])],\n    'category_4': [lambda x: tuple(stats.mode(x)[0])],\n    'city_id': [lambda x: tuple(stats.mode(x)[0])],\n    'state_id': [lambda x: tuple(stats.mode(x)[0])],\n    'category_2': [lambda x: tuple(stats.mode(x)[0])]\n        \n    }\n    \n    agg_history = history.groupby(['merchant_id']).agg(agg_func)\n    agg_history.columns = ['_'.join(col).strip() for col in agg_history.columns.values]\n    agg_history.reset_index(inplace=True)\n    \n    df = (history.groupby('merchant_id')\n          .size()\n          .reset_index(name='merchant_count'))\n    \n    agg_history = pd.merge(df, agg_history, on='merchant_id', how='left')\n    \n    return agg_history","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"30d90d9716a9d0935b6ba0c4cc6af149dd1c72ee"},"cell_type":"code","source":"merchants_data = aggregate_merchants(merchants_df)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d178e1b738fdd16284dfb3d82a53897ecb452cc8"},"cell_type":"code","source":"merchants_data.columns = ['merch_' + c if c != 'merchant_id' else c for c in merchants_data.columns]\nmerchants_data[:5]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"156af577b3f2d7c28ea3e71e66aa242709a9a5ce"},"cell_type":"code","source":"merchants_data.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"7e5e8462c93728554826b45df9ce1c9373487094"},"cell_type":"code","source":"merchants_data.columns","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6faf830b57cdc70a41580df36edba02c812a3511"},"cell_type":"code","source":"merchants_data.columns = ['merchant_id', 'merch_merchant_count',\n       'merch_merchant_group_id_mode',\n       'merch_merchant_category_id_mode', 'merch_subsector_id_mode',\n       'merch_numerical_1_sum', 'merch_numerical_1_mean',\n       'merch_numerical_2_sum', 'merch_numerical_2_mean',\n       'merch_category_1_mode', 'merch_most_recent_sales_range_mode',\n       'merch_most_recent_purchases_range_mode',\n       'merch_avg_sales_lag3_sum', 'merch_avg_sales_lag3_mean',\n       'merch_avg_purchases_lag3_sum', 'merch_avg_purchases_lag3_mean',\n       'merch_active_months_lag3_mode', 'merch_avg_sales_lag6_mean',\n       'merch_avg_sales_lag6_mode', 'merch_avg_purchases_lag6_sum',\n       'merch_avg_purchases_lag6_mean', 'merch_active_months_lag6_mode',\n       'merch_avg_sales_lag12_sum', 'merch_avg_sales_lag12_mean',\n       'merch_avg_purchases_lag12_sum', 'merch_avg_purchases_lag12_mean',\n       'merch_active_months_lag12_mode', 'merch_category_4_mode',\n       'merch_city_id_mode', 'merch_state_id_mode',\n       'merch_category_2_mode']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6cd20677e2f3607de45fbeca85cc481f082b011f"},"cell_type":"code","source":"merchants_data.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"895f433c08457e92989bfd202e46336e5738ead9"},"cell_type":"code","source":"del merchants_df","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e50075e66cc7b7285e69c31f8ba43a54b9dcb987"},"cell_type":"code","source":"merchants_data.isna().sum()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"677a4ce0a0d2e4322fc04d7b2aa0a0d639eb0e09"},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3965932bae2cf585647b6ec8fa2869d4abd192e6"},"cell_type":"code","source":"train['merchant_id'] = train['hist_merchant_id_mode'].str.replace('\\W', '')\ntest['merchant_id'] = test['hist_merchant_id_mode'].str.replace('\\W', '')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"84cfb210acd9c81b89dc7cd949a94f21f4c5400a"},"cell_type":"code","source":"del train['hist_merchant_id_mode']\ndel test['hist_merchant_id_mode']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"ca7cb1f77ca3ff7d27d0362c88cc92a0c429422d"},"cell_type":"code","source":"test['old_index'] = range(0, len(test))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2ba1e6aae5ee642d5f61fc37121456d8b6b1792f"},"cell_type":"code","source":"train_final = pd.merge(train, merchants_data,  on=['merchant_id'] )\ntest_final = pd.merge(test, merchants_data,  on=['merchant_id'] )","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"17341fe3cdfd94a756835913eb73c7e487efd434"},"cell_type":"code","source":"train_final.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"061bf7ab16cf2b49d385432e4846e6c489d9f9be"},"cell_type":"code","source":"train.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"87745348aa9463a1ffc9bcd3d0564f7fa5d233da"},"cell_type":"code","source":"train_final.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c004b2251240f2cec9bd9945de7ec3108d2e5ee5"},"cell_type":"code","source":"train.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"98bc154a9420ab0c982863d02fca4e24163b6d57"},"cell_type":"code","source":"test.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"744893dc5097d046014f645560ce2eaa911ccf87"},"cell_type":"code","source":"test_final.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"61f9d7170fc34493dc4f648f2a699db148e8119e"},"cell_type":"code","source":"test.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0402264a3007b5e988d34fbd52b44cc9e13dee5f"},"cell_type":"code","source":"test_final.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a5920405c84489f19612ce2a84403c740a0f27c1"},"cell_type":"code","source":"test_final = test_final.sort_values(by=['old_index'])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2735a2e7513039841bf916098ae6b5d13322688a"},"cell_type":"code","source":"test_final.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"99eb6921c267d064c8f36f46406f8f1889a9425f"},"cell_type":"code","source":"test_final.index = test_final['old_index'].values","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a505f0acd4dd8ffce121d24db8203b16aa00a1e6"},"cell_type":"code","source":"test_final.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"12f4d623f0d523f3a94951f45f33e49ab41f96c5"},"cell_type":"code","source":"train_final['merch_merchant_group_id_mode'] = train_final['merch_merchant_group_id_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_merchant_category_id_mode'] = train_final['merch_merchant_category_id_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_subsector_id_mode'] = train_final['merch_subsector_id_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_category_1_mode'] = train_final['merch_category_1_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_most_recent_sales_range_mode'] = train_final['merch_most_recent_sales_range_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_most_recent_purchases_range_mode'] = train_final['merch_most_recent_purchases_range_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_active_months_lag3_mode'] = train_final['merch_active_months_lag3_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_avg_sales_lag6_mode'] = train_final['merch_avg_sales_lag6_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_active_months_lag6_mode'] = train_final['merch_active_months_lag6_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_active_months_lag12_mode'] = train_final['merch_active_months_lag12_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_category_4_mode'] = train_final['merch_category_4_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_city_id_mode'] = train_final['merch_city_id_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_state_id_mode'] = train_final['merch_state_id_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntrain_final['merch_category_2_mode'] = train_final['merch_category_2_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6df160a1285e8fee0963b79793c4ce14d615dcf2"},"cell_type":"code","source":"test_final['merch_merchant_group_id_mode'] = test_final['merch_merchant_group_id_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_merchant_category_id_mode'] = test_final['merch_merchant_category_id_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_subsector_id_mode'] = test_final['merch_subsector_id_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_category_1_mode'] = test_final['merch_category_1_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_most_recent_sales_range_mode'] = test_final['merch_most_recent_sales_range_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_most_recent_purchases_range_mode'] = test_final['merch_most_recent_purchases_range_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_active_months_lag3_mode'] = test_final['merch_active_months_lag3_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_avg_sales_lag6_mode'] = test_final['merch_avg_sales_lag6_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_active_months_lag6_mode'] = test_final['merch_active_months_lag6_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_active_months_lag12_mode'] = test_final['merch_active_months_lag12_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_category_4_mode'] = test_final['merch_category_4_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_city_id_mode'] = test_final['merch_city_id_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_state_id_mode'] = test_final['merch_state_id_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))\ntest_final['merch_category_2_mode'] = test_final['merch_category_2_mode'].map(lambda x: str(x).lstrip('(').rstrip(',)'))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"dfcaabe94e80d4eb0fa87cfd1d329f3ed4733064"},"cell_type":"code","source":"train_final.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"ddde48f0eef2aed0de69acc7e4a3872069324163"},"cell_type":"code","source":"test_final.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"d181bbc0e5472e322f61f5cb7c6ef20bdef22d9e"},"cell_type":"code","source":"y_train = train_final['target']\ndel train_final['target']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8e40e58aa29a25fa6d6fdb664d30b8561ef80bbd"},"cell_type":"code","source":"train_final['month'] =  pd.DatetimeIndex(train_final['first_active_month']).month  \ntest_final['month'] = pd.DatetimeIndex(test_final['first_active_month']).month\n\ndel train_final['first_active_month']\ndel test_final['first_active_month']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"122c5012a5d9a55f284703291da7e7a651c4d423"},"cell_type":"code","source":"test_card_ids = test_final['card_id']\ndel test_final['card_id']\ndel test_final['merchant_id']\ndel train_final['card_id']\ndel train_final['merchant_id']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b2d27ec9b56d4f611b11e214c12ec801bb9f4b78"},"cell_type":"code","source":"del test_final['old_index']","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9374e203c168dcae670820528805a0a9d4a0c13f"},"cell_type":"code","source":"train_final.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a2a06e67f1209eba28629d3146138629ffd92d4a"},"cell_type":"code","source":"test_final.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6337f326324fa43775f4922d367e23d2160e8827"},"cell_type":"code","source":"y_train.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"21bf55e1dfdb57ff447b2f9ddb043da5f4712d9b"},"cell_type":"code","source":"del train\ndel test\n#del merchants_data\n#del history","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f920e9afb40719496743c7ae0b08a8235918db36"},"cell_type":"code","source":"test_final.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1bd86881cbc8f246091580da452f60ed1c136cf2"},"cell_type":"code","source":"test_final.isna().sum()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"37815f02bcf1ba08bd31dcec15cac96759ba98aa"},"cell_type":"code","source":"test_final['month'].fillna(12.0, inplace = True)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8d23fad69af0909a71affafa567a70d989189bb3"},"cell_type":"code","source":"x_train = np.array(train_final)\nx_test = np.array(test_final)\ny_train = np.array(y_train).reshape(201917,1)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"90769fdcb2e0cebadf4714080b692dfa27dd52c1"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"dbf2f93a2804b8c1d311c41ee29432488dab4458"},"cell_type":"code","source":"from keras.models import Sequential\nfrom keras.layers import Dense\nfrom keras.wrappers.scikit_learn import KerasRegressor\nfrom sklearn.model_selection import cross_val_score","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5e948d7891992d8dd85b12244c3938d24c69a949"},"cell_type":"code","source":"model = Sequential()\nmodel.add(Dense(134, input_dim=67, activation='relu', kernel_initializer='random_uniform'))\n#model.add(Dense(134,activation='relu', kernel_initializer='random_uniform'))\n#model.add(Dense(67,activation='relu', kernel_initializer='random_uniform'))\nmodel.add(Dense(1, activation='linear', kernel_initializer='random_uniform'))\nmodel.compile(loss='mse', optimizer='adam')\nmodel.fit(x_train, y_train, epochs=30)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"164d4643b4a050a6089716796f61d5bd4a20cd22"},"cell_type":"code","source":"#from sklearn.ensemble import RandomForestRegressor\n#RF = RandomForestRegressor()\n#RF.fit(train_final,y_train)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8ce1c5ef16c3658cc503a9d3018e34703a79ff0b"},"cell_type":"code","source":"#train_final.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"099e9cbd8d253f334c4b6c063de9e169cc7dafbd"},"cell_type":"code","source":"#test_final.shape","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"eb8fdb47a541f9b2b3b3308cd83de03c40e1046d"},"cell_type":"code","source":"#train_final.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"23d30f77f67636e1402f02d642e37615ce3ac0fa"},"cell_type":"code","source":"#test_final.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4a76c18f09c361ff92236edd5e0d7d7bcf0474d0"},"cell_type":"code","source":"#from sklearn.linear_model import LinearRegression, Lasso\n#lm = Lasso(alpha=0.1, normalize=False)\n#lm.fit(train_final, y_train)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6a4dfc979cf849aa451ded16c22773d67519f0e1"},"cell_type":"code","source":"#y_pred = lm.predict(test_final)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f0e0dec9112a19175db2d33fb9d0765f79b43efb"},"cell_type":"code","source":"y_pred = model.predict(x_test)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"bc8b41c3e94a564aee7625fd0d6e8c6d24c83c74"},"cell_type":"code","source":"submission_df = pd.DataFrame()\nsubmission_df['card_id'] = test_card_ids\nsubmission_df['target'] = y_pred","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9aeade550d3ad92ad67d3f3364d2ae5fe8546cd5"},"cell_type":"code","source":"submission_df.to_csv(\"submission.csv\", index=None)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"dfa20254f0e453e6fc6a117da618d3f5a110cb96"},"cell_type":"code","source":"submission_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"69a8becee0fff6ba67c4baaa85b1853c051b766d"},"cell_type":"code","source":"sample_train = train_final.copy()\nsample_train['target'] = y_train","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5d6563f2657147aaa9240f8557ee49309902925f"},"cell_type":"code","source":"sample_test = test_final.copy()\nsample_test['card_id'] = test_card_ids\nsample_test.to_csv(\"test_out.csv\", index=None)\nsample_train.to_csv(\"train_out.csv\", index=None)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9a17f852f093851f02d0e2965e56ab27a12147f2"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"aa4d8f4ab9580836eae0086b454d795f49fc719b"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"e5ee7e5c986695a7359a5f2ea2d45ab892a16adc"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}