{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true,"_kg_hide-output":false},"cell_type":"code","source":"# from SRK, thanks!\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\nimport os\nprint(os.listdir(\"../input\"))\n\nimport json\nfrom pandas.io.json import json_normalize\nimport matplotlib.pyplot as plt\nimport seaborn as sns\ncolor = sns.color_palette()\n\n%matplotlib inline\n\nfrom plotly import tools\nimport plotly.offline as py\npy.init_notebook_mode(connected=True)\nimport plotly.graph_objs as go\n\nfrom sklearn import model_selection, preprocessing, metrics\nimport lightgbm as lgb\n\npd.options.mode.chained_assignment = None\npd.options.display.max_columns = 999","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","collapsed":true,"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":false},"cell_type":"markdown","source":"** 1. DataSet**"},{"metadata":{"trusted":true,"_uuid":"1466f0e3c155a4967555c05d8108d3043a390ef3"},"cell_type":"code","source":"# train.csv                     训练数据\n# merchant.csv                  关于数据集中所有商户/商户id的附加信息\n# sample_submission.csv         正确格式的示例提交文件——包含期望预测的所有card_id\n# test.csv                      测试数据\n# historical_transaction.csv    每个card_id三个月内的历史交易信息\n# new_merchant_transaction.csv  每个card_id两个月的数据,包含在历史数据中未访问过的merchant_ids上的所有购买行为      ","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"38c7b2a6317c9bd40596f332338efa435b30163f"},"cell_type":"markdown","source":"**2. Explore the train and test set**"},{"metadata":{"trusted":true,"_uuid":"7efb8bded57cfc71339a907b1a83d1e004d6ab7f"},"cell_type":"code","source":"train_df = pd.read_csv(\"../input/train.csv\", parse_dates=[\"first_active_month\"])   # 将首次活动时间解析为日期\ntest_df = pd.read_csv(\"../input/test.csv\", parse_dates=[\"first_active_month\"])\nprint(\"Number of rows and columns in train set : \",train_df.shape)\nprint(\"Number of rows and columns in test set : \",test_df.shape)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b2bf09ca6f9a86856173875e58abbff2736caa8f"},"cell_type":"code","source":"train_df.head()  # 首次活跃时间 卡号 特征1 特征2 特征3 目标值","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"80e0abfd9ebc8c51da3fcbfeca49cae377e7caa1"},"cell_type":"markdown","source":"**3. Target Column Exploration**"},{"metadata":{"trusted":true,"_uuid":"020e6b19eba400711d01e5f98d32786a84618582"},"cell_type":"code","source":"# target_col 分布图 \n\ntarget_col = 'target'\n\nplt.figure(figsize=(8,6))\nplt.scatter(range(train_df.shape[0]), np.sort(train_df[target_col].values))   # 绘制散点图\nplt.xlabel('index', fontsize=12)\nplt.ylabel('Loyalty Score', fontsize=12)    # 历史点击率\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"772c51bfb7abf6340fbe5e569f7d881b5394668f"},"cell_type":"code","source":"# target_col 直方图\n# 直方图表示通过沿数据范围形成分箱，然后绘制条以显示落入每个分箱的观测次数的数据分布\n\nplt.figure(figsize=(12,8))\nsns.distplot(train_df[target_col].values, bins=50, color='red')\nplt.title('Histograme of Loyalty score')\nplt.xlabel('Loyalty score', fontsize=12)       # 历史点击率柱状图\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"63ae56a7fea7a1694c1a934a944a88f0048b9531"},"cell_type":"markdown","source":"**部分真实点击率远小于其他值，对其统计**"},{"metadata":{"trusted":true,"_uuid":"8efcefe84c1566b68d7866ce6630c8975b13666f"},"cell_type":"code","source":"(train_df[target_col]<-30).sum()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"6ab8a159daefa3df769957be9bdabc4daaffaf5b"},"cell_type":"markdown","source":"**存在2207行数据（训练数据1%），其真实点击率值与其他数据差异极大。由于度量RMSE，所以这些行可能极为重要**"},{"metadata":{"_uuid":"6b003b18b6890d5add3816039e0e69616c119d57"},"cell_type":"markdown","source":"**4. 观察关于card_id的首次活动时间，在训练集和测试集中的分布是否存在变化**"},{"metadata":{"trusted":true,"_uuid":"c01e285af55fa1d92d3b4c4d35b498865cc1076f"},"cell_type":"code","source":"# 训练集所有首次活动时间频次统计\n#条形图表示数值变量与每个矩形高度的中心趋势的估计值，并使用误差线提供关于该估计值附近的不确定性的一些指示\n\ncnt_srs = train_df['first_active_month'].dt.date.value_counts()  # 获取首次活动时间的频次统计\ncnt_srs = cnt_srs.sort_index()                                   # 按首次活动时间排序\nplt.figure(figsize=(14,6))\nsns.barplot(cnt_srs.index, cnt_srs.values, alpha=0.8, color='green')  # 索引为x 值为y\nplt.xticks(rotation='vertical')                                       # 设置标签方向\nplt.xlabel('First active month', fontsize=12)\nplt.ylabel('Number of cards', fontsize=12)\nplt.title('First active month count in train set')\nplt.show()\n\n# 测试集所有首次活动时间频次统计\n\ncnt_srs = test_df['first_active_month'].dt.date.value_counts()\ncnt_srs = cnt_srs.sort_index()\nplt.figure(figsize=(14,6))\nsns.barplot(cnt_srs.index, cnt_srs.values, alpha=0.8, color='red')\nplt.xticks(rotation='vertical')\nplt.xlabel('First active month', fontsize=12)\nplt.ylabel('Number of cards', fontsize=12)\nplt.title('First active month count in train set')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"a363c4bf5a141dfc22e9b64223400057c85cc17c"},"cell_type":"markdown","source":"**训练集和测试集之间的分布基本一致，所以我们暂时不需要做基于时间的分割**"},{"metadata":{"_uuid":"94baa1e6148f847a4dd4464afbbac0b17da078c9"},"cell_type":"markdown","source":"**5. Feature 1 2 3**\n"},{"metadata":{"_uuid":"20bb8e2d40f6fe27e18b250354dff5a619a16cbd"},"cell_type":"markdown","source":"**探索训练集中的特征1、2、3是否有良好点击率预估能力 **\n"},{"metadata":{"trusted":true,"_uuid":"009b9eb5a378c6a86fcae6f256421559c38505cc"},"cell_type":"code","source":"# 它显示了定量数据在一个（或多个）分类变量的多个层次上的分布，这些分布可以进行比较。\n# 不像箱形图中所有绘图组件都对应于实际数据点，小提琴绘图以基础分布的核密度估计为特征。\n\n# feature 1\nplt.figure(figsize=(8, 4))\nsns.violinplot(x='feature_1', y=target_col, data=train_df)         \nplt.xticks(rotation='vertical')\nplt.xlabel('Feature_1', fontsize=12)\nplt.ylabel('Loyalty score', fontsize=12)\nplt.title('Feature_1 distribution')     \nplt.show()\n\n# feature 2\nplt.figure(figsize=(8,4))\nsns.violinplot(x='feature_2', y=target_col, data=train_df)\nplt.xticks(rotation='vertical')\nplt.xlabel('Feature_2', fontsize=12)\nplt.ylabel('Loyalty score', fontsize=12)\nplt.title('Feature_2 distribution')\nplt.show()\n\n# feature 3\nplt.figure(figsize=(8,4))\nsns.violinplot(x='feature_3', y=target_col,data=train_df)\nplt.xticks(rotation='vertical')\nplt.xlabel('Feature_3', fontsize=12)\nplt.ylabel('Loyalty score', fontsize=12)\nplt.title('Feature_3 distribution')\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c24428007c4802bbe20baa1f0a768d733a015f28"},"cell_type":"markdown","source":"**由图可知，这三个特征在不同类别中的分布都是类似的，也许可以在模型中找到东西**"},{"metadata":{"trusted":true,"_uuid":"3e0fd016cd7bf86fa6b53bbee780c7e231b6f84d"},"cell_type":"markdown","source":"**6. 历史交易数据**"},{"metadata":{"trusted":true,"_uuid":"b12a0d06fedacac77a09b48465f980a230b7611d"},"cell_type":"code","source":"hist_df = pd.read_csv('../input/historical_transactions.csv', parse_dates=['purchase_date'])\nhist_df.head()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"8b7f04675143551198918de8fe2a3b6cc293604d"},"cell_type":"markdown","source":"字段描述如下：\n\n1. card_id:                           标识名\n1. month_lag:                      到参考日期的月份延迟\n1. purchase_date:               购买时间\n1. authorized_flag:             授权标志 Y表示同意 N表示拒绝\n1. category_3:                     匿名的类别\n1. installments:                  分期付款购买的数量\n1. category_1:                      匿名的类别\n1. merchant_category_id:  商户类别标识名（匿名）\n1. subsector_id:                  商户类别组标识名（匿名）\n1. merchant_id:                  商户标识名\n1. purchase_amount:         归一化的购买金额\n1. city_id:                             城市标识名\n1. state_id:                          状态标识名（匿名）\n1. category_2:                     匿名的类别\n   "},{"metadata":{"trusted":true,"_uuid":"9762f577a7ca3633938517b4f971d26e85eee302"},"cell_type":"markdown","source":"**7. 根据历史交易数据构造特征并拼接到训练数据和测试数据上**"},{"metadata":{"trusted":true,"_uuid":"b37997df780fad5b10eb12287823d9ef843fd3c2"},"cell_type":"markdown","source":"**1）每个card_id的历史交易数目**"},{"metadata":{"trusted":true,"_uuid":"19dc35d7628044b7dce98f7f1d3e9c177b2c71ce"},"cell_type":"code","source":"gdf = hist_df.groupby('card_id')\ngdf = gdf['purchase_amount'].size().reset_index()\ngdf.columns = ['card_id', 'num_hist_transactions']\ntrain_df = pd.merge(train_df, gdf, on='card_id', how='left')\ntest_df = pd.merge(test_df, gdf, on='card_id', how='left')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f6f5cc8b2b9f839fa88ddf7ef470d53163281195"},"cell_type":"code","source":"cnt_srs = train_df.groupby(\"num_hist_transactions\")[target_col].mean()     # 每个交易数目数目下的点击率均值\ncnt_srs = cnt_srs.sort_index()\ncnt_srs = cnt_srs[:-50]\n\ndef scatter_plot(cnt_srs, color):\n    trace = go.Scatter(\n        x=cnt_srs.index[::-1],\n        y=cnt_srs.values[::-1],\n        showlegend=False,\n        marker=dict(\n            color=color,\n        ),\n    )\n    return trace\n\ntrace = scatter_plot(cnt_srs, \"orange\")\nlayout = dict(\n    title='Loyalty score by Number of historical transactions',\n    )\ndata = [trace]\nfig = go.Figure(data=data, layout=layout)\npy.iplot(fig, filename=\"Histtranscnt\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4972acf1a4fd4c776cf0894ef594b395ffc92603"},"cell_type":"markdown","source":"**将历史交易记录的数量分箱，作方框图观看分布**"},{"metadata":{"trusted":true,"_uuid":"3320d5dc027cd3d11dbf0a3f43899a79753cae27","scrolled":true},"cell_type":"code","source":"bins = [0, 10, 20, 30, 40, 50, 75, 100, 150, 200, 500, 10000]  # 指定区间\ntrain_df['binned_num_hist_transactions'] = pd.cut(train_df['num_hist_transactions'], bins)  # 确定每个数所在区间\ncnt_srs = train_df.groupby(\"binned_num_hist_transactions\")[target_col].mean()\n\nplt.figure(figsize=(12,8))\nsns.boxplot(x=\"binned_num_hist_transactions\", y=target_col, data=train_df, showfliers=False)\nplt.xticks(rotation='vertical')\nplt.xlabel('binned_num_hist_transactions', fontsize=12)\nplt.ylabel('Loyalty score', fontsize=12)\nplt.title(\"binned_num_hist_transactions distribution\")\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"abbd620b56fc690b588a2b3fd5a689da4e3574e5"},"cell_type":"markdown","source":"**2）历史交易价值**\n*  检查card_id对应的历史交易价值，在此基础得到点击率分布"},{"metadata":{"trusted":true,"_uuid":"6ff54a047b10eb072584f7ed957788af81668af9"},"cell_type":"code","source":"gdf = hist_df.groupby(\"card_id\")\ngdf = gdf[\"purchase_amount\"].agg(['sum', 'mean', 'std', 'min', 'max']).reset_index()\ngdf.columns = [\"card_id\", \"sum_hist_trans\", \"mean_hist_trans\", \"std_hist_trans\", \"min_hist_trans\", \"max_hist_trans\"]\ntrain_df = pd.merge(train_df, gdf, on=\"card_id\", how=\"left\")\ntest_df = pd.merge(test_df, gdf, on=\"card_id\", how=\"left\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"b9e5c2a020dbbd43cafd81d10037768dfabde39e"},"cell_type":"code","source":"bins = np.percentile(train_df[\"sum_hist_trans\"], range(0,101,10))             # 处于p%位置的值称第p百分位数\ntrain_df['binned_sum_hist_trans'] = pd.cut(train_df['sum_hist_trans'], bins)  # 将train_df按10个分位数分为10份，每个值替换为为其所在区间\n#cnt_srs = train_df.groupby(\"binned_sum_hist_trans\")[target_col].mean()\n\nplt.figure(figsize=(12,8))\nsns.boxplot(x=\"binned_sum_hist_trans\", y=target_col, data=train_df, showfliers=False)\nplt.xticks(rotation='vertical')\nplt.xlabel('binned_sum_hist_trans', fontsize=12)\nplt.ylabel('Loyalty score', fontsize=12)\nplt.title(\"Sum of historical transaction value (Binned) distribution\")\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"6214339db943a973861850914c69ee874e4a2142"},"cell_type":"markdown","source":"**如上图所示，点击率似乎随着“历史交易价值总和”的增加而增加。**"},{"metadata":{"trusted":true,"_uuid":"cc59efefdf68907b53aecc5c4d8518653ad744b5"},"cell_type":"code","source":"bins = np.percentile(train_df[\"mean_hist_trans\"], range(0,101,10))\ntrain_df['binned_mean_hist_trans'] = pd.cut(train_df['mean_hist_trans'], bins)\n#cnt_srs = train_df.groupby(\"binned_mean_hist_trans\")[target_col].mean()\n\nplt.figure(figsize=(12,8))\nsns.boxplot(x=\"binned_mean_hist_trans\", y=target_col, data=train_df, showfliers=False)\nplt.xticks(rotation='vertical')\nplt.xlabel('Binned Mean Historical Transactions', fontsize=12)\nplt.ylabel('Loyalty score', fontsize=12)\nplt.title(\"Mean of historical transaction value (Binned) distribution\")\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"536184c72c74055116d658ad2fc50b331966d0a0"},"cell_type":"markdown","source":"**如上图，点击率的分布也受“历史交易价值均值”的影响**"},{"metadata":{"_uuid":"a3df7069af24651243ca048b0066947f06cb6450"},"cell_type":"markdown","source":"**8. 新的历史交易记录**"},{"metadata":{"trusted":true,"_uuid":"5728b643f604512d2365883bb3293798821800c1"},"cell_type":"code","source":"new_trans_df = pd.read_csv(\"../input/new_merchant_transactions.csv\", parse_dates=['purchase_date'])\nnew_trans_df.head()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"c2cf7ddab8510cfe4cfa62a2387d0ce0bb34afab"},"cell_type":"markdown","source":"**1） 新的历史交易数目**"},{"metadata":{"trusted":true,"_uuid":"70c101f5fd618c3a6b02b878799a7eaec9530aec"},"cell_type":"code","source":"gdf = new_trans_df.groupby(\"card_id\")\ngdf = gdf[\"purchase_amount\"].size().reset_index()             # 交易记录数量\ngdf.columns = [\"card_id\", \"num_merch_transactions\"]\ntrain_df = pd.merge(train_df, gdf, on=\"card_id\", how=\"left\")\ntest_df = pd.merge(test_df, gdf, on=\"card_id\", how=\"left\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"06d8af72c64cb80ed3b56ddb4ce92d335f4fec8a"},"cell_type":"code","source":"bins = [0, 10, 20, 30, 40, 50, 75, 10000]\ntrain_df['binned_num_merch_transactions'] = pd.cut(train_df['num_merch_transactions'], bins)\ncnt_srs = train_df.groupby(\"binned_num_merch_transactions\")[target_col].mean()\n\nplt.figure(figsize=(12,8))\nsns.boxplot(x=\"binned_num_merch_transactions\", y=target_col, data=train_df, showfliers=False)\nplt.xticks(rotation='vertical')\nplt.xlabel('binned_num_merch_transactions', fontsize=12)\nplt.ylabel('Loyalty score', fontsize=12)\nplt.title(\"Number of new merchants transaction (Binned) distribution\")\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"1a9e6bcb2d655fd208d93980e539f9b13057ccb2"},"cell_type":"markdown","source":"**整体趋势上，随着新商家交易数量的增加，点击率有所下降，除了最后一个箱子**"},{"metadata":{"_uuid":"c3e96001522450ba6a387b5742d2ae93dae08eae"},"cell_type":"markdown","source":"**2）新的历史交易价值均值、总数、最大值、最小值等**"},{"metadata":{"trusted":true,"_uuid":"467f4db1407de2e2b0a24c72924a18e9a23f09ee"},"cell_type":"code","source":"gdf = new_trans_df.groupby(\"card_id\")\ngdf = gdf[\"purchase_amount\"].agg(['sum', 'mean', 'std', 'min', 'max']).reset_index()\ngdf.columns = [\"card_id\", \"sum_merch_trans\", \"mean_merch_trans\", \"std_merch_trans\", \"min_merch_trans\", \"max_merch_trans\"]\ntrain_df = pd.merge(train_df, gdf, on=\"card_id\", how=\"left\")\ntest_df = pd.merge(test_df, gdf, on=\"card_id\", how=\"left\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"cdf8c4b09259d3d61cc6ddffe1d32c547c777335"},"cell_type":"code","source":"bins = np.nanpercentile(train_df[\"sum_merch_trans\"], range(0,101,10))\ntrain_df['binned_sum_merch_trans'] = pd.cut(train_df['sum_merch_trans'], bins)\n#cnt_srs = train_df.groupby(\"binned_sum_hist_trans\")[target_col].mean()\n\nplt.figure(figsize=(12,8))\nsns.boxplot(x=\"binned_sum_merch_trans\", y=target_col, data=train_df, showfliers=False)\nplt.xticks(rotation='vertical')\nplt.xlabel('binned sum of new merchant transactions', fontsize=12)\nplt.ylabel('Loyalty score', fontsize=12)\nplt.title(\"Sum of New merchants transaction value (Binned) distribution\")\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"4afb08165c5c9d3f2fda57d002ed6fc5ca87c801"},"cell_type":"markdown","source":"**整体趋势上，随着新商家交易价值总和的增加，点击率增加，除了最后一个箱子**"},{"metadata":{"trusted":true,"_uuid":"d78e21e2a18213165af1dda6ca6ffe4882b13bda"},"cell_type":"code","source":"bins = np.nanpercentile(train_df[\"mean_merch_trans\"], range(0,101,10))\ntrain_df['binned_mean_merch_trans'] = pd.cut(train_df['mean_merch_trans'], bins)\n#cnt_srs = train_df.groupby(\"binned_sum_hist_trans\")[target_col].mean()\n\nplt.figure(figsize=(12,8))\nsns.boxplot(x=\"binned_mean_merch_trans\", y=target_col, data=train_df, showfliers=False)\nplt.xticks(rotation='vertical')\nplt.xlabel('binned mean of new merchant transactions', fontsize=12)\nplt.ylabel('Loyalty score', fontsize=12)\nplt.title(\"Mean of New merchants transaction value (Binned) distribution\")\nplt.show()","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"503223029ec38dad842a029e45e5d15b9e789238"},"cell_type":"markdown","source":"**Model**"},{"metadata":{"trusted":true,"_uuid":"50619724dbf380ac05c4906908bd3ba0fccdf35e"},"cell_type":"code","source":"train_df[\"year\"] = train_df[\"first_active_month\"].dt.year\ntest_df[\"year\"] = test_df[\"first_active_month\"].dt.year\ntrain_df[\"month\"] = train_df[\"first_active_month\"].dt.month\ntest_df[\"month\"] = test_df[\"first_active_month\"].dt.month\n\ncols_to_use = [\"feature_1\", \"feature_2\", \"feature_3\", \"year\", \"month\", \n               \"num_hist_transactions\", \"sum_hist_trans\", \"mean_hist_trans\", \"std_hist_trans\", \n               \"min_hist_trans\", \"max_hist_trans\",\n               \"num_merch_transactions\", \"sum_merch_trans\", \"mean_merch_trans\", \"std_merch_trans\",\n               \"min_merch_trans\", \"max_merch_trans\",\n              ]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"188fc222b7afdd0ab2a3a80d85bd5846ba8e4c88"},"cell_type":"code","source":"def run_lgb(train_X, train_y, val_X, val_y, test_X):\n    params = {\n        'boosting_type': 'gbdt',\n        'objective': 'regression',\n        'metric': 'rmse',\n        'num_leaves': 144,\n        'learning_rate': 0.05,\n        'feature_fraction': 0.8,\n        'bagging_fraction': 0.9,\n        'bagging_seed':0,\n        'bagging_freq': 1,\n        'verbose': 1,\n        'reg_alpha':3,\n        'reg_lambda':5\n    }\n    \n    lgtrain = lgb.Dataset(train_X, label=train_y)\n    lgval = lgb.Dataset(val_X, label=val_y)\n    evals_result = {}\n    model = lgb.train(params, lgtrain, 1000, valid_sets=[lgval], early_stopping_rounds=100, verbose_eval=100, evals_result=evals_result)\n    \n    pred_test_y = model.predict(test_X, num_iteration=model.best_iteration)\n    return pred_test_y, model, evals_result","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1453839f9829d709eefde96fc30c30d3893a05e6"},"cell_type":"code","source":"train_X = train_df[cols_to_use]\ntest_X = test_df[cols_to_use]\ntrain_y = train_df[target_col].values\n\npred_test = 0\nkf = model_selection.KFold(n_splits=5, random_state=1000, shuffle=True)\nfor dev_index, val_index in kf.split(train_df):\n    dev_X, val_X = train_X.loc[dev_index,:], train_X.loc[val_index,:]\n    dev_y, val_y = train_y[dev_index], train_y[val_index]\n    \n    pred_test_tmp, model, evals_result = run_lgb(dev_X, dev_y, val_X, val_y, test_X)\n    pred_test += pred_test_tmp\npred_test /= 5.","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9ce1534bd2d6eedf036adfef56006f995353883b"},"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}