├── README.md ├── data ├── results │ ├── result_2017-03-11_model.csv │ ├── result_2017-03-11_special_day_weather_huopot.csv │ ├── result_2017-03-16_.csv │ ├── result_2017-03-16_fuse.csv │ ├── result_2017-03-16_special_day.csv │ ├── result_2017-03-16_special_day_weather.csv │ └── result_2017-03-16_special_day_weather_huopot.csv ├── shop_info_name2Id │ ├── cate_1_name.csv │ ├── cate_2_name.csv │ ├── cate_3_name.csv │ ├── city_name.csv │ ├── shop_info.csv │ └── shop_info_num.csv ├── statistics │ ├── all_mon_week3_mean_med_var_std.csv │ ├── city_weather.csv │ ├── count_user_pay.csv │ ├── count_user_pay_avg.csv │ ├── count_user_pay_avg_no_header.csv │ ├── count_user_view.csv │ ├── result_avg7_common_with_last_week.csv │ ├── shop_info.txt │ ├── shop_info_num.csv │ ├── shopid_day_num.txt │ ├── weather-10-11.csv │ ├── weather-11-14.csv │ └── weather_city.csv ├── test_train │ ├── 2017-03-16_test_off_x.csv │ ├── 2017-03-16_test_off_y.csv │ ├── 2017-03-16_test_on_x.csv │ ├── 2017-03-16_train_off_x.csv │ ├── 2017-03-16_train_off_y.csv │ ├── 2017-03-16_train_on_x.csv │ └── 2017-03-16_train_on_y.csv ├── weekABCD │ ├── A.csv │ ├── B.csv │ ├── C.csv │ ├── D.csv │ ├── week0.csv │ ├── week1.csv │ ├── week2.csv │ ├── week3.csv │ ├── week4.csv │ ├── weekA.csv │ ├── weekA1.csv │ ├── weekA_view.csv │ ├── weekB.csv │ ├── weekB1.csv │ ├── weekB_view.csv │ ├── weekC.csv │ ├── weekC1.csv │ ├── weekC_view.csv │ ├── weekD.csv │ ├── weekD1.csv │ ├── weekD_view.csv │ ├── weekP.csv │ ├── weekP2.csv │ ├── weekZ.csv │ └── weekZ1.csv └── weekABCD_0123 │ ├── A0.csv │ ├── A1.csv │ ├── A2.csv │ ├── A3.csv │ ├── B0.csv │ ├── B1.csv │ ├── B2.csv │ ├── B3.csv │ ├── C0.csv │ ├── C1.csv │ ├── C2.csv │ ├── C3.csv │ ├── D0.csv │ ├── D1.csv │ ├── D2.csv │ └── D3.csv ├── main ├── __init__.py ├── analysis │ ├── analysis_weather.py │ ├── base_als.py │ ├── test_weather.py │ ├── test_week2.py │ ├── testweek.py │ ├── weather │ │ ├── alldata.csv │ │ ├── cat_1.csv │ │ ├── cat_2.csv │ │ ├── cat_3.csv │ │ ├── city.csv │ │ ├── weather_all.csv │ │ └── weather_city.csv │ └── week │ │ ├── last_first_rate.csv │ │ ├── weeks_cnt.txt │ │ └── weektend.csv ├── data_processing │ ├── __init__.py │ ├── __init__.pyc │ ├── avg_smoothing.py │ ├── avg_smoothing.pyc │ ├── run.py │ ├── run.pyc │ ├── smoothing.py │ ├── smoothing.pyc │ ├── split_test_train.py │ └── split_test_train.pyc ├── draw_picture │ └── draw.py ├── fuse │ ├── __init__.py │ ├── __init__.pyc │ ├── fuse.py │ ├── fuse.pyc │ ├── run.py │ └── run.pyc ├── model │ ├── RandomForestRegreessor.py │ ├── RandomForestRegreessor.pyc │ ├── __init__.py │ ├── __init__.pyc │ ├── base_model.py │ ├── base_model.pyc │ ├── gbdt.py │ ├── gbdt.pyc │ ├── multi_mode.py │ ├── old_model │ │ ├── arima_pred.py │ │ ├── arima_test.py │ │ ├── linearmodel.py │ │ ├── prepare.py │ │ ├── product.py │ │ └── test.py │ ├── predict_two_week.py │ ├── run.py │ ├── run.pyc │ ├── unit.py │ ├── unit.pyc │ ├── use_first_week_predict_second_week.py │ └── use_first_week_predict_second_week.pyc └── rule │ ├── __init__.py │ ├── __init__.pyc │ ├── hot_pot.py │ ├── hot_pot.pyc │ ├── run.py │ ├── run.pyc │ ├── special_day.py │ ├── special_day.pyc │ ├── weather.py │ └── weather.pyc ├── notebook ├── Untitled.ipynb ├── als_data.ipynb ├── eye_test.ipynb └── show.ipynb ├── pictures ├── cate_shop_number │ ├── cate_1.csv │ ├── cate_1.png │ ├── cate_2.csv │ ├── cate_2.png │ ├── cate_3.csv │ └── cate_3.png └── city_shop_number │ ├── 0-50.png │ ├── 101-121.png │ ├── 51-100.png │ ├── all.png │ └── city_shop_number.csv └── run.py /README.md: -------------------------------------------------------------------------------- 1 | # 代码说明文档 2 | 队名: 皮皮虾,我们回去吧 3 | 队员: 周杰,欧阳欣, 邓勇 4 | ## 环境需求 5 | ### 运行环境 6 | - python2.7 Anaconda 4.0 7 | - Jupyter notebook 8 | ### 外部依赖库 9 | - numpy 10 | - pandas 11 | - sklearn 12 | - statsmodels 13 | ## 文件 14 | ### data 15 | 16 | 用于存储所有的数据,包括原始数据,额外数据,处理后的数据,模型中间数据以及最后提交的结果。 17 | 18 | #### results 19 | 存储模型和规则预测出的最终结果。 20 | #### shop\_info\_name2Id 21 | 将商店中的地址、三级分类等名词映射成Id保存在该文件夹下。 22 | #### statistics 23 | 原始数据处理后的数据,包括平滑后的数据,天气数据和天气统计。 24 | #### test_train 25 | 存储线下线上train和test的特征以及标签文件。 26 | #### weekABCD 27 | 线下线上训练集和测试集的划分,按日分。 28 | #### weekABCD_0123 29 | 线下线上训练集和测试集的划分(将一天分为四个时间段,没六小时一个时间段)。 30 | 31 | ### main 32 | 主要的数据预处理代码和模型,以及数据分析代码。 33 | #### analysis 34 | 数据分析的代码和统计结果。 35 | 36 | #### data_processing 37 | 数据预处理,包括数据统计,数据预处理,数据平滑,训练集和测试集划分。 38 | - `avg_smoothing.py` 对数据中的0进行处理,遇到0,用前三星期对应值的平均值替换 39 | - `smoothing.py` 处理数据中的异常值 40 | - `split_test_train.py` 数据集训练集和测试集划分 41 | 42 | #### draw_picture 43 | 用于画图的一些基本的函数,方便数据的显示和分析 44 | - `draw.py` 画图 45 | 46 | #### fuse 47 | 模型融合相关文件。 48 | - `fuse.py` 两个模型的结果进行融合,需要运行`run.py`文件来调用。 49 | 50 | #### model 51 | 我们在比赛中所使用过的模型,包括 ARIMA,GBDT,LR,RF,Extremely Randomized Trees等。 52 | - `base_model.py` ExtraTreeRegreessor模型,是我们在比赛线上线下预测中最主要使用的模型。 53 | - `gbdt.py` 基于GBDT模型的简单预测。 54 | - `RandomForestRegreessor.py` 基于随机森林模型的预测。 55 | - `predict_two_week.py` 与之前复制单周预测不同,直接预测两周结果。 56 | - `multi_mode.py` 不同模型,不同特征,不同参数的结合。 57 | - `use_first_week_predict_second_week.py` 在预测第一周的结果后,将第一周的结果用于第二周的预测。 58 | 59 | ##### old model 60 | 该文件夹下主要是比赛初期使用的一些预测模型,在后来被我们放弃使用。 61 | - `mean_test.py` 62 | 均值预测,取最后三周平滑数据对应周期(7)的均值,预测一周销售量,最后输出结果到文件。 63 | - `lr_test.py` LR预测,使用Ridge回归拟合最后三周的每个商铺的总销售量,预测一周的总销售量,最后输出差值到文件。 64 | - `arima_pred.py` 使用了ARIMA模型进行预测,对数据进行对数惩罚,一阶差分后计算ADF值,找到最稳定的差分项。之后用grid search找出拟合效果最好的模型进行预测。我们采用了bic和smape对模型效果进行评估。 65 | 66 | #### rule 67 | 主要使用的规则代码,包括节假日(双十一等),天气处理,火锅店单独处理等,执行`run.py`在指定结果上添加规则影响。 68 | - `special_day.py` 对特定的节假日如11月11日进行处理。 69 | - `weather.py` 根据天气值对预测值进行处理 70 | - `hot_pot.py` 对火锅店进行特殊处理 71 | ### notebook 72 | 为了方便统计数据特征,ARIMA模型结果,可视化结果和特征,我们使用了jupyter notebook来处理和保存含有图片的代码。详见文件夹中具体代码。 73 | ### pictures 74 | 一些统计信息和图片。 -------------------------------------------------------------------------------- /data/shop_info_name2Id/cate_1_name.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/data/shop_info_name2Id/cate_1_name.csv -------------------------------------------------------------------------------- /data/shop_info_name2Id/cate_2_name.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/data/shop_info_name2Id/cate_2_name.csv -------------------------------------------------------------------------------- /data/shop_info_name2Id/cate_3_name.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/data/shop_info_name2Id/cate_3_name.csv -------------------------------------------------------------------------------- /data/shop_info_name2Id/city_name.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/data/shop_info_name2Id/city_name.csv -------------------------------------------------------------------------------- /data/shop_info_name2Id/shop_info.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/data/shop_info_name2Id/shop_info.csv -------------------------------------------------------------------------------- /data/weekABCD_0123/A0.csv: -------------------------------------------------------------------------------- 1 | shop_id,2016-09-20,2016-09-21,2016-09-22,2016-09-23,2016-09-24,2016-09-25,2016-09-26 2 | 1,0,0,0,0,0,0,0 3 | 2,0,0,0,0,0,0,0 4 | 3,0,0,0,0,0,0,0 5 | 4,0,0,0,0,0,0,0 6 | 5,0,0,0,0,0,0,0 7 | 6,0,0,0,0,0,0,0 8 | 7,0,0,0,0,0,0,0 9 | 8,0,0,0,0,0,0,0 10 | 9,0,0,0,0,0,0,0 11 | 10,0,0,0,0,0,0,0 12 | 11,0,0,0,0,0,0,0 13 | 12,0,0,0,0,0,0,0 14 | 13,0,0,0,0,1,0,0 15 | 14,0,0,0,0,0,0,0 16 | 15,0,0,0,0,0,0,0 17 | 16,0,0,0,0,0,0,0 18 | 17,0,5,1,4,4,7,4 19 | 18,0,0,0,0,0,0,0 20 | 19,0,0,0,0,0,0,0 21 | 20,0,0,0,0,0,0,0 22 | 21,0,0,0,0,0,0,0 23 | 22,0,0,0,0,0,0,0 24 | 23,6,2,0,4,6,8,0 25 | 24,0,0,0,0,0,0,0 26 | 25,3,2,3,3,5,3,3 27 | 26,0,0,0,0,0,0,0 28 | 27,0,0,0,0,0,0,0 29 | 28,0,0,0,0,0,0,0 30 | 29,0,0,0,0,0,0,0 31 | 30,1,0,0,1,3,2,2 32 | 31,0,0,0,0,0,0,0 33 | 32,0,1,0,5,4,4,1 34 | 33,0,0,0,0,0,0,0 35 | 34,0,0,0,0,0,0,0 36 | 35,0,0,0,0,0,0,0 37 | 36,0,0,0,0,0,0,0 38 | 37,0,0,0,0,0,0,0 39 | 38,4,2,0,2,3,7,1 40 | 39,0,0,0,0,0,0,0 41 | 40,0,0,0,0,0,0,0 42 | 41,5,1,7,8,11,7,4 43 | 42,0,0,0,0,0,0,0 44 | 43,0,0,0,0,0,0,0 45 | 44,4,11,8,4,0,14,7 46 | 45,0,0,0,0,0,0,0 47 | 46,0,0,0,0,0,0,0 48 | 47,0,5,5,1,2,5,3 49 | 48,0,0,0,0,0,0,0 50 | 49,0,0,0,0,0,0,0 51 | 50,0,0,0,0,0,0,0 52 | 51,0,0,0,0,0,0,0 53 | 52,0,0,0,0,0,0,0 54 | 53,9,7,7,14,12,12,4 55 | 54,0,0,0,0,0,0,0 56 | 55,0,0,0,0,0,0,0 57 | 56,5,1,1,2,2,2,2 58 | 57,0,0,0,0,0,0,0 59 | 58,0,0,0,0,0,0,0 60 | 59,0,0,0,0,0,0,0 61 | 60,0,0,0,0,0,0,0 62 | 61,0,0,0,0,0,0,0 63 | 62,4,3,3,5,1,2,4 64 | 63,0,0,0,0,0,0,0 65 | 64,0,0,0,0,0,0,0 66 | 65,0,0,0,0,0,0,0 67 | 66,0,0,0,0,0,0,0 68 | 67,0,0,0,0,0,0,0 69 | 68,1,0,2,1,0,1,2 70 | 69,8,17,11,14,19,33,17 71 | 70,0,0,0,0,0,0,0 72 | 71,0,0,0,0,0,0,0 73 | 72,0,0,0,0,0,0,0 74 | 73,0,0,0,0,0,0,0 75 | 74,0,0,0,0,0,0,0 76 | 75,0,0,0,0,0,0,0 77 | 76,0,0,0,0,0,0,0 78 | 77,0,0,0,0,0,0,0 79 | 78,0,0,0,0,1,0,0 80 | 79,0,0,0,0,0,0,0 81 | 80,0,0,0,0,0,0,0 82 | 81,0,0,0,0,0,0,0 83 | 82,0,0,0,0,0,0,0 84 | 83,0,0,0,0,0,0,0 85 | 84,0,0,0,0,0,0,0 86 | 85,1,2,3,3,2,4,0 87 | 86,0,0,0,0,0,0,0 88 | 87,0,0,0,0,0,0,0 89 | 88,0,0,0,0,0,0,0 90 | 89,0,0,0,0,0,0,0 91 | 90,0,0,0,0,0,0,0 92 | 91,0,0,0,0,0,0,0 93 | 92,0,0,0,0,0,0,0 94 | 93,0,0,0,0,0,0,0 95 | 94,0,0,0,0,0,0,0 96 | 95,0,0,0,0,0,0,1 97 | 96,0,0,0,0,0,0,0 98 | 97,0,0,0,0,0,0,0 99 | 98,0,0,0,0,0,0,0 100 | 99,0,0,0,0,0,0,0 101 | 100,0,0,0,1,2,3,3 102 | 101,0,0,0,0,0,0,0 103 | 102,0,0,0,0,0,0,0 104 | 103,0,0,0,0,0,0,0 105 | 104,1,7,1,0,3,8,4 106 | 105,0,0,0,0,0,0,0 107 | 106,4,4,2,4,5,9,3 108 | 107,0,0,0,0,0,0,0 109 | 108,0,0,0,0,0,0,0 110 | 109,0,0,0,0,0,0,0 111 | 110,3,3,4,4,7,5,5 112 | 111,0,0,0,0,0,0,0 113 | 112,0,0,0,0,0,0,0 114 | 113,0,0,0,0,0,0,0 115 | 114,0,0,0,0,0,0,0 116 | 115,0,4,1,1,0,1,2 117 | 116,0,0,0,0,0,0,0 118 | 117,0,0,0,0,0,0,0 119 | 118,0,0,0,0,0,0,0 120 | 119,0,0,0,0,0,0,0 121 | 120,0,0,0,0,0,0,0 122 | 121,0,0,0,0,0,0,0 123 | 122,0,0,0,0,0,0,0 124 | 123,0,0,0,0,1,0,0 125 | 124,0,0,0,0,0,0,0 126 | 125,0,0,0,0,0,0,0 127 | 126,0,0,0,0,0,0,0 128 | 127,0,0,0,0,0,0,0 129 | 128,0,0,0,0,0,0,0 130 | 129,0,0,0,0,0,0,0 131 | 130,0,0,0,0,0,0,0 132 | 131,0,0,0,0,0,0,0 133 | 132,0,0,0,0,0,1,0 134 | 133,0,0,0,0,0,0,0 135 | 134,0,0,0,0,0,0,0 136 | 135,0,0,0,0,0,0,0 137 | 136,0,0,0,0,0,0,0 138 | 137,0,0,0,0,0,0,0 139 | 138,0,0,0,0,0,0,0 140 | 139,0,0,0,0,0,0,0 141 | 140,2,1,2,0,2,2,1 142 | 141,0,0,0,0,0,0,0 143 | 142,0,0,1,0,0,0,0 144 | 143,0,0,0,0,0,0,0 145 | 144,0,0,0,0,0,0,0 146 | 145,3,3,4,5,3,6,4 147 | 146,0,0,0,0,0,0,0 148 | 147,5,7,9,5,8,3,3 149 | 148,3,1,3,0,4,6,6 150 | 149,1,0,3,3,4,3,1 151 | 150,0,0,0,0,0,0,0 152 | 151,0,0,0,0,0,0,0 153 | 152,0,0,0,0,0,0,0 154 | 153,0,0,0,0,0,0,0 155 | 154,0,0,0,0,0,0,0 156 | 155,0,0,0,0,0,0,0 157 | 156,0,0,0,0,0,0,0 158 | 157,3,0,2,0,0,1,1 159 | 158,1,2,0,1,4,0,0 160 | 159,0,0,0,0,0,0,0 161 | 160,4,1,2,5,2,11,3 162 | 161,0,0,0,0,0,0,0 163 | 162,3,6,0,3,7,1,6 164 | 163,0,0,0,0,0,0,0 165 | 164,0,0,0,0,0,0,0 166 | 165,0,0,0,0,0,0,0 167 | 166,0,0,0,0,0,0,0 168 | 167,0,0,0,0,0,0,0 169 | 168,0,0,0,0,0,0,0 170 | 169,0,0,0,0,0,0,0 171 | 170,0,0,0,0,0,0,0 172 | 171,0,0,0,0,0,0,0 173 | 172,0,0,0,0,0,0,0 174 | 173,0,0,0,0,0,0,0 175 | 174,0,0,0,0,0,0,0 176 | 175,0,0,0,0,0,0,0 177 | 176,0,0,0,0,0,0,0 178 | 177,0,0,0,0,0,0,0 179 | 178,0,0,0,0,0,0,0 180 | 179,0,0,0,0,0,1,0 181 | 180,0,0,0,0,0,0,0 182 | 181,3,0,1,2,1,1,1 183 | 182,1,5,4,2,1,0,2 184 | 183,0,0,0,0,0,0,0 185 | 184,0,0,0,0,0,0,0 186 | 185,0,0,0,0,0,0,0 187 | 186,3,0,1,0,4,3,1 188 | 187,0,0,2,4,0,2,3 189 | 188,0,0,0,0,0,0,0 190 | 189,0,0,0,0,0,0,0 191 | 190,0,0,0,0,0,0,0 192 | 191,0,0,0,0,0,0,0 193 | 192,0,0,0,0,0,0,0 194 | 193,0,0,0,0,0,0,0 195 | 194,0,0,0,0,0,0,0 196 | 195,0,0,0,0,0,0,0 197 | 196,0,0,0,0,0,0,0 198 | 197,0,0,0,0,0,0,0 199 | 198,0,0,0,0,0,0,0 200 | 199,0,0,0,0,0,0,0 201 | 200,0,0,0,0,0,0,0 202 | 201,0,0,0,0,0,0,0 203 | 202,0,0,0,0,0,0,0 204 | 203,0,0,0,0,0,0,0 205 | 204,0,0,1,4,3,6,4 206 | 205,0,0,0,0,0,0,0 207 | 206,0,0,0,0,0,0,0 208 | 207,0,0,0,0,0,0,0 209 | 208,0,0,0,0,0,0,0 210 | 209,0,0,0,0,0,0,0 211 | 210,0,0,0,0,0,0,0 212 | 211,8,0,5,3,6,5,0 213 | 212,0,0,0,0,0,0,0 214 | 213,0,0,0,0,0,0,0 215 | 214,0,0,0,0,0,0,0 216 | 215,0,0,0,0,0,0,0 217 | 216,0,0,0,0,0,0,0 218 | 217,0,0,0,0,0,0,0 219 | 218,0,0,0,0,0,0,0 220 | 219,0,3,0,0,1,0,0 221 | 220,0,0,0,0,0,0,0 222 | 221,0,0,0,0,0,0,0 223 | 222,0,0,2,1,0,1,2 224 | 223,2,5,4,2,5,2,3 225 | 224,0,0,0,0,0,0,0 226 | 225,0,0,0,0,0,0,0 227 | 226,1,0,0,4,1,1,0 228 | 227,0,0,0,0,0,0,0 229 | 228,0,0,0,0,0,0,0 230 | 229,5,9,4,5,7,8,4 231 | 230,0,0,0,0,0,0,0 232 | 231,0,0,0,0,0,0,0 233 | 232,4,12,6,4,7,8,5 234 | 233,0,0,0,0,0,0,0 235 | 234,0,0,0,0,0,0,0 236 | 235,0,0,0,0,0,0,0 237 | 236,0,0,0,0,0,0,0 238 | 237,0,0,0,0,0,0,0 239 | 238,0,0,0,0,0,0,0 240 | 239,0,0,0,0,0,0,0 241 | 240,3,7,2,3,8,6,4 242 | 241,0,0,0,0,0,0,0 243 | 242,0,0,0,0,0,0,0 244 | 243,0,0,0,0,0,0,0 245 | 244,0,0,0,0,1,3,0 246 | 245,0,0,0,0,0,0,0 247 | 246,0,0,0,0,0,0,0 248 | 247,0,0,0,0,0,1,0 249 | 248,0,0,0,0,0,0,0 250 | 249,0,0,0,0,0,0,0 251 | 250,0,0,0,0,0,0,0 252 | 251,0,0,0,0,0,0,0 253 | 252,3,3,8,3,12,6,5 254 | 253,0,0,0,0,0,0,0 255 | 254,0,0,0,0,0,0,0 256 | 255,0,0,0,0,0,0,0 257 | 256,0,0,0,0,0,0,0 258 | 257,3,0,2,3,3,4,1 259 | 258,2,2,2,9,0,8,5 260 | 259,0,0,0,0,0,0,0 261 | 260,2,4,11,2,4,2,3 262 | 261,0,0,0,0,0,0,0 263 | 262,0,0,0,0,0,0,0 264 | 263,0,0,0,0,0,0,0 265 | 264,3,0,4,0,3,7,0 266 | 265,0,0,0,0,0,0,0 267 | 266,0,0,0,0,0,0,0 268 | 267,1,0,0,0,0,0,0 269 | 268,4,2,4,10,22,21,10 270 | 269,0,0,0,0,0,0,0 271 | 270,3,4,1,1,9,1,4 272 | 271,0,0,0,0,0,0,0 273 | 272,0,5,0,0,0,7,1 274 | 273,0,0,0,0,0,0,0 275 | 274,0,0,0,0,0,0,0 276 | 275,0,0,0,0,0,0,0 277 | 276,0,0,0,0,0,0,0 278 | 277,0,0,0,0,0,0,0 279 | 278,0,0,0,0,0,0,0 280 | 279,0,0,0,0,0,0,0 281 | 280,0,0,0,0,0,0,0 282 | 281,10,2,6,1,2,5,2 283 | 282,9,9,11,10,11,12,10 284 | 283,0,0,0,0,0,0,0 285 | 284,0,0,0,0,0,0,0 286 | 285,0,0,0,0,0,0,0 287 | 286,0,0,0,0,0,0,0 288 | 287,4,2,4,5,8,2,7 289 | 288,0,0,0,0,0,0,0 290 | 289,0,0,0,0,0,0,0 291 | 290,2,3,11,5,6,6,7 292 | 291,0,0,0,0,0,0,0 293 | 292,3,4,2,3,6,7,8 294 | 293,0,0,0,0,0,0,0 295 | 294,0,0,0,0,0,0,0 296 | 295,0,0,0,0,0,0,0 297 | 296,0,0,0,0,0,0,0 298 | 297,0,0,0,0,0,0,0 299 | 298,0,0,0,0,0,0,0 300 | 299,0,0,0,0,0,0,0 301 | 300,0,0,0,0,0,0,0 302 | 301,1,0,4,4,1,0,3 303 | 302,0,0,0,0,0,0,0 304 | 303,0,0,0,0,0,0,0 305 | 304,1,0,0,0,1,0,0 306 | 305,7,2,7,3,9,7,8 307 | 306,0,0,0,0,0,0,0 308 | 307,0,0,0,0,0,0,0 309 | 308,0,0,0,0,0,0,0 310 | 309,0,0,0,0,0,0,0 311 | 310,0,0,0,0,0,0,0 312 | 311,0,0,0,0,0,0,0 313 | 312,0,0,0,0,0,0,0 314 | 313,0,0,0,0,0,0,0 315 | 314,8,10,5,7,11,32,18 316 | 315,4,8,5,1,8,3,5 317 | 316,0,0,0,0,0,0,0 318 | 317,0,0,0,0,0,0,0 319 | 318,0,0,0,0,0,0,0 320 | 319,0,0,2,0,4,0,1 321 | 320,2,3,9,2,4,8,7 322 | 321,0,0,0,0,0,0,0 323 | 322,3,2,3,1,3,3,1 324 | 323,0,0,0,0,0,0,0 325 | 324,0,0,0,0,0,0,0 326 | 325,2,1,1,2,2,1,1 327 | 326,0,0,0,0,0,0,0 328 | 327,0,0,0,0,0,0,0 329 | 328,0,0,0,0,0,0,0 330 | 329,4,4,8,2,4,18,3 331 | 330,0,0,0,0,0,0,0 332 | 331,0,0,0,0,0,0,0 333 | 332,0,0,0,0,0,0,0 334 | 333,0,0,0,0,0,0,0 335 | 334,0,0,0,0,0,0,0 336 | 335,0,0,0,0,0,0,0 337 | 336,0,0,0,0,0,0,0 338 | 337,9,4,3,4,4,7,5 339 | 338,0,0,0,0,0,0,0 340 | 339,0,0,0,0,0,0,0 341 | 340,0,0,0,0,1,2,0 342 | 341,0,0,0,0,0,0,0 343 | 342,0,0,0,0,0,0,0 344 | 343,0,6,3,2,4,6,0 345 | 344,10,16,3,9,10,11,8 346 | 345,5,15,6,7,10,4,4 347 | 346,29,24,38,23,32,49,35 348 | 347,1,0,0,4,5,1,4 349 | 348,0,0,0,0,0,0,0 350 | 349,0,0,0,0,0,0,0 351 | 350,0,4,3,3,5,3,0 352 | 351,0,0,0,0,0,0,0 353 | 352,0,0,0,0,0,0,0 354 | 353,0,0,0,0,0,0,0 355 | 354,0,0,0,0,0,0,0 356 | 355,0,0,0,0,0,0,0 357 | 356,9,15,1,7,9,4,4 358 | 357,0,0,1,0,0,0,0 359 | 358,2,3,2,4,1,5,3 360 | 359,6,6,5,9,7,15,6 361 | 360,0,0,0,0,0,0,0 362 | 361,0,0,0,0,0,0,0 363 | 362,7,9,7,10,11,11,6 364 | 363,0,0,0,0,0,0,0 365 | 364,0,0,0,0,0,0,0 366 | 365,2,0,4,4,11,6,3 367 | 366,0,0,0,0,0,0,0 368 | 367,0,0,0,0,0,0,0 369 | 368,0,2,2,0,0,0,1 370 | 369,0,5,5,4,8,3,7 371 | 370,0,0,0,0,0,0,0 372 | 371,0,0,0,0,0,0,0 373 | 372,0,0,0,0,0,0,0 374 | 373,0,0,0,0,0,0,0 375 | 374,0,0,0,0,0,0,0 376 | 375,0,0,0,0,0,0,0 377 | 376,0,0,0,0,0,0,0 378 | 377,6,6,3,8,12,9,3 379 | 378,0,1,0,2,0,0,0 380 | 379,0,0,0,0,0,0,0 381 | 380,13,8,5,6,12,12,3 382 | 381,0,0,0,0,0,0,0 383 | 382,0,0,0,0,0,0,0 384 | 383,0,0,0,0,0,0,0 385 | 384,0,0,0,0,0,0,0 386 | 385,0,0,0,0,0,0,0 387 | 386,0,1,0,0,0,0,1 388 | 387,0,0,0,0,0,0,0 389 | 388,0,0,0,0,0,0,0 390 | 389,0,0,0,0,0,0,0 391 | 390,0,0,0,0,0,0,0 392 | 391,0,0,0,0,0,0,0 393 | 392,6,2,2,7,10,8,3 394 | 393,0,0,0,0,0,0,0 395 | 394,0,0,0,0,0,0,0 396 | 395,0,0,0,0,0,0,0 397 | 396,0,0,0,0,0,0,0 398 | 397,0,0,0,0,0,0,0 399 | 398,0,0,0,0,0,0,0 400 | 399,0,0,0,0,0,0,0 401 | 400,0,0,0,0,0,0,0 402 | 401,0,0,0,0,0,0,0 403 | 402,0,0,0,0,0,0,0 404 | 403,0,0,0,0,0,0,0 405 | 404,0,0,0,0,0,0,0 406 | 405,1,7,2,2,1,2,6 407 | 406,0,0,0,0,0,0,0 408 | 407,0,0,0,0,0,0,0 409 | 408,0,0,0,0,0,0,0 410 | 409,0,0,0,0,0,0,0 411 | 410,0,0,0,0,0,0,0 412 | 411,0,0,0,0,0,0,0 413 | 412,0,0,0,0,0,0,0 414 | 413,5,7,5,7,12,7,4 415 | 414,0,0,0,0,0,0,0 416 | 415,0,0,0,0,0,0,0 417 | 416,0,0,0,0,0,0,0 418 | 417,0,0,0,0,0,0,0 419 | 418,2,4,2,5,7,3,0 420 | 419,1,2,44,53,80,10,54 421 | 420,3,0,5,3,8,5,7 422 | 421,0,0,0,0,0,0,0 423 | 422,0,0,0,0,0,0,0 424 | 423,0,0,0,0,0,0,0 425 | 424,0,0,0,0,0,0,0 426 | 425,0,0,0,0,0,0,0 427 | 426,14,14,16,21,15,5,10 428 | 427,0,0,0,0,0,0,0 429 | 428,0,0,0,0,0,0,0 430 | 429,0,0,0,0,0,0,0 431 | 430,10,16,25,19,14,14,15 432 | 431,5,0,0,0,0,6,2 433 | 432,0,0,0,0,0,0,0 434 | 433,0,0,0,0,0,0,0 435 | 434,0,0,0,0,0,0,0 436 | 435,0,0,0,0,0,0,0 437 | 436,0,5,8,10,16,12,4 438 | 437,0,0,0,0,0,0,0 439 | 438,7,7,16,16,8,11,10 440 | 439,0,0,0,0,0,0,0 441 | 440,0,1,1,0,0,0,1 442 | 441,0,0,0,0,0,0,0 443 | 442,0,0,0,0,0,0,0 444 | 443,0,0,0,0,0,0,0 445 | 444,0,0,0,0,0,0,0 446 | 445,15,21,25,24,30,50,19 447 | 446,0,0,0,0,0,0,0 448 | 447,0,0,0,0,0,0,0 449 | 448,2,4,4,3,1,4,3 450 | 449,0,0,0,0,0,0,0 451 | 450,0,0,0,0,0,0,0 452 | 451,18,15,13,12,11,19,17 453 | 452,0,0,0,0,0,0,0 454 | 453,0,0,0,0,0,0,0 455 | 454,0,0,0,0,0,0,0 456 | 455,0,0,0,0,0,0,0 457 | 456,1,1,0,2,2,5,8 458 | 457,0,0,0,0,0,0,0 459 | 458,2,1,3,5,6,7,6 460 | 459,0,0,0,0,0,0,0 461 | 460,0,0,0,0,0,0,0 462 | 461,0,0,0,0,0,0,0 463 | 462,0,0,0,0,0,0,0 464 | 463,0,0,0,0,0,0,0 465 | 464,0,0,0,0,0,0,0 466 | 465,0,0,0,0,0,0,0 467 | 466,0,0,0,0,0,0,0 468 | 467,0,0,0,0,0,0,0 469 | 468,1,3,2,3,3,8,4 470 | 469,0,0,0,0,0,0,0 471 | 470,0,0,0,0,0,0,0 472 | 471,0,0,0,0,0,0,0 473 | 472,11,4,13,8,23,22,7 474 | 473,0,0,0,0,0,0,0 475 | 474,0,0,0,0,0,1,1 476 | 475,0,0,0,0,0,0,0 477 | 476,0,0,0,0,0,0,0 478 | 477,0,0,0,0,0,0,0 479 | 478,1,0,0,0,0,1,0 480 | 479,0,0,0,0,0,0,0 481 | 480,0,0,0,0,0,0,0 482 | 481,0,0,0,0,0,0,0 483 | 482,0,0,0,0,0,0,0 484 | 483,3,7,2,4,4,5,2 485 | 484,0,0,0,0,0,0,0 486 | 485,0,0,0,0,0,0,0 487 | 486,1,1,0,3,1,0,1 488 | 487,0,0,0,0,0,0,0 489 | 488,0,0,0,0,0,0,0 490 | 489,3,10,5,11,8,10,6 491 | 490,0,0,0,0,0,0,0 492 | 491,0,0,0,0,0,0,0 493 | 492,0,0,0,0,0,0,0 494 | 493,4,6,1,2,9,4,2 495 | 494,0,0,0,0,1,0,0 496 | 495,0,0,0,0,0,0,0 497 | 496,0,0,0,0,0,0,0 498 | 497,0,0,0,0,0,0,0 499 | 498,0,0,0,0,0,0,0 500 | 499,1,0,2,1,0,0,3 501 | 500,0,0,0,0,0,0,0 502 | 501,0,0,0,0,0,0,0 503 | 502,0,0,0,0,0,0,0 504 | 503,0,0,0,0,0,0,0 505 | 504,8,5,6,0,10,5,3 506 | 505,0,0,0,0,0,0,0 507 | 506,0,0,0,0,0,0,0 508 | 507,0,0,0,0,0,0,0 509 | 508,6,1,6,3,9,6,1 510 | 509,0,0,0,0,0,0,0 511 | 510,10,5,6,7,11,9,5 512 | 511,0,0,0,0,0,0,0 513 | 512,0,0,0,0,0,0,0 514 | 513,0,0,0,0,0,0,0 515 | 514,0,0,0,0,0,0,0 516 | 515,8,13,13,10,20,14,8 517 | 516,0,0,0,1,0,1,0 518 | 517,0,0,0,0,0,0,0 519 | 518,0,0,0,0,0,0,0 520 | 519,0,0,0,0,0,0,0 521 | 520,0,0,0,0,0,0,0 522 | 521,0,0,0,0,0,0,0 523 | 522,0,0,0,0,0,0,0 524 | 523,0,0,0,0,0,0,0 525 | 524,0,0,0,0,0,0,0 526 | 525,0,0,0,0,0,0,0 527 | 526,5,2,5,0,5,7,5 528 | 527,0,0,0,0,0,0,0 529 | 528,0,0,0,0,0,0,0 530 | 529,0,0,0,0,0,0,0 531 | 530,0,0,0,0,0,0,0 532 | 531,5,8,5,11,6,6,4 533 | 532,0,0,0,0,0,0,0 534 | 533,0,5,2,2,4,5,10 535 | 534,0,0,0,0,0,0,0 536 | 535,0,0,0,0,0,0,0 537 | 536,0,0,0,0,0,0,0 538 | 537,0,0,0,0,0,0,0 539 | 538,0,0,0,0,0,0,0 540 | 539,3,6,2,5,2,8,1 541 | 540,0,0,0,0,0,0,0 542 | 541,0,0,0,0,0,0,0 543 | 542,0,0,0,0,0,0,0 544 | 543,0,0,0,0,0,0,0 545 | 544,0,0,0,0,0,0,0 546 | 545,0,0,0,0,0,0,0 547 | 546,0,0,0,0,0,0,0 548 | 547,0,1,0,0,0,0,0 549 | 548,0,0,0,0,0,0,0 550 | 549,0,0,0,0,0,0,0 551 | 550,0,0,1,0,0,0,1 552 | 551,0,0,0,0,0,0,0 553 | 552,0,0,0,0,0,0,0 554 | 553,0,0,0,0,0,0,0 555 | 554,0,0,0,0,0,0,0 556 | 555,0,0,0,0,0,0,0 557 | 556,0,0,0,0,0,0,0 558 | 557,6,3,10,3,1,4,6 559 | 558,0,0,0,0,0,0,0 560 | 559,0,0,0,0,0,0,0 561 | 560,0,0,0,0,0,0,0 562 | 561,0,0,0,0,0,0,0 563 | 562,0,0,0,0,0,0,0 564 | 563,0,1,2,3,4,1,1 565 | 564,0,0,0,0,0,0,0 566 | 565,0,0,0,0,0,0,0 567 | 566,0,2,3,1,2,7,3 568 | 567,2,0,1,2,2,2,2 569 | 568,0,0,0,0,0,0,0 570 | 569,0,0,0,0,0,0,0 571 | 570,0,8,10,6,5,10,9 572 | 571,0,0,0,0,0,0,0 573 | 572,0,0,0,0,0,0,0 574 | 573,4,4,1,2,2,3,0 575 | 574,0,0,0,0,0,0,0 576 | 575,0,0,0,0,0,0,0 577 | 576,1,1,0,1,1,1,2 578 | 577,0,0,0,0,0,0,0 579 | 578,5,7,6,4,16,13,6 580 | 579,0,0,0,0,0,0,0 581 | 580,0,0,0,0,0,0,0 582 | 581,1,3,1,1,1,0,0 583 | 582,0,0,0,0,0,0,0 584 | 583,0,0,0,0,0,0,0 585 | 584,0,0,0,0,0,0,0 586 | 585,0,0,0,0,0,0,0 587 | 586,0,0,0,0,0,0,0 588 | 587,0,0,0,0,0,0,0 589 | 588,0,0,0,0,0,0,0 590 | 589,1,0,0,1,1,2,1 591 | 590,0,0,0,0,0,0,0 592 | 591,0,2,0,0,1,0,0 593 | 592,0,0,0,0,0,0,0 594 | 593,0,0,0,0,0,0,0 595 | 594,0,0,0,0,0,0,0 596 | 595,0,0,0,1,0,0,0 597 | 596,1,0,1,4,5,2,2 598 | 597,0,0,0,0,0,0,0 599 | 598,5,3,1,3,5,6,2 600 | 599,0,0,0,0,0,0,0 601 | 600,0,0,0,0,0,0,0 602 | 601,0,0,0,0,0,0,0 603 | 602,0,0,0,0,0,0,0 604 | 603,5,7,0,0,0,0,0 605 | 604,0,0,0,0,0,0,0 606 | 605,0,0,0,0,0,0,0 607 | 606,0,0,0,0,0,0,0 608 | 607,0,0,0,0,0,0,0 609 | 608,0,0,0,0,0,0,0 610 | 609,0,0,0,0,0,0,0 611 | 610,5,2,3,2,2,2,2 612 | 611,0,0,0,0,0,0,0 613 | 612,0,0,0,0,0,0,0 614 | 613,0,0,0,0,0,0,0 615 | 614,0,0,0,0,0,0,0 616 | 615,0,0,0,0,0,0,0 617 | 616,10,8,11,9,10,15,12 618 | 617,0,0,0,0,0,0,0 619 | 618,6,15,5,6,9,4,5 620 | 619,18,19,17,23,35,41,14 621 | 620,0,0,0,0,0,0,0 622 | 621,0,0,0,0,0,0,0 623 | 622,0,0,0,0,0,0,0 624 | 623,0,0,0,0,0,0,0 625 | 624,0,0,0,0,0,0,0 626 | 625,0,0,0,0,0,0,0 627 | 626,0,0,0,0,0,0,0 628 | 627,4,2,1,6,2,4,2 629 | 628,1,0,0,0,0,3,0 630 | 629,0,0,0,0,0,0,0 631 | 630,0,0,0,0,0,0,0 632 | 631,3,13,5,11,15,12,10 633 | 632,0,1,0,1,0,1,0 634 | 633,0,0,0,0,0,0,0 635 | 634,0,0,0,0,0,0,0 636 | 635,0,0,0,0,0,0,0 637 | 636,0,0,0,0,0,0,0 638 | 637,0,0,0,0,0,0,0 639 | 638,0,0,0,0,0,0,0 640 | 639,0,0,0,0,0,0,0 641 | 640,0,0,0,0,0,0,0 642 | 641,4,4,8,4,3,4,6 643 | 642,4,6,6,4,5,7,5 644 | 643,14,10,10,12,23,15,15 645 | 644,0,0,0,2,0,3,0 646 | 645,8,10,6,7,9,12,10 647 | 646,0,0,0,0,0,0,0 648 | 647,0,0,0,0,0,0,0 649 | 648,0,0,0,0,0,0,0 650 | 649,2,2,0,0,0,0,0 651 | 650,0,0,0,0,0,0,0 652 | 651,0,0,0,0,0,0,0 653 | 652,0,0,0,0,0,0,0 654 | 653,12,14,9,11,15,11,12 655 | 654,0,0,0,0,0,0,0 656 | 655,8,4,2,2,7,4,6 657 | 656,0,0,0,0,0,0,0 658 | 657,4,1,1,3,4,4,5 659 | 658,0,0,0,0,0,0,0 660 | 659,0,0,0,0,0,0,0 661 | 660,0,1,1,0,0,0,0 662 | 661,0,0,0,0,0,0,0 663 | 662,0,0,0,0,0,0,0 664 | 663,0,0,0,0,0,0,0 665 | 664,0,0,0,0,0,0,0 666 | 665,0,0,0,0,0,0,0 667 | 666,0,0,0,0,0,0,0 668 | 667,0,2,2,1,0,1,0 669 | 668,0,0,0,0,0,0,0 670 | 669,0,0,0,0,0,0,0 671 | 670,4,8,5,7,15,6,4 672 | 671,0,0,0,0,0,0,0 673 | 672,0,0,0,0,0,0,0 674 | 673,0,0,0,0,0,0,0 675 | 674,0,0,0,0,0,0,0 676 | 675,2,4,2,4,4,5,2 677 | 676,4,1,1,0,7,8,6 678 | 677,0,0,0,0,0,0,0 679 | 678,5,1,5,8,3,4,5 680 | 679,0,0,0,0,0,0,0 681 | 680,0,0,0,0,0,0,0 682 | 681,0,3,0,0,5,1,1 683 | 682,0,0,0,0,0,0,0 684 | 683,0,0,0,0,0,0,0 685 | 684,0,2,0,1,0,0,0 686 | 685,0,0,0,0,0,0,0 687 | 686,0,0,0,0,0,0,0 688 | 687,0,0,0,0,0,0,0 689 | 688,2,3,2,2,0,1,1 690 | 689,0,0,0,0,0,0,0 691 | 690,0,0,0,0,0,0,0 692 | 691,0,0,0,0,0,0,0 693 | 692,4,11,13,9,11,11,8 694 | 693,0,0,0,0,0,0,0 695 | 694,0,0,0,0,0,0,0 696 | 695,0,0,0,0,0,0,0 697 | 696,0,0,0,0,0,0,0 698 | 697,0,0,1,1,0,1,0 699 | 698,0,0,0,0,0,0,0 700 | 699,0,0,0,0,0,0,0 701 | 700,0,0,0,0,0,0,0 702 | 701,0,0,0,0,0,0,0 703 | 702,0,0,0,0,0,0,1 704 | 703,0,0,0,0,0,0,0 705 | 704,0,0,0,0,0,0,0 706 | 705,0,0,0,0,0,0,0 707 | 706,0,0,0,0,0,0,0 708 | 707,0,0,0,0,0,0,0 709 | 708,0,0,0,0,0,0,0 710 | 709,0,0,0,0,0,0,0 711 | 710,0,2,2,4,3,2,4 712 | 711,0,0,0,0,0,0,0 713 | 712,0,0,0,0,0,0,0 714 | 713,4,1,5,4,4,6,4 715 | 714,0,0,0,0,0,0,0 716 | 715,0,0,0,0,0,0,0 717 | 716,0,0,0,0,0,0,0 718 | 717,0,0,0,0,0,0,0 719 | 718,0,0,0,1,2,2,0 720 | 719,0,0,0,0,0,0,0 721 | 720,7,11,9,6,11,14,7 722 | 721,0,0,0,0,0,0,0 723 | 722,0,0,0,0,0,0,0 724 | 723,0,0,0,0,0,0,0 725 | 724,2,1,1,0,2,0,3 726 | 725,0,0,0,0,0,0,0 727 | 726,0,0,0,0,0,0,0 728 | 727,11,21,10,28,38,41,16 729 | 728,0,0,0,0,0,0,0 730 | 729,7,5,5,4,2,1,5 731 | 730,0,0,0,0,0,0,0 732 | 731,3,0,5,6,5,6,3 733 | 732,0,0,0,0,0,0,0 734 | 733,0,0,2,0,1,3,0 735 | 734,0,0,0,0,0,0,0 736 | 735,5,1,13,3,7,5,7 737 | 736,0,0,0,0,0,0,0 738 | 737,6,6,6,3,6,9,3 739 | 738,0,0,0,0,0,0,0 740 | 739,0,0,0,0,0,0,0 741 | 740,0,0,0,0,0,0,0 742 | 741,0,0,0,0,0,0,0 743 | 742,0,0,0,0,0,0,0 744 | 743,1,5,6,3,2,1,2 745 | 744,0,0,0,0,0,0,0 746 | 745,0,0,0,0,0,0,0 747 | 746,9,2,2,7,9,1,3 748 | 747,0,0,0,0,0,0,0 749 | 748,0,0,0,0,0,0,0 750 | 749,2,1,4,0,0,2,0 751 | 750,4,4,0,3,3,3,4 752 | 751,0,0,0,0,0,0,0 753 | 752,0,0,0,0,0,0,0 754 | 753,0,0,0,0,0,0,0 755 | 754,0,0,0,0,0,0,0 756 | 755,0,0,0,0,0,0,0 757 | 756,0,0,0,0,0,0,0 758 | 757,0,0,0,0,0,0,0 759 | 758,0,0,0,0,0,0,0 760 | 759,0,0,0,0,0,0,0 761 | 760,0,0,0,0,0,0,0 762 | 761,0,0,0,0,0,0,0 763 | 762,0,0,0,0,0,0,0 764 | 763,0,0,0,0,0,0,0 765 | 764,0,0,0,0,0,0,0 766 | 765,0,0,0,0,0,0,0 767 | 766,0,0,0,0,0,0,0 768 | 767,2,4,0,5,2,3,2 769 | 768,0,0,0,0,0,0,0 770 | 769,0,0,0,0,0,0,0 771 | 770,0,0,0,0,0,0,0 772 | 771,8,0,4,0,6,2,2 773 | 772,0,0,0,0,0,0,0 774 | 773,4,3,14,7,8,9,8 775 | 774,0,0,0,0,0,0,0 776 | 775,2,2,2,6,5,6,11 777 | 776,0,0,0,0,0,0,0 778 | 777,0,2,0,0,0,0,1 779 | 778,0,0,0,0,0,0,0 780 | 779,0,0,0,0,0,0,0 781 | 780,13,10,14,13,11,21,26 782 | 781,0,0,0,0,0,0,0 783 | 782,6,3,8,1,2,3,4 784 | 783,0,0,0,0,0,0,0 785 | 784,0,5,3,2,0,6,0 786 | 785,10,10,8,8,17,15,17 787 | 786,0,2,1,0,2,2,0 788 | 787,0,0,0,0,0,0,0 789 | 788,0,0,0,0,1,1,0 790 | 789,0,0,0,0,0,0,0 791 | 790,0,0,0,0,0,0,0 792 | 791,3,1,0,1,4,2,4 793 | 792,3,5,2,5,7,7,9 794 | 793,0,0,0,0,0,0,0 795 | 794,0,0,0,0,0,0,0 796 | 795,0,0,0,0,0,0,0 797 | 796,0,0,0,0,0,0,0 798 | 797,4,2,1,8,3,2,1 799 | 798,0,0,0,0,0,0,0 800 | 799,14,6,10,9,10,10,7 801 | 800,0,0,0,0,0,0,0 802 | 801,0,0,0,0,0,0,0 803 | 802,0,0,0,0,0,0,0 804 | 803,0,0,0,0,0,0,0 805 | 804,0,0,0,0,0,0,0 806 | 805,3,8,13,12,8,6,6 807 | 806,0,0,0,0,0,0,0 808 | 807,0,0,0,0,0,0,0 809 | 808,16,9,7,2,15,14,13 810 | 809,0,0,0,0,0,0,0 811 | 810,0,0,0,0,0,0,0 812 | 811,0,0,0,0,0,0,0 813 | 812,0,0,0,0,0,0,0 814 | 813,0,0,0,0,0,0,0 815 | 814,17,12,21,11,15,22,15 816 | 815,0,0,0,0,0,0,0 817 | 816,0,0,0,0,0,0,0 818 | 817,0,0,0,0,0,0,0 819 | 818,0,0,0,0,0,0,0 820 | 819,0,0,0,0,0,2,0 821 | 820,0,0,0,0,0,0,0 822 | 821,0,0,0,0,0,0,0 823 | 822,0,0,0,0,0,0,0 824 | 823,0,0,0,0,0,0,0 825 | 824,0,0,0,0,0,0,0 826 | 825,0,0,0,0,0,0,0 827 | 826,0,0,0,0,0,0,0 828 | 827,0,0,1,3,0,3,0 829 | 828,0,0,0,0,0,0,0 830 | 829,0,0,1,0,0,0,0 831 | 830,3,1,1,1,0,0,0 832 | 831,0,0,0,0,0,0,0 833 | 832,2,4,2,2,7,0,3 834 | 833,0,0,0,0,0,0,0 835 | 834,0,0,0,0,0,0,0 836 | 835,0,0,0,0,0,0,0 837 | 836,0,0,0,0,0,0,0 838 | 837,0,0,0,0,0,0,0 839 | 838,11,14,15,5,14,14,20 840 | 839,0,0,0,0,0,0,0 841 | 840,0,0,2,0,0,0,0 842 | 841,0,0,0,0,0,0,1 843 | 842,0,0,0,0,0,0,0 844 | 843,0,0,0,0,0,0,0 845 | 844,0,0,0,0,0,0,0 846 | 845,0,0,0,0,0,0,0 847 | 846,0,0,0,0,0,0,0 848 | 847,0,0,0,0,0,0,0 849 | 848,0,0,0,0,0,0,0 850 | 849,0,0,0,0,0,0,0 851 | 850,0,0,0,0,0,0,0 852 | 851,0,0,0,0,0,0,0 853 | 852,0,0,0,0,0,0,0 854 | 853,0,0,0,0,0,0,0 855 | 854,0,0,0,0,0,0,0 856 | 855,0,0,0,0,0,0,0 857 | 856,4,6,2,4,5,3,1 858 | 857,0,0,0,0,0,0,0 859 | 858,0,0,0,0,0,0,0 860 | 859,0,0,0,0,0,0,0 861 | 860,0,0,0,0,0,0,0 862 | 861,0,0,0,0,0,0,0 863 | 862,0,0,0,0,0,0,0 864 | 863,0,0,0,0,0,0,0 865 | 864,0,0,0,0,0,0,0 866 | 865,0,0,0,0,0,0,0 867 | 866,0,0,0,0,0,0,0 868 | 867,0,1,0,0,1,0,0 869 | 868,0,0,0,0,0,0,0 870 | 869,0,0,0,0,0,0,0 871 | 870,0,0,0,0,0,0,0 872 | 871,0,0,0,0,0,0,0 873 | 872,0,0,0,0,0,0,0 874 | 873,0,0,0,0,0,0,0 875 | 874,3,5,2,3,3,5,3 876 | 875,4,0,2,0,8,2,1 877 | 876,0,0,0,0,0,0,0 878 | 877,0,0,0,0,0,0,0 879 | 878,0,0,0,0,0,0,0 880 | 879,0,0,0,0,0,0,0 881 | 880,0,0,0,0,0,0,0 882 | 881,0,0,0,0,0,0,0 883 | 882,0,0,0,0,0,0,0 884 | 883,0,0,0,0,0,0,0 885 | 884,0,0,0,0,0,0,0 886 | 885,11,3,7,8,13,21,9 887 | 886,0,0,0,0,0,0,0 888 | 887,0,0,0,0,0,0,0 889 | 888,0,0,0,0,0,0,0 890 | 889,0,0,0,0,0,0,0 891 | 890,1,0,1,4,3,4,1 892 | 891,0,0,0,0,0,0,0 893 | 892,0,0,0,0,0,0,0 894 | 893,10,4,2,0,9,8,2 895 | 894,0,0,0,0,0,0,0 896 | 895,0,0,0,0,0,0,0 897 | 896,17,9,16,7,18,19,12 898 | 897,0,0,0,0,0,0,0 899 | 898,0,0,0,0,0,0,0 900 | 899,0,0,0,0,0,0,0 901 | 900,0,0,0,0,0,0,0 902 | 901,0,0,0,0,0,0,0 903 | 902,0,0,0,0,0,0,0 904 | 903,0,0,0,0,0,0,0 905 | 904,6,8,7,9,8,20,5 906 | 905,0,0,0,0,0,0,0 907 | 906,0,0,0,0,0,0,0 908 | 907,0,0,0,0,0,0,0 909 | 908,0,0,0,0,0,0,0 910 | 909,0,0,0,0,0,0,0 911 | 910,0,0,0,0,0,0,0 912 | 911,0,0,0,0,0,0,0 913 | 912,0,0,0,0,0,0,0 914 | 913,0,0,0,0,0,0,0 915 | 914,0,0,0,0,0,0,0 916 | 915,0,0,0,0,0,0,0 917 | 916,0,0,0,0,0,0,0 918 | 917,5,4,2,1,5,5,3 919 | 918,0,0,0,0,0,0,0 920 | 919,0,0,0,0,0,0,0 921 | 920,0,0,0,0,0,0,0 922 | 921,0,0,0,0,0,0,0 923 | 922,0,0,0,0,0,0,0 924 | 923,0,0,0,0,0,0,0 925 | 924,0,0,0,0,0,0,0 926 | 925,1,2,4,1,2,2,1 927 | 926,0,0,0,0,0,0,0 928 | 927,0,0,0,0,0,0,0 929 | 928,0,0,0,0,0,0,0 930 | 929,0,0,0,0,0,0,0 931 | 930,0,0,0,0,0,0,0 932 | 931,0,0,0,0,0,0,0 933 | 932,0,0,0,0,0,0,0 934 | 933,0,0,0,0,0,0,0 935 | 934,0,0,0,0,0,0,0 936 | 935,1,1,0,2,0,0,1 937 | 936,0,0,0,0,0,0,0 938 | 937,0,0,0,0,0,0,0 939 | 938,0,0,0,0,0,0,0 940 | 939,0,0,0,0,0,0,0 941 | 940,0,0,0,0,0,0,0 942 | 941,0,0,0,0,0,0,0 943 | 942,0,0,0,0,0,0,0 944 | 943,0,0,0,0,0,0,0 945 | 944,0,0,0,0,0,0,0 946 | 945,0,0,0,0,0,0,0 947 | 946,0,0,0,0,0,0,0 948 | 947,5,4,7,7,3,8,7 949 | 948,0,1,0,0,0,0,0 950 | 949,0,0,0,0,0,0,0 951 | 950,1,3,2,2,0,2,0 952 | 951,0,0,0,0,0,0,0 953 | 952,0,0,0,0,0,0,0 954 | 953,0,0,0,0,0,0,0 955 | 954,0,0,0,0,0,0,0 956 | 955,0,0,0,0,0,0,0 957 | 956,0,0,0,0,0,0,0 958 | 957,0,0,0,0,0,0,0 959 | 958,0,0,0,0,0,0,0 960 | 959,21,11,16,14,17,6,17 961 | 960,0,0,1,0,0,1,0 962 | 961,0,0,0,0,0,0,0 963 | 962,0,0,0,0,0,0,0 964 | 963,0,0,0,0,0,0,0 965 | 964,0,0,0,0,0,0,0 966 | 965,0,0,1,0,0,0,1 967 | 966,0,0,0,0,0,0,0 968 | 967,0,0,0,0,0,0,0 969 | 968,12,5,8,3,10,11,7 970 | 969,0,0,0,0,0,0,0 971 | 970,3,2,5,4,4,7,2 972 | 971,0,0,0,0,0,0,0 973 | 972,10,8,14,6,14,17,7 974 | 973,0,0,0,0,0,0,0 975 | 974,0,0,0,0,0,0,0 976 | 975,0,0,0,0,0,0,0 977 | 976,2,4,7,4,3,1,3 978 | 977,3,0,0,0,0,0,0 979 | 978,14,5,10,16,13,13,11 980 | 979,0,0,0,0,0,0,0 981 | 980,0,0,0,0,0,0,0 982 | 981,0,0,0,0,0,0,0 983 | 982,0,0,0,0,0,0,0 984 | 983,0,0,0,0,0,0,1 985 | 984,0,0,0,0,0,0,0 986 | 985,2,5,4,3,5,12,5 987 | 986,0,0,0,0,0,0,0 988 | 987,0,0,0,0,0,0,0 989 | 988,0,0,0,0,0,0,0 990 | 989,3,6,2,5,5,1,1 991 | 990,0,0,0,0,0,0,0 992 | 991,0,0,0,0,0,0,0 993 | 992,0,0,0,0,0,0,0 994 | 993,0,0,0,0,0,0,0 995 | 994,0,0,0,0,0,0,0 996 | 995,0,0,0,0,0,0,0 997 | 996,0,0,0,0,0,0,0 998 | 997,0,0,0,0,0,0,0 999 | 998,0,0,0,0,0,0,0 1000 | 999,4,7,6,1,13,4,3 1001 | 1000,0,0,0,0,0,0,0 1002 | 1001,0,0,0,0,0,0,0 1003 | 1002,0,0,0,0,0,0,0 1004 | 1003,0,0,0,0,0,0,0 1005 | 1004,0,0,0,0,0,1,0 1006 | 1005,0,0,0,0,0,0,0 1007 | 1006,0,0,0,0,0,0,0 1008 | 1007,0,1,1,0,1,1,0 1009 | 1008,0,0,0,0,0,0,0 1010 | 1009,0,0,0,0,0,0,0 1011 | 1010,0,0,0,0,3,0,0 1012 | 1011,0,0,0,0,0,0,0 1013 | 1012,0,0,0,0,0,0,0 1014 | 1013,1,2,1,0,3,3,2 1015 | 1014,0,0,0,0,0,0,0 1016 | 1015,0,0,0,0,0,0,0 1017 | 1016,0,0,0,0,0,0,0 1018 | 1017,0,0,0,0,0,0,0 1019 | 1018,0,0,0,0,0,0,0 1020 | 1019,0,0,0,0,0,0,0 1021 | 1020,3,3,3,6,1,6,6 1022 | 1021,0,0,0,0,0,0,0 1023 | 1022,13,14,12,6,24,21,9 1024 | 1023,0,0,0,0,0,0,0 1025 | 1024,6,5,6,11,5,9,12 1026 | 1025,0,0,0,0,0,0,0 1027 | 1026,0,0,0,0,0,0,0 1028 | 1027,0,0,0,0,0,0,0 1029 | 1028,0,0,0,0,0,0,0 1030 | 1029,0,0,0,0,0,0,0 1031 | 1030,0,0,0,0,0,0,0 1032 | 1031,0,0,0,0,0,0,0 1033 | 1032,0,0,0,0,0,0,0 1034 | 1033,0,0,0,0,0,0,0 1035 | 1034,4,2,0,1,2,4,4 1036 | 1035,0,0,0,0,0,0,0 1037 | 1036,0,0,0,0,0,0,0 1038 | 1037,0,0,0,0,0,0,0 1039 | 1038,0,0,0,0,0,0,0 1040 | 1039,0,0,0,0,0,0,0 1041 | 1040,0,0,0,0,0,0,0 1042 | 1041,0,0,0,0,0,0,0 1043 | 1042,0,0,0,0,0,0,0 1044 | 1043,3,2,0,5,1,6,4 1045 | 1044,0,0,0,0,0,0,0 1046 | 1045,0,0,0,0,0,0,0 1047 | 1046,4,6,7,7,4,8,6 1048 | 1047,0,0,0,0,0,0,0 1049 | 1048,4,8,4,5,12,11,9 1050 | 1049,1,1,3,4,6,1,2 1051 | 1050,0,0,0,0,0,0,0 1052 | 1051,0,0,0,1,0,1,0 1053 | 1052,0,0,0,0,0,0,0 1054 | 1053,0,0,0,0,0,0,0 1055 | 1054,0,2,0,0,0,0,0 1056 | 1055,0,0,0,0,0,0,0 1057 | 1056,0,0,0,0,0,0,0 1058 | 1057,0,0,0,0,0,0,0 1059 | 1058,0,0,0,0,0,0,0 1060 | 1059,0,0,0,0,0,0,0 1061 | 1060,0,0,0,0,0,1,0 1062 | 1061,3,4,3,4,1,2,5 1063 | 1062,1,3,0,1,0,0,0 1064 | 1063,0,0,0,0,0,0,0 1065 | 1064,7,6,10,4,7,5,4 1066 | 1065,0,0,0,0,0,0,0 1067 | 1066,1,2,2,1,4,4,2 1068 | 1067,0,0,0,0,0,0,0 1069 | 1068,0,0,0,0,0,0,0 1070 | 1069,0,0,0,0,0,0,0 1071 | 1070,0,0,0,0,0,0,0 1072 | 1071,0,0,0,0,0,0,0 1073 | 1072,0,0,0,0,0,0,0 1074 | 1073,7,6,9,3,13,6,3 1075 | 1074,0,0,0,0,0,0,0 1076 | 1075,0,0,0,0,0,0,0 1077 | 1076,0,0,0,0,0,0,0 1078 | 1077,0,0,0,0,0,0,0 1079 | 1078,1,1,1,1,3,1,1 1080 | 1079,0,0,0,0,0,0,0 1081 | 1080,0,0,0,0,0,0,0 1082 | 1081,7,11,12,4,11,11,11 1083 | 1082,0,0,0,0,0,0,0 1084 | 1083,0,0,0,0,0,0,0 1085 | 1084,0,0,0,0,0,0,0 1086 | 1085,0,0,0,0,0,0,0 1087 | 1086,0,0,0,0,0,0,0 1088 | 1087,0,0,0,0,0,0,0 1089 | 1088,0,0,0,0,0,0,0 1090 | 1089,0,0,0,0,0,0,0 1091 | 1090,2,3,2,0,0,0,0 1092 | 1091,0,0,0,0,0,0,0 1093 | 1092,0,0,0,0,0,0,0 1094 | 1093,0,0,0,0,0,0,0 1095 | 1094,9,2,2,5,12,5,8 1096 | 1095,15,3,5,8,16,13,9 1097 | 1096,0,0,0,0,0,0,0 1098 | 1097,0,0,0,0,0,0,0 1099 | 1098,0,0,0,0,0,0,0 1100 | 1099,0,0,0,0,0,0,0 1101 | 1100,0,0,0,0,0,0,0 1102 | 1101,4,2,6,2,3,3,2 1103 | 1102,3,9,3,2,12,10,8 1104 | 1103,0,0,0,0,0,0,0 1105 | 1104,0,0,0,0,0,0,0 1106 | 1105,7,0,6,5,9,2,5 1107 | 1106,0,0,0,0,0,0,0 1108 | 1107,0,0,0,0,0,0,0 1109 | 1108,22,16,19,13,18,20,10 1110 | 1109,2,0,0,0,0,0,0 1111 | 1110,0,0,0,0,0,0,0 1112 | 1111,1,0,1,0,1,1,0 1113 | 1112,0,0,0,0,0,0,0 1114 | 1113,1,0,0,1,0,0,0 1115 | 1114,0,0,0,0,0,0,1 1116 | 1115,0,0,1,0,3,3,0 1117 | 1116,0,0,0,0,0,0,0 1118 | 1117,0,0,0,0,0,0,0 1119 | 1118,0,0,0,0,0,0,0 1120 | 1119,0,0,0,0,0,0,0 1121 | 1120,0,0,1,0,2,1,1 1122 | 1121,0,0,0,0,0,0,0 1123 | 1122,1,0,0,0,0,1,2 1124 | 1123,0,0,0,0,0,0,0 1125 | 1124,0,0,0,0,0,0,0 1126 | 1125,4,6,3,2,4,2,2 1127 | 1126,0,0,0,0,0,0,0 1128 | 1127,0,0,0,0,0,0,0 1129 | 1128,0,0,0,0,0,0,0 1130 | 1129,0,0,0,0,0,0,0 1131 | 1130,0,0,1,0,1,0,0 1132 | 1131,0,0,0,0,0,0,0 1133 | 1132,0,0,0,0,0,0,0 1134 | 1133,8,8,4,9,8,13,7 1135 | 1134,0,0,2,2,2,1,0 1136 | 1135,0,0,0,0,0,0,0 1137 | 1136,0,0,0,0,0,0,0 1138 | 1137,0,0,0,0,0,0,0 1139 | 1138,0,0,0,0,0,0,0 1140 | 1139,0,0,0,0,0,6,4 1141 | 1140,0,0,0,0,0,0,0 1142 | 1141,0,0,0,0,0,0,0 1143 | 1142,0,0,0,0,0,0,0 1144 | 1143,0,0,0,0,0,0,0 1145 | 1144,0,0,0,0,0,0,0 1146 | 1145,0,0,0,0,0,0,0 1147 | 1146,0,0,0,0,0,0,0 1148 | 1147,0,0,0,0,0,0,0 1149 | 1148,0,0,0,0,0,0,0 1150 | 1149,0,0,0,0,0,0,0 1151 | 1150,0,0,0,0,0,0,0 1152 | 1151,0,0,0,0,0,0,0 1153 | 1152,0,0,0,0,0,0,0 1154 | 1153,0,0,0,0,0,0,0 1155 | 1154,0,0,0,0,0,0,0 1156 | 1155,0,1,0,0,1,1,0 1157 | 1156,0,0,0,0,0,0,0 1158 | 1157,0,0,0,0,0,0,0 1159 | 1158,0,0,0,0,0,0,0 1160 | 1159,0,0,0,0,0,0,0 1161 | 1160,1,4,7,3,2,0,1 1162 | 1161,0,0,0,0,0,0,0 1163 | 1162,0,0,0,0,0,0,0 1164 | 1163,0,0,0,0,0,0,0 1165 | 1164,0,0,0,0,0,0,0 1166 | 1165,5,3,2,9,3,9,0 1167 | 1166,0,0,0,0,0,0,0 1168 | 1167,0,0,0,0,0,0,0 1169 | 1168,0,0,0,0,0,0,0 1170 | 1169,4,7,4,5,7,7,3 1171 | 1170,0,0,0,0,0,0,0 1172 | 1171,0,0,0,0,0,0,0 1173 | 1172,0,0,0,0,0,0,0 1174 | 1173,0,0,0,0,0,0,0 1175 | 1174,2,0,3,3,7,7,4 1176 | 1175,0,0,0,0,0,0,0 1177 | 1176,0,0,0,0,0,0,0 1178 | 1177,0,0,0,0,0,0,0 1179 | 1178,0,0,0,0,0,0,0 1180 | 1179,0,0,0,0,0,0,0 1181 | 1180,0,0,0,0,0,0,0 1182 | 1181,0,0,0,0,0,0,0 1183 | 1182,0,0,0,0,0,0,0 1184 | 1183,0,0,0,0,0,0,0 1185 | 1184,0,0,0,0,0,0,0 1186 | 1185,0,1,0,2,0,0,0 1187 | 1186,3,7,2,3,4,6,3 1188 | 1187,0,0,0,0,0,0,0 1189 | 1188,0,0,0,0,0,0,0 1190 | 1189,0,0,0,0,0,0,0 1191 | 1190,11,6,9,10,30,18,11 1192 | 1191,0,0,0,0,0,0,0 1193 | 1192,0,0,0,0,0,0,0 1194 | 1193,0,0,0,0,0,0,0 1195 | 1194,0,0,0,0,0,0,0 1196 | 1195,0,0,0,0,0,0,0 1197 | 1196,0,0,0,0,0,0,0 1198 | 1197,0,0,0,0,0,0,0 1199 | 1198,0,0,0,0,0,0,0 1200 | 1199,2,0,0,1,2,3,1 1201 | 1200,15,7,9,7,15,13,15 1202 | 1201,0,0,0,0,0,0,0 1203 | 1202,6,1,3,2,2,4,3 1204 | 1203,0,0,0,0,0,0,0 1205 | 1204,0,0,0,0,0,0,0 1206 | 1205,0,0,0,0,0,0,0 1207 | 1206,0,1,2,1,9,2,0 1208 | 1207,0,0,0,0,0,0,0 1209 | 1208,0,0,0,0,0,0,0 1210 | 1209,0,0,0,0,0,0,0 1211 | 1210,0,0,0,0,0,0,0 1212 | 1211,0,0,0,0,0,0,0 1213 | 1212,0,0,0,0,0,0,0 1214 | 1213,0,0,0,0,0,0,0 1215 | 1214,0,0,0,0,0,0,0 1216 | 1215,1,4,2,2,3,1,2 1217 | 1216,0,0,0,0,0,0,0 1218 | 1217,0,0,0,0,0,0,0 1219 | 1218,1,3,1,0,3,0,1 1220 | 1219,1,2,2,3,3,3,2 1221 | 1220,2,2,0,0,2,2,0 1222 | 1221,0,0,0,0,0,0,0 1223 | 1222,0,0,0,0,0,0,0 1224 | 1223,0,0,0,0,0,0,0 1225 | 1224,0,0,0,0,0,0,0 1226 | 1225,0,0,0,0,0,0,0 1227 | 1226,0,0,0,0,0,0,0 1228 | 1227,0,0,0,0,0,0,0 1229 | 1228,0,0,0,0,0,0,0 1230 | 1229,0,0,0,0,0,0,0 1231 | 1230,11,5,4,5,8,13,5 1232 | 1231,0,0,0,0,0,0,0 1233 | 1232,0,0,0,0,0,0,0 1234 | 1233,0,0,0,0,0,0,0 1235 | 1234,0,0,0,0,0,0,0 1236 | 1235,0,0,0,0,0,0,0 1237 | 1236,0,0,0,0,0,0,0 1238 | 1237,0,0,0,0,0,0,0 1239 | 1238,4,7,4,6,8,11,9 1240 | 1239,4,4,11,11,4,8,7 1241 | 1240,0,0,0,0,0,0,0 1242 | 1241,0,0,0,0,0,0,0 1243 | 1242,0,0,0,0,0,0,0 1244 | 1243,0,0,0,0,0,0,0 1245 | 1244,0,0,0,0,0,0,0 1246 | 1245,11,7,4,13,8,14,4 1247 | 1246,0,0,0,0,0,0,0 1248 | 1247,0,0,0,0,0,0,0 1249 | 1248,6,5,8,3,6,8,8 1250 | 1249,0,0,0,0,0,0,0 1251 | 1250,2,2,3,2,4,2,3 1252 | 1251,0,0,0,0,0,0,0 1253 | 1252,0,0,0,0,0,0,0 1254 | 1253,0,0,0,0,0,0,0 1255 | 1254,0,0,0,0,0,0,0 1256 | 1255,0,0,0,0,0,0,0 1257 | 1256,0,0,0,0,0,0,0 1258 | 1257,0,0,0,0,0,0,0 1259 | 1258,0,0,0,0,0,0,0 1260 | 1259,0,0,0,0,0,0,0 1261 | 1260,0,0,0,0,0,0,0 1262 | 1261,0,0,0,0,0,0,0 1263 | 1262,0,0,0,0,0,0,0 1264 | 1263,0,0,0,0,0,0,0 1265 | 1264,0,0,0,0,0,0,0 1266 | 1265,0,0,0,0,0,0,0 1267 | 1266,9,15,10,7,15,17,13 1268 | 1267,0,0,0,0,0,0,0 1269 | 1268,0,0,0,0,0,0,0 1270 | 1269,0,0,0,0,0,0,0 1271 | 1270,0,0,0,0,0,0,0 1272 | 1271,0,0,0,0,0,0,0 1273 | 1272,0,0,0,0,0,0,0 1274 | 1273,0,0,0,0,0,0,0 1275 | 1274,0,0,0,0,0,0,0 1276 | 1275,9,0,14,13,22,8,14 1277 | 1276,0,0,0,0,0,0,0 1278 | 1277,0,0,0,0,0,0,0 1279 | 1278,0,0,0,0,0,0,0 1280 | 1279,3,4,3,3,5,9,5 1281 | 1280,0,0,0,0,0,0,0 1282 | 1281,0,1,3,4,1,3,0 1283 | 1282,0,0,0,0,0,0,0 1284 | 1283,0,0,0,0,0,0,0 1285 | 1284,1,4,0,0,0,1,1 1286 | 1285,0,0,0,0,0,0,0 1287 | 1286,0,0,0,0,0,0,0 1288 | 1287,7,22,22,12,24,19,16 1289 | 1288,0,0,0,0,0,0,0 1290 | 1289,0,0,0,0,0,0,0 1291 | 1290,0,0,0,0,0,0,0 1292 | 1291,0,0,0,0,0,0,0 1293 | 1292,0,0,0,0,0,0,0 1294 | 1293,0,0,0,0,0,0,0 1295 | 1294,0,0,0,0,0,0,0 1296 | 1295,0,0,0,0,0,0,0 1297 | 1296,0,0,0,0,0,0,0 1298 | 1297,0,0,0,0,0,0,0 1299 | 1298,0,0,0,0,0,0,0 1300 | 1299,3,2,2,2,6,3,1 1301 | 1300,0,0,0,0,0,0,0 1302 | 1301,0,0,0,0,0,0,0 1303 | 1302,0,0,0,0,0,0,0 1304 | 1303,1,15,7,10,7,8,8 1305 | 1304,0,0,0,0,0,0,0 1306 | 1305,0,0,1,0,0,0,0 1307 | 1306,0,0,0,0,0,0,0 1308 | 1307,0,0,0,0,0,0,0 1309 | 1308,0,0,0,0,0,0,0 1310 | 1309,0,0,0,0,0,0,0 1311 | 1310,0,0,0,0,0,0,0 1312 | 1311,0,0,0,0,0,0,0 1313 | 1312,7,17,12,11,13,13,17 1314 | 1313,4,7,0,3,2,2,1 1315 | 1314,3,2,6,10,4,13,9 1316 | 1315,0,0,0,0,0,0,0 1317 | 1316,0,0,0,0,0,0,0 1318 | 1317,0,0,0,0,0,0,0 1319 | 1318,0,0,0,0,0,0,0 1320 | 1319,0,0,0,0,0,0,0 1321 | 1320,0,0,0,0,0,0,0 1322 | 1321,0,0,0,0,0,0,0 1323 | 1322,39,31,24,28,36,55,41 1324 | 1323,0,0,0,0,0,0,0 1325 | 1324,0,0,0,0,0,0,0 1326 | 1325,0,0,0,0,0,0,0 1327 | 1326,0,0,0,0,0,0,0 1328 | 1327,0,0,0,0,0,0,0 1329 | 1328,0,0,0,0,0,0,0 1330 | 1329,0,1,1,4,2,2,2 1331 | 1330,0,0,0,0,0,0,0 1332 | 1331,0,0,0,0,0,0,0 1333 | 1332,0,0,0,0,0,0,0 1334 | 1333,0,0,2,0,1,3,0 1335 | 1334,0,0,4,0,0,0,0 1336 | 1335,0,0,0,0,0,0,0 1337 | 1336,0,0,0,0,0,0,0 1338 | 1337,0,0,0,0,0,0,0 1339 | 1338,0,0,0,0,0,0,0 1340 | 1339,0,0,0,0,0,0,0 1341 | 1340,0,0,0,0,0,0,0 1342 | 1341,0,0,0,0,0,0,0 1343 | 1342,0,0,0,0,0,0,0 1344 | 1343,0,0,0,0,0,0,0 1345 | 1344,0,0,0,0,0,0,0 1346 | 1345,0,0,0,0,0,0,0 1347 | 1346,0,0,0,0,0,0,0 1348 | 1347,0,0,0,0,0,0,0 1349 | 1348,3,5,6,7,8,3,4 1350 | 1349,0,0,0,0,0,0,0 1351 | 1350,3,14,0,0,6,16,2 1352 | 1351,0,0,0,0,0,0,0 1353 | 1352,0,3,7,4,3,4,4 1354 | 1353,0,0,0,0,0,0,0 1355 | 1354,0,0,0,0,0,0,0 1356 | 1355,4,3,2,7,5,4,3 1357 | 1356,0,0,0,0,0,0,0 1358 | 1357,0,0,0,0,0,0,0 1359 | 1358,0,0,0,0,0,0,0 1360 | 1359,0,0,0,0,0,0,0 1361 | 1360,1,0,0,1,0,1,1 1362 | 1361,6,6,7,5,5,5,2 1363 | 1362,2,3,1,1,3,1,3 1364 | 1363,0,0,0,0,0,0,0 1365 | 1364,0,0,0,0,0,0,0 1366 | 1365,3,3,5,4,2,8,2 1367 | 1366,0,0,0,0,0,0,0 1368 | 1367,0,0,0,0,0,0,0 1369 | 1368,9,3,7,9,9,10,5 1370 | 1369,0,0,0,0,0,0,0 1371 | 1370,0,0,0,0,0,0,0 1372 | 1371,0,0,0,0,0,0,0 1373 | 1372,0,0,0,0,0,0,0 1374 | 1373,0,0,0,0,0,0,0 1375 | 1374,0,0,0,0,0,0,0 1376 | 1375,0,0,0,0,0,0,0 1377 | 1376,0,0,0,0,0,0,0 1378 | 1377,3,4,2,3,7,6,7 1379 | 1378,0,0,0,0,0,0,0 1380 | 1379,0,2,0,0,0,0,0 1381 | 1380,0,0,0,0,0,0,0 1382 | 1381,7,8,12,1,16,22,4 1383 | 1382,1,5,5,8,6,2,6 1384 | 1383,0,0,0,0,0,0,0 1385 | 1384,0,0,0,0,0,0,0 1386 | 1385,2,2,3,5,0,2,0 1387 | 1386,0,0,0,0,0,0,0 1388 | 1387,0,0,0,0,0,0,0 1389 | 1388,0,3,4,3,4,8,0 1390 | 1389,1,3,2,1,4,2,2 1391 | 1390,0,0,0,0,0,0,0 1392 | 1391,0,0,0,0,0,0,0 1393 | 1392,0,0,1,0,0,0,1 1394 | 1393,0,0,0,0,0,0,0 1395 | 1394,0,0,0,0,0,0,0 1396 | 1395,3,8,0,6,5,5,8 1397 | 1396,0,0,0,0,0,0,0 1398 | 1397,0,0,0,0,0,0,0 1399 | 1398,0,0,0,0,0,0,0 1400 | 1399,0,0,0,0,0,0,0 1401 | 1400,0,0,0,0,0,0,0 1402 | 1401,3,4,6,5,12,3,8 1403 | 1402,0,0,0,0,0,0,0 1404 | 1403,0,0,0,0,0,0,0 1405 | 1404,0,0,0,0,0,0,0 1406 | 1405,0,0,0,0,0,0,0 1407 | 1406,0,0,0,0,0,0,0 1408 | 1407,0,0,0,1,0,0,0 1409 | 1408,0,0,0,0,0,0,0 1410 | 1409,0,0,0,0,0,0,0 1411 | 1410,0,0,0,0,0,0,0 1412 | 1411,2,7,6,5,4,11,6 1413 | 1412,0,0,0,0,0,0,0 1414 | 1413,0,0,0,0,0,0,0 1415 | 1414,0,0,0,0,0,0,0 1416 | 1415,0,0,0,0,0,0,0 1417 | 1416,0,0,0,0,0,0,0 1418 | 1417,0,0,0,0,0,0,0 1419 | 1418,0,0,0,0,0,0,0 1420 | 1419,0,0,0,0,0,0,0 1421 | 1420,1,1,3,0,1,6,3 1422 | 1421,0,2,1,2,0,1,1 1423 | 1422,14,26,17,10,27,46,26 1424 | 1423,0,0,0,0,0,0,0 1425 | 1424,0,0,0,0,0,0,0 1426 | 1425,11,7,12,5,12,9,8 1427 | 1426,4,4,8,6,12,7,13 1428 | 1427,0,0,0,0,0,0,0 1429 | 1428,0,0,0,0,0,0,0 1430 | 1429,0,0,0,0,0,0,0 1431 | 1430,0,0,0,0,0,0,0 1432 | 1431,0,0,0,0,0,0,0 1433 | 1432,7,4,7,13,25,22,3 1434 | 1433,0,0,0,0,0,0,0 1435 | 1434,0,0,0,0,1,0,0 1436 | 1435,1,3,1,2,0,0,2 1437 | 1436,0,0,0,0,0,0,0 1438 | 1437,0,0,0,0,0,0,0 1439 | 1438,4,2,0,3,2,6,2 1440 | 1439,2,6,3,1,1,2,2 1441 | 1440,0,0,0,0,0,0,0 1442 | 1441,0,0,0,0,0,0,0 1443 | 1442,0,0,0,0,0,0,0 1444 | 1443,0,0,0,0,0,0,0 1445 | 1444,0,0,0,0,0,0,0 1446 | 1445,0,0,0,0,0,0,0 1447 | 1446,4,0,0,0,0,0,0 1448 | 1447,0,0,0,0,0,0,1 1449 | 1448,0,0,0,0,0,0,0 1450 | 1449,3,0,1,1,1,1,3 1451 | 1450,0,0,0,0,0,0,0 1452 | 1451,0,1,2,1,0,0,1 1453 | 1452,0,0,0,0,0,0,0 1454 | 1453,0,0,0,0,0,0,0 1455 | 1454,0,0,0,0,0,0,0 1456 | 1455,0,0,0,0,0,0,0 1457 | 1456,8,7,9,3,10,12,5 1458 | 1457,1,2,1,0,0,1,1 1459 | 1458,0,0,0,0,0,0,0 1460 | 1459,0,0,0,0,0,0,0 1461 | 1460,0,0,0,0,0,0,0 1462 | 1461,0,0,0,0,0,0,0 1463 | 1462,0,0,0,0,0,0,0 1464 | 1463,0,0,0,0,0,0,0 1465 | 1464,0,0,0,0,0,0,0 1466 | 1465,0,0,0,0,0,0,0 1467 | 1466,0,0,0,0,0,0,0 1468 | 1467,0,0,0,0,0,0,0 1469 | 1468,0,0,0,0,0,0,0 1470 | 1469,0,0,0,0,0,0,0 1471 | 1470,0,0,0,0,0,0,0 1472 | 1471,0,0,0,0,0,0,0 1473 | 1472,0,0,0,0,0,0,0 1474 | 1473,0,0,1,0,1,3,3 1475 | 1474,0,0,0,0,0,0,0 1476 | 1475,0,0,0,0,0,0,0 1477 | 1476,4,5,1,1,4,7,4 1478 | 1477,0,0,0,0,0,0,0 1479 | 1478,0,0,0,0,0,0,0 1480 | 1479,0,0,0,0,0,0,0 1481 | 1480,0,0,0,0,0,0,0 1482 | 1481,0,0,0,0,0,0,0 1483 | 1482,0,0,0,0,0,0,0 1484 | 1483,0,5,4,7,11,24,7 1485 | 1484,0,0,0,0,0,0,0 1486 | 1485,7,6,4,11,7,10,4 1487 | 1486,0,0,1,0,5,1,0 1488 | 1487,0,0,0,0,0,0,0 1489 | 1488,9,13,9,18,13,20,13 1490 | 1489,0,0,0,0,0,0,0 1491 | 1490,0,0,0,0,0,0,0 1492 | 1491,0,0,0,0,0,0,0 1493 | 1492,0,0,0,0,0,0,0 1494 | 1493,0,0,0,0,0,0,0 1495 | 1494,0,0,0,0,0,0,0 1496 | 1495,0,0,0,0,0,0,0 1497 | 1496,0,0,0,0,0,0,0 1498 | 1497,8,11,14,7,6,14,11 1499 | 1498,0,0,0,0,0,0,0 1500 | 1499,0,0,0,0,0,0,0 1501 | 1500,0,0,0,0,0,0,0 1502 | 1501,10,7,2,3,3,4,5 1503 | 1502,0,1,0,0,0,0,0 1504 | 1503,0,0,0,0,0,0,0 1505 | 1504,0,0,0,0,1,0,0 1506 | 1505,6,7,1,3,2,6,4 1507 | 1506,0,0,0,0,0,0,0 1508 | 1507,0,4,0,0,0,1,0 1509 | 1508,0,0,0,0,0,0,0 1510 | 1509,0,0,0,0,0,0,0 1511 | 1510,0,0,0,0,0,0,0 1512 | 1511,0,0,0,0,0,0,0 1513 | 1512,0,0,0,0,0,0,0 1514 | 1513,2,2,2,4,6,12,5 1515 | 1514,0,3,0,0,0,0,1 1516 | 1515,0,0,0,0,0,0,0 1517 | 1516,5,4,5,2,3,9,5 1518 | 1517,2,0,1,5,3,1,2 1519 | 1518,0,0,0,0,0,0,0 1520 | 1519,0,0,0,0,0,0,2 1521 | 1520,0,0,0,0,0,0,0 1522 | 1521,0,0,0,0,0,0,0 1523 | 1522,0,0,0,0,0,0,0 1524 | 1523,0,0,0,0,1,0,0 1525 | 1524,0,0,0,0,0,0,0 1526 | 1525,0,0,0,0,0,0,0 1527 | 1526,0,0,0,0,0,0,0 1528 | 1527,3,0,1,8,6,8,9 1529 | 1528,0,0,0,0,0,0,0 1530 | 1529,0,0,0,0,0,0,0 1531 | 1530,2,2,0,1,2,3,1 1532 | 1531,0,0,0,0,0,0,0 1533 | 1532,0,0,0,0,0,0,0 1534 | 1533,0,0,0,0,0,0,0 1535 | 1534,9,12,11,15,11,8,11 1536 | 1535,0,0,0,0,0,0,0 1537 | 1536,0,1,1,0,1,1,0 1538 | 1537,2,0,2,1,5,4,3 1539 | 1538,0,0,0,0,0,0,0 1540 | 1539,18,27,14,22,30,33,25 1541 | 1540,0,0,0,0,0,0,0 1542 | 1541,0,0,0,0,0,0,0 1543 | 1542,0,0,0,0,0,0,0 1544 | 1543,0,0,0,0,0,0,0 1545 | 1544,0,0,0,0,0,0,0 1546 | 1545,0,0,0,0,0,0,0 1547 | 1546,0,0,0,0,0,0,0 1548 | 1547,0,0,0,0,0,0,0 1549 | 1548,0,0,0,0,0,0,0 1550 | 1549,0,0,0,0,0,0,0 1551 | 1550,0,0,0,0,0,0,0 1552 | 1551,0,0,0,0,0,0,0 1553 | 1552,0,0,1,0,0,0,1 1554 | 1553,7,6,11,8,10,12,10 1555 | 1554,0,0,0,1,1,0,0 1556 | 1555,0,0,0,0,0,0,0 1557 | 1556,0,0,0,0,0,0,0 1558 | 1557,0,0,0,0,0,0,0 1559 | 1558,0,0,0,0,0,0,0 1560 | 1559,0,0,0,0,0,0,0 1561 | 1560,0,0,0,0,0,0,0 1562 | 1561,0,0,0,0,0,0,0 1563 | 1562,0,0,0,0,0,0,0 1564 | 1563,0,0,0,0,0,0,0 1565 | 1564,5,7,4,2,4,9,5 1566 | 1565,0,0,0,0,0,0,0 1567 | 1566,0,0,0,0,0,0,0 1568 | 1567,0,0,0,0,0,0,0 1569 | 1568,0,0,0,0,0,0,0 1570 | 1569,0,0,0,0,0,0,0 1571 | 1570,6,12,15,8,14,18,10 1572 | 1571,0,0,0,0,0,0,0 1573 | 1572,0,0,0,0,0,0,0 1574 | 1573,10,8,15,15,14,18,17 1575 | 1574,2,0,0,0,2,1,2 1576 | 1575,0,0,0,0,0,0,0 1577 | 1576,5,1,5,5,4,2,4 1578 | 1577,0,0,0,0,0,0,0 1579 | 1578,0,0,0,0,0,0,0 1580 | 1579,0,0,0,0,0,0,0 1581 | 1580,0,0,0,0,0,0,0 1582 | 1581,0,0,0,0,0,0,0 1583 | 1582,0,0,0,0,0,0,0 1584 | 1583,0,0,0,0,0,0,0 1585 | 1584,0,0,0,0,0,0,0 1586 | 1585,1,1,0,1,1,2,0 1587 | 1586,0,0,0,0,0,1,0 1588 | 1587,0,0,0,0,0,1,0 1589 | 1588,1,2,2,3,3,3,2 1590 | 1589,0,0,0,0,0,0,0 1591 | 1590,0,0,0,0,0,0,0 1592 | 1591,0,0,0,0,0,0,0 1593 | 1592,5,0,2,3,2,4,1 1594 | 1593,0,0,0,0,0,0,0 1595 | 1594,0,0,0,0,0,0,0 1596 | 1595,0,0,0,0,0,0,0 1597 | 1596,0,0,0,0,1,0,0 1598 | 1597,0,0,0,0,0,0,0 1599 | 1598,1,2,7,3,1,4,3 1600 | 1599,0,0,0,0,0,0,0 1601 | 1600,0,0,0,0,0,0,0 1602 | 1601,0,0,0,0,0,0,0 1603 | 1602,0,0,0,0,0,0,0 1604 | 1603,0,0,0,0,0,0,0 1605 | 1604,0,0,0,0,0,0,0 1606 | 1605,0,0,0,0,0,0,0 1607 | 1606,0,0,0,0,0,0,0 1608 | 1607,0,0,0,0,0,0,0 1609 | 1608,0,0,0,0,0,0,0 1610 | 1609,0,0,0,0,0,0,0 1611 | 1610,0,0,0,0,0,0,0 1612 | 1611,0,0,0,0,0,0,0 1613 | 1612,6,6,10,9,10,11,9 1614 | 1613,0,0,0,0,0,0,0 1615 | 1614,0,0,0,0,0,0,0 1616 | 1615,0,0,0,0,0,0,0 1617 | 1616,0,0,0,0,0,0,0 1618 | 1617,3,1,4,1,1,2,4 1619 | 1618,0,2,1,1,7,9,0 1620 | 1619,0,0,0,0,0,0,0 1621 | 1620,0,0,0,0,0,0,0 1622 | 1621,0,0,0,0,0,0,0 1623 | 1622,5,5,7,4,8,11,5 1624 | 1623,10,6,8,9,14,18,13 1625 | 1624,18,16,14,16,23,31,25 1626 | 1625,0,0,0,0,0,0,0 1627 | 1626,0,0,0,0,0,0,0 1628 | 1627,5,4,4,3,5,7,4 1629 | 1628,0,0,0,0,0,0,0 1630 | 1629,0,0,0,0,0,0,0 1631 | 1630,0,0,0,0,0,0,0 1632 | 1631,0,0,0,0,0,0,0 1633 | 1632,6,2,7,10,7,4,2 1634 | 1633,0,0,0,0,0,0,0 1635 | 1634,6,5,9,7,13,6,15 1636 | 1635,0,0,0,0,0,0,0 1637 | 1636,0,0,0,0,0,0,0 1638 | 1637,0,0,0,0,0,0,0 1639 | 1638,0,0,0,0,0,0,0 1640 | 1639,0,0,0,0,0,0,0 1641 | 1640,0,0,0,0,0,0,0 1642 | 1641,0,0,0,0,0,0,0 1643 | 1642,0,0,0,0,0,0,0 1644 | 1643,5,3,2,0,7,2,0 1645 | 1644,0,0,0,0,0,0,0 1646 | 1645,0,0,0,0,0,0,0 1647 | 1646,0,0,0,0,0,0,0 1648 | 1647,7,5,2,4,3,9,4 1649 | 1648,0,0,0,0,0,0,0 1650 | 1649,0,1,2,0,0,0,1 1651 | 1650,0,0,0,0,0,0,0 1652 | 1651,0,0,0,0,0,0,0 1653 | 1652,0,0,0,0,0,0,0 1654 | 1653,0,0,0,0,0,0,0 1655 | 1654,0,0,0,0,0,0,0 1656 | 1655,0,0,0,0,0,0,0 1657 | 1656,0,0,0,0,0,0,0 1658 | 1657,2,0,3,4,4,1,3 1659 | 1658,0,0,0,0,0,0,0 1660 | 1659,0,0,0,0,0,0,0 1661 | 1660,0,0,0,0,0,0,0 1662 | 1661,0,0,0,0,0,0,0 1663 | 1662,6,3,3,5,5,9,1 1664 | 1663,0,0,0,0,0,0,0 1665 | 1664,0,0,0,0,0,0,0 1666 | 1665,0,0,0,0,0,0,0 1667 | 1666,0,0,0,0,0,0,0 1668 | 1667,0,0,0,0,0,0,0 1669 | 1668,0,0,0,0,0,0,0 1670 | 1669,0,0,0,0,0,0,0 1671 | 1670,18,16,22,23,22,23,20 1672 | 1671,0,0,0,0,0,0,0 1673 | 1672,0,0,0,0,0,0,0 1674 | 1673,0,0,0,0,0,0,0 1675 | 1674,2,4,3,5,1,3,2 1676 | 1675,12,7,8,4,16,12,7 1677 | 1676,3,4,6,5,9,7,4 1678 | 1677,14,14,11,15,14,18,12 1679 | 1678,0,0,0,0,0,0,0 1680 | 1679,0,0,0,0,0,0,0 1681 | 1680,10,10,8,11,12,10,5 1682 | 1681,0,0,0,0,0,0,0 1683 | 1682,0,0,0,0,0,0,0 1684 | 1683,0,0,0,0,0,0,0 1685 | 1684,0,0,0,0,0,0,0 1686 | 1685,0,0,0,0,0,0,0 1687 | 1686,1,0,0,0,1,1,1 1688 | 1687,0,0,0,0,0,0,0 1689 | 1688,0,0,0,0,0,0,0 1690 | 1689,0,3,3,0,5,9,3 1691 | 1690,4,2,5,0,7,2,4 1692 | 1691,0,0,0,0,0,0,0 1693 | 1692,0,0,0,0,0,0,0 1694 | 1693,0,0,0,0,0,0,0 1695 | 1694,0,0,0,0,0,0,0 1696 | 1695,10,7,2,3,8,6,4 1697 | 1696,3,5,1,5,8,3,4 1698 | 1697,0,0,0,0,0,0,0 1699 | 1698,1,1,0,1,1,0,0 1700 | 1699,0,0,0,0,0,0,0 1701 | 1700,0,0,0,0,0,0,0 1702 | 1701,0,0,0,0,0,0,0 1703 | 1702,0,0,0,1,0,0,0 1704 | 1703,0,0,0,0,0,0,0 1705 | 1704,0,0,1,0,0,0,0 1706 | 1705,0,0,0,0,0,0,0 1707 | 1706,6,4,0,2,5,6,2 1708 | 1707,0,0,0,0,0,2,0 1709 | 1708,2,1,5,1,2,0,2 1710 | 1709,9,10,9,3,6,6,11 1711 | 1710,0,0,0,0,0,0,0 1712 | 1711,12,8,10,12,13,8,15 1713 | 1712,0,0,0,0,0,0,0 1714 | 1713,0,0,0,0,0,0,0 1715 | 1714,0,0,0,0,0,0,0 1716 | 1715,0,0,0,0,0,0,0 1717 | 1716,0,0,0,0,0,0,0 1718 | 1717,0,0,0,0,0,0,0 1719 | 1718,0,0,0,0,0,0,0 1720 | 1719,0,0,0,0,0,0,0 1721 | 1720,24,23,24,23,29,17,42 1722 | 1721,0,0,0,0,0,0,0 1723 | 1722,0,0,0,0,0,0,0 1724 | 1723,1,3,0,7,3,4,2 1725 | 1724,0,0,0,0,0,0,0 1726 | 1725,0,0,0,0,0,0,0 1727 | 1726,0,0,0,0,0,0,0 1728 | 1727,4,3,3,7,12,10,6 1729 | 1728,4,3,7,5,0,12,4 1730 | 1729,0,0,0,0,0,0,0 1731 | 1730,0,0,0,0,0,0,0 1732 | 1731,0,0,0,0,0,0,0 1733 | 1732,0,0,0,0,0,0,0 1734 | 1733,0,0,0,0,0,0,0 1735 | 1734,4,0,5,0,3,5,2 1736 | 1735,0,0,0,0,0,0,0 1737 | 1736,0,0,0,1,2,5,3 1738 | 1737,0,0,0,0,0,0,0 1739 | 1738,1,4,1,2,2,2,2 1740 | 1739,0,0,0,0,0,0,0 1741 | 1740,0,2,2,0,0,5,2 1742 | 1741,0,0,0,0,0,0,0 1743 | 1742,0,0,0,0,0,0,0 1744 | 1743,0,0,0,0,0,0,0 1745 | 1744,1,1,0,0,0,3,0 1746 | 1745,0,0,0,0,0,0,0 1747 | 1746,0,0,0,0,0,0,0 1748 | 1747,0,0,0,0,0,0,0 1749 | 1748,0,0,0,0,0,0,0 1750 | 1749,0,0,0,0,0,0,0 1751 | 1750,0,0,0,0,0,0,0 1752 | 1751,0,0,0,0,0,0,0 1753 | 1752,0,0,0,0,0,0,0 1754 | 1753,6,4,3,3,2,7,7 1755 | 1754,0,0,0,0,0,0,0 1756 | 1755,0,0,0,0,0,0,0 1757 | 1756,0,0,0,0,0,0,0 1758 | 1757,0,0,0,0,0,0,0 1759 | 1758,0,0,0,0,0,0,0 1760 | 1759,0,0,0,0,0,0,0 1761 | 1760,0,0,0,0,0,0,0 1762 | 1761,0,0,0,0,0,0,0 1763 | 1762,0,1,1,0,0,1,0 1764 | 1763,5,3,1,3,16,10,9 1765 | 1764,4,6,4,1,4,6,2 1766 | 1765,0,0,0,0,0,0,0 1767 | 1766,8,6,7,7,18,13,7 1768 | 1767,0,0,0,0,0,0,0 1769 | 1768,0,0,0,0,1,0,0 1770 | 1769,0,0,0,0,0,0,0 1771 | 1770,0,0,0,0,0,0,0 1772 | 1771,0,0,0,0,0,0,0 1773 | 1772,0,0,0,0,0,0,0 1774 | 1773,0,0,0,0,0,0,0 1775 | 1774,0,0,0,0,0,0,0 1776 | 1775,7,10,6,11,15,14,4 1777 | 1776,0,0,0,0,0,0,0 1778 | 1777,0,0,0,0,0,0,0 1779 | 1778,0,0,0,0,0,0,0 1780 | 1779,0,0,0,0,0,0,0 1781 | 1780,0,0,0,0,0,0,0 1782 | 1781,0,0,0,0,0,0,0 1783 | 1782,5,6,8,4,4,7,7 1784 | 1783,0,0,0,0,0,0,0 1785 | 1784,0,0,0,0,0,0,0 1786 | 1785,11,3,6,11,13,8,8 1787 | 1786,0,0,0,0,0,0,0 1788 | 1787,0,0,1,0,0,0,0 1789 | 1788,0,0,0,0,0,0,0 1790 | 1789,0,0,0,0,0,0,0 1791 | 1790,1,4,3,3,5,3,0 1792 | 1791,2,0,1,1,5,3,2 1793 | 1792,0,0,0,0,0,0,0 1794 | 1793,0,0,0,0,0,0,0 1795 | 1794,0,0,0,0,0,0,0 1796 | 1795,0,0,0,0,0,0,0 1797 | 1796,0,0,0,0,0,0,0 1798 | 1797,0,0,0,0,0,0,0 1799 | 1798,0,0,0,0,0,0,0 1800 | 1799,0,0,0,0,0,0,0 1801 | 1800,5,6,5,3,6,6,3 1802 | 1801,0,0,0,0,0,0,0 1803 | 1802,0,0,0,0,0,0,0 1804 | 1803,0,0,0,0,0,0,0 1805 | 1804,0,0,0,0,0,0,0 1806 | 1805,0,0,0,0,0,0,0 1807 | 1806,1,7,9,4,2,4,6 1808 | 1807,7,5,4,5,4,3,3 1809 | 1808,0,0,0,0,0,0,0 1810 | 1809,2,0,0,1,2,0,0 1811 | 1810,0,0,0,0,0,0,0 1812 | 1811,7,9,7,4,6,9,5 1813 | 1812,0,0,1,0,3,1,1 1814 | 1813,0,0,0,0,0,0,0 1815 | 1814,0,0,0,0,0,0,0 1816 | 1815,11,5,5,7,9,13,11 1817 | 1816,0,0,0,0,0,0,0 1818 | 1817,4,3,2,1,1,3,3 1819 | 1818,0,0,0,0,0,0,0 1820 | 1819,0,0,0,0,0,0,0 1821 | 1820,1,1,2,2,6,5,4 1822 | 1821,0,0,0,0,0,0,0 1823 | 1822,0,0,0,0,0,0,0 1824 | 1823,13,19,8,13,7,14,24 1825 | 1824,0,0,0,0,0,0,0 1826 | 1825,0,0,0,0,0,0,0 1827 | 1826,0,0,0,0,0,0,0 1828 | 1827,0,0,0,0,0,0,0 1829 | 1828,0,0,1,0,0,0,0 1830 | 1829,0,0,0,0,0,0,0 1831 | 1830,0,0,0,0,0,0,0 1832 | 1831,0,0,0,0,0,0,0 1833 | 1832,0,0,0,0,0,0,0 1834 | 1833,0,0,0,0,0,0,0 1835 | 1834,3,1,6,2,3,5,1 1836 | 1835,0,0,0,0,0,0,0 1837 | 1836,0,0,0,0,0,0,0 1838 | 1837,5,2,1,8,1,2,5 1839 | 1838,0,0,0,0,0,0,0 1840 | 1839,0,0,0,0,0,0,0 1841 | 1840,0,0,0,0,0,0,0 1842 | 1841,0,0,0,0,0,0,0 1843 | 1842,0,0,0,0,0,0,0 1844 | 1843,0,0,0,0,0,0,0 1845 | 1844,4,2,17,3,3,4,3 1846 | 1845,2,5,11,6,7,6,5 1847 | 1846,0,0,0,0,0,0,0 1848 | 1847,0,0,0,0,0,0,0 1849 | 1848,0,0,0,0,0,0,0 1850 | 1849,0,0,0,0,0,0,0 1851 | 1850,0,0,0,0,0,0,0 1852 | 1851,0,0,0,0,0,0,0 1853 | 1852,0,0,0,0,0,0,0 1854 | 1853,0,0,0,0,0,0,0 1855 | 1854,0,0,0,0,0,0,0 1856 | 1855,0,0,0,0,0,0,0 1857 | 1856,0,0,0,0,0,0,0 1858 | 1857,0,0,0,0,0,0,0 1859 | 1858,0,0,0,0,0,0,0 1860 | 1859,6,9,2,4,10,6,6 1861 | 1860,0,0,0,0,0,0,0 1862 | 1861,0,0,0,0,0,0,0 1863 | 1862,0,0,0,0,0,0,0 1864 | 1863,0,0,0,0,0,0,0 1865 | 1864,0,0,0,0,0,0,0 1866 | 1865,0,0,0,0,0,0,0 1867 | 1866,0,0,0,0,0,0,0 1868 | 1867,0,0,0,0,0,0,0 1869 | 1868,10,4,5,8,4,7,5 1870 | 1869,0,0,0,0,0,0,0 1871 | 1870,0,0,0,0,0,0,0 1872 | 1871,0,0,0,0,0,0,0 1873 | 1872,0,0,0,0,0,0,0 1874 | 1873,0,0,0,0,0,0,0 1875 | 1874,13,0,5,6,9,17,7 1876 | 1875,1,1,0,0,0,0,0 1877 | 1876,0,0,0,0,0,0,0 1878 | 1877,0,0,0,0,0,0,0 1879 | 1878,0,0,0,0,0,0,0 1880 | 1879,0,0,0,0,0,0,0 1881 | 1880,0,0,0,0,0,0,0 1882 | 1881,0,0,0,0,0,0,0 1883 | 1882,0,0,0,0,0,0,0 1884 | 1883,8,4,5,4,9,7,4 1885 | 1884,4,2,1,2,3,9,1 1886 | 1885,0,0,0,0,0,0,0 1887 | 1886,0,0,0,0,0,0,0 1888 | 1887,0,0,0,0,0,0,0 1889 | 1888,9,4,6,11,11,12,9 1890 | 1889,0,0,0,0,0,0,0 1891 | 1890,1,2,0,1,0,3,1 1892 | 1891,0,0,0,0,0,0,0 1893 | 1892,0,0,0,0,0,0,0 1894 | 1893,2,4,3,5,6,6,3 1895 | 1894,0,0,0,0,0,0,0 1896 | 1895,0,0,0,0,0,0,0 1897 | 1896,0,0,0,0,0,0,0 1898 | 1897,0,0,0,0,0,0,0 1899 | 1898,0,0,0,0,0,0,0 1900 | 1899,0,0,0,0,0,0,0 1901 | 1900,0,4,3,5,2,1,0 1902 | 1901,0,0,0,0,0,0,0 1903 | 1902,1,0,0,0,0,2,0 1904 | 1903,12,4,12,5,9,17,14 1905 | 1904,0,0,0,0,0,0,0 1906 | 1905,4,4,3,5,6,5,5 1907 | 1906,0,0,0,0,0,0,0 1908 | 1907,3,2,3,0,5,1,1 1909 | 1908,0,0,0,0,0,0,0 1910 | 1909,0,0,0,0,0,0,0 1911 | 1910,2,1,2,1,1,3,0 1912 | 1911,6,0,4,8,5,5,7 1913 | 1912,6,4,5,4,12,5,6 1914 | 1913,0,0,0,0,0,0,0 1915 | 1914,16,17,16,22,26,9,15 1916 | 1915,6,3,7,3,4,5,1 1917 | 1916,17,9,18,22,21,17,16 1918 | 1917,0,0,0,0,0,0,0 1919 | 1918,0,0,0,0,0,0,0 1920 | 1919,0,4,0,2,7,4,4 1921 | 1920,0,0,0,0,0,0,0 1922 | 1921,0,0,0,0,0,0,0 1923 | 1922,0,0,0,0,0,0,0 1924 | 1923,0,0,0,0,0,0,0 1925 | 1924,6,5,1,2,4,10,8 1926 | 1925,0,0,0,0,0,0,0 1927 | 1926,0,0,0,0,0,0,0 1928 | 1927,0,0,0,0,0,0,0 1929 | 1928,0,0,0,0,0,0,0 1930 | 1929,0,0,0,0,0,0,0 1931 | 1930,0,0,0,0,0,0,0 1932 | 1931,0,0,0,0,0,0,0 1933 | 1932,0,0,0,0,0,0,0 1934 | 1933,0,0,0,0,0,0,0 1935 | 1934,0,0,0,0,0,0,0 1936 | 1935,0,0,0,0,0,0,0 1937 | 1936,0,0,0,0,0,0,0 1938 | 1937,0,0,0,0,0,0,0 1939 | 1938,0,0,0,0,0,0,0 1940 | 1939,0,0,0,0,0,0,0 1941 | 1940,6,7,7,0,14,6,6 1942 | 1941,0,0,0,0,0,0,0 1943 | 1942,0,0,0,0,0,0,0 1944 | 1943,0,0,0,0,0,0,0 1945 | 1944,0,0,0,0,0,0,0 1946 | 1945,0,0,0,0,0,0,0 1947 | 1946,0,0,0,0,0,0,0 1948 | 1947,2,0,1,7,3,2,1 1949 | 1948,0,0,0,0,0,0,0 1950 | 1949,0,1,0,0,0,0,0 1951 | 1950,0,0,0,0,0,0,0 1952 | 1951,0,0,1,0,0,0,0 1953 | 1952,0,0,0,0,0,0,0 1954 | 1953,0,0,0,0,0,0,0 1955 | 1954,0,0,0,0,0,0,0 1956 | 1955,0,0,0,0,0,0,0 1957 | 1956,16,17,20,22,28,21,24 1958 | 1957,5,10,2,6,11,18,9 1959 | 1958,0,0,0,0,0,0,0 1960 | 1959,0,0,0,0,0,0,0 1961 | 1960,0,0,0,0,0,0,0 1962 | 1961,0,0,0,0,0,0,0 1963 | 1962,0,0,0,0,0,0,0 1964 | 1963,7,3,3,6,3,8,3 1965 | 1964,0,0,0,0,0,0,0 1966 | 1965,2,1,2,0,2,4,3 1967 | 1966,0,0,0,0,0,0,0 1968 | 1967,0,0,0,0,0,0,0 1969 | 1968,0,0,0,0,0,0,0 1970 | 1969,0,0,0,0,0,0,0 1971 | 1970,0,0,0,0,0,0,0 1972 | 1971,0,0,0,0,0,0,0 1973 | 1972,0,0,0,0,0,0,0 1974 | 1973,0,0,0,0,0,0,0 1975 | 1974,0,0,0,0,0,0,0 1976 | 1975,0,0,0,0,0,0,0 1977 | 1976,0,0,0,0,0,0,0 1978 | 1977,0,0,0,0,0,0,0 1979 | 1978,0,0,0,0,0,0,1 1980 | 1979,0,0,0,0,0,0,0 1981 | 1980,0,0,0,0,0,0,0 1982 | 1981,0,0,0,0,0,0,0 1983 | 1982,0,0,0,0,0,0,0 1984 | 1983,0,0,0,0,0,0,0 1985 | 1984,0,0,0,0,0,0,0 1986 | 1985,0,0,0,0,0,0,0 1987 | 1986,5,4,6,5,9,6,8 1988 | 1987,0,0,0,0,0,0,0 1989 | 1988,0,0,0,0,0,0,0 1990 | 1989,0,0,0,0,0,0,0 1991 | 1990,0,0,0,0,0,0,0 1992 | 1991,8,8,6,10,14,14,6 1993 | 1992,0,0,0,0,0,0,0 1994 | 1993,0,0,0,0,0,0,0 1995 | 1994,0,0,0,0,0,0,0 1996 | 1995,0,0,0,0,0,0,0 1997 | 1996,12,14,8,12,19,22,15 1998 | 1997,0,0,0,0,0,0,0 1999 | 1998,0,0,1,0,1,0,1 2000 | 1999,0,0,0,0,0,0,0 2001 | 2000,0,0,0,0,0,0,0 2002 | -------------------------------------------------------------------------------- /main/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/__init__.py -------------------------------------------------------------------------------- /main/analysis/analysis_weather.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Roger' 2 | 3 | import numpy as np 4 | 5 | ## create the csv data to analysis weather, some steps we use python to slove, and others we use mysql to create tables 6 | shop = np.loadtxt('../data/shopid_day_num.txt', delimiter=',') 7 | 8 | city_dict = {} 9 | city_weather = {} 10 | city_wind = {} 11 | city_temp = {} 12 | # load city weather 13 | with open('../data/city_weather.csv') as f: 14 | cnt = 0 15 | for line in f.readlines(): 16 | item = line.strip().split(',') 17 | if item[1] == '2015-12-12': 18 | continue 19 | if item[0] not in city_weather: 20 | city_weather[item[0]] = [] 21 | if item[0] not in city_dict.values(): 22 | city_dict[cnt] = item[0] 23 | cnt += 1 24 | city_weather[item[0]].append(item[4]) 25 | # TODO: add wind and temp 26 | # city_wind[item[0]].append(item[5]) 27 | 28 | # simple test 29 | print(city_weather['上海'].__len__()) 30 | print(city_dict.__len__(), city_dict) 31 | 32 | # load city info 33 | shop_info = {} 34 | cat_1_dict = {} 35 | cat_2_dict = {} 36 | cat_3_dict = {} 37 | 38 | # process data 39 | with open('../data/shop_info.txt') as f: 40 | cnt1 = 0 41 | cnt2 = 0 42 | cnt3 = 0 43 | for line in f.readlines(): 44 | item = line.strip().split(',') 45 | if int(item[0]) not in shop_info: 46 | shop_info[int(item[0])] = {} 47 | shop_info[int(item[0])]['city'] = item[1] 48 | shop_info[int(item[0])]['cat_1'] = item[7] 49 | shop_info[int(item[0])]['cat_2'] = item[8] 50 | shop_info[int(item[0])]['cat_3'] = item[9] 51 | 52 | if item[7] not in cat_1_dict.values(): 53 | cat_1_dict[cnt1] = item[7] 54 | cnt1 += 1 55 | if item[8] not in cat_2_dict.values(): 56 | cat_2_dict[cnt2] = item[8] 57 | cnt2 += 1 58 | if item[9] not in cat_3_dict.values(): 59 | cat_3_dict[cnt3] = item[9] 60 | cnt3 += 1 61 | 62 | # print(shop_info) 63 | # print(cat_1_dict) 64 | # print(cat_2_dict) 65 | # print(cat_3_dict) 66 | 67 | # if it is rain then 0 other 1 68 | days = 488 69 | 70 | # 0 cityid 1 cat1 2 cat2 3 cat3 71 | cut_tag = np.zeros([2000, days + 4]) 72 | 73 | for i in range(2000): 74 | id = int(shop[i, 0]) 75 | city = shop_info[id]['city'] 76 | cat1 = shop_info[id]['cat_1'] 77 | cat2 = shop_info[id]['cat_2'] 78 | cat3 = shop_info[id]['cat_3'] 79 | for j in range(488): 80 | wea = city_weather[city][j] 81 | 82 | if '雨' in wea: 83 | cut_tag[i, j + 4] = 1 84 | 85 | for cityid in city_dict: 86 | if city_dict[cityid] == city: 87 | cut_tag[i, 0] = cityid 88 | 89 | for catid in cat_1_dict: 90 | if cat_1_dict[catid] == cat1: 91 | cut_tag[i, 1] = catid 92 | 93 | for catid in cat_2_dict: 94 | if cat_2_dict[catid] == cat2: 95 | cut_tag[i, 2] = catid 96 | 97 | for catid in cat_3_dict: 98 | if cat_3_dict[catid] == cat3: 99 | cut_tag[i, 3] = catid 100 | 101 | ## cnt all and save csv 102 | with open('../als/weather/weather_city.csv', 'w') as f: 103 | f.write('id, shop, cat_1, cat_2, cat_3, rain_cnt, nrain_cnt, rnr_cnt_rate, rain_avg, nrain_avg, rnr_avg_rate\n') 104 | for i in range(2000): 105 | id = shop[i, 0] 106 | city = city_dict[cut_tag[i, 0]] 107 | cat1 = cat_1_dict[cut_tag[i, 1]] 108 | cat2 = cat_2_dict[cut_tag[i, 2]] 109 | cat3 = cat_3_dict[cut_tag[i, 3]] 110 | 111 | rain = shop[i, 1:][cut_tag[i, 4:] == 1] 112 | no_rain = shop[i, 1:][cut_tag[i, 4:] == 0] 113 | 114 | rain_cnt = rain.shape[0] 115 | nrain_cnt = no_rain.shape[0] 116 | rain_avg = np.mean(rain).round(2) 117 | nrain_avg = np.mean(no_rain).round(2) 118 | 119 | r_nr_rate = (rain_avg * 1.0 / nrain_avg).round(4) 120 | r_nr_avg = round(rain_cnt * 1.0 / nrain_cnt, 4) 121 | # print(type(r_nr_rate), type(r_nr_avg)) 122 | f.write('{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}, {10}\n'.format(int(id), city, cat1, cat2, cat3, rain_cnt, 123 | nrain_cnt, r_nr_avg, rain_avg, nrain_avg, 124 | r_nr_rate)) 125 | -------------------------------------------------------------------------------- /main/analysis/base_als.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Roger' 2 | ## from py3 to py2 3 | import numpy as np 4 | 5 | ## save median, var, std 6 | shop = np.loadtxt('../data/shopid_day_num.txt', delimiter=',') 7 | 8 | all = shop[:, -21:] 9 | 10 | week3 = shop[:, -7:] 11 | 12 | month = shop[:, -14:] 13 | 14 | res = np.zeros([2000, 13]) 15 | 16 | res[:, 0] = shop[:, 0] 17 | res[:, 1] = np.mean(all, axis=1) 18 | res[:, 2] = np.mean(month, axis=1) 19 | res[:, 3] = np.mean(week3, axis=1) 20 | res[:, 4] = np.median(all, axis=1) 21 | res[:, 5] = np.median(month, axis=1) 22 | res[:, 6] = np.median(week3, axis=1) 23 | res[:, 7] = np.var(all, axis=1) 24 | res[:, 8] = np.var(month, axis=1) 25 | res[:, 9] = np.var(week3, axis=1) 26 | res[:, 10] = np.std(all, axis=1) 27 | res[:, 11] = np.std(month, axis=1) 28 | res[:, 12] = np.std(week3, axis=1) 29 | 30 | np.savetxt('../data/all_mon_week3_mean_med_var_std.csv', res, delimiter=',', fmt='%d') 31 | -------------------------------------------------------------------------------- /main/analysis/test_weather.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Roger' 2 | 3 | import numpy as np 4 | import pandas as pd 5 | 6 | ## analysis the weather to find if there is any rules 7 | ## count the weather with good or bad 8 | ## and then try to more concrete analysis 9 | 10 | ## count the weather from 10-11 to 11-14 11 | def count_wtr(): 12 | time = pd.date_range('2016-10-11','2016-11-14') 13 | weather = {} 14 | wind = {} 15 | shop_info = {} 16 | # load shop info 17 | with open('../data/shop_info.txt') as f: 18 | for line in f.readlines(): 19 | item = line.strip().split(',') 20 | if int(item[0]) not in shop_info: 21 | shop_info[item[0]] = {} 22 | shop_info[item[0]]['city'] = item[1] 23 | 24 | # load city weather and create the weather dict 25 | with open('city_weather.csv') as f: 26 | for line in f.readlines(): 27 | item = line.strip().split(',') 28 | if item[1] not in time: 29 | continue 30 | item[4] = item[4].replace('转','-').replace('~','-') 31 | if item[4] not in weather: 32 | weather[item[4]] = 0 33 | weather[item[4]] += 1 34 | for i in shop_info: 35 | if item[0] == shop_info[i]['city']: 36 | shop_info[i][item[1]] = item[4] 37 | 38 | print(weather.__len__()) 39 | print(sum(weather.values())) 40 | # print the weather 41 | for w in weather: 42 | print(w, weather[w]) 43 | 44 | date = np.vectorize(lambda s: s.strftime('%Y-%m-%d'))(time.to_pydatetime()) 45 | # save weather data 46 | with open('weather-10-11.csv', 'w') as f: 47 | 48 | for i in range(1,2001): 49 | f.write('{0}'.format(i)) 50 | for j in date: 51 | f.write(',{0}'.format(shop_info[str(i)][j])) 52 | f.write('\n') 53 | for w in wind: 54 | print(w, wind[w]) 55 | 56 | 57 | ## count the weather data of predict days 2016-11-01 to 2016-11-14 58 | ## to find out if there is any inflect to predict 59 | 60 | def cnt_weather_predict_day(): 61 | # load weather data 62 | weather = open('data/weather-11-14.csv') 63 | weather_cnt = {} 64 | for line in weather.readlines(): 65 | item = line.strip().split(',') 66 | id = int(item[0]) 67 | if id not in weather_cnt: 68 | weather_cnt[id] = [] 69 | for k in item[1:]: 70 | weather_cnt[id].append(k) 71 | # count for day 11-11, 11-12 11-14 72 | day_special = [] 73 | for id in weather_cnt: 74 | print('{0}\t{1}\t{2}'.format(weather_cnt[id][-4], weather_cnt[id][-3], weather_cnt[id][-1])) 75 | day_special.append([weather_cnt[id][-4], weather_cnt[id][-3], weather_cnt[id][-1]]) 76 | 77 | # count for 11-11 11-12 11-14 78 | day = [11, 12, 14] 79 | for j in [0, 1, 2]: 80 | cnt_sunny = 0 81 | cnt_yin = 0 82 | cnt_dy = 0 83 | cnt_rain = 0 84 | for i in day_special: 85 | # print(i[j]) 86 | if '晴' in i[j]: 87 | cnt_sunny += 1 88 | if '雨' in i[j] or '雪' in i[j]: 89 | cnt_rain += 1 90 | if '多云' in i[j]: 91 | cnt_dy += 1 92 | if '阴' in i[j]: 93 | cnt_yin += 1 94 | 95 | print(day[j], cnt_sunny, cnt_rain, cnt_dy, cnt_yin) 96 | 97 | ## analysis the rate between rain and no rain 98 | cnt_weather_predict_day() 99 | predict = np.loadtxt('../res/result_3_1_base_rule_100_features_15_40_2_avg_123.csv',delimiter=',') 100 | weather_list = [] 101 | weather_tmp = {} 102 | 103 | with open('weather-10-11.csv') as f: 104 | for line in f.readlines(): 105 | item = line.strip().split(',') 106 | weather_list.append(item) 107 | 108 | with open('als/weather/weather_city.csv') as f: 109 | for line in f.readlines(): 110 | item = line.strip().split(',') 111 | if int(item[0]) not in weather_tmp: 112 | weather_tmp[int(item[0])] = float(item[11]) 113 | 114 | print(weather_list) 115 | print(weather_tmp) 116 | 117 | ## analysis the rate of last 3 weeks 118 | rate = np.zeros(2000) 119 | for i in weather_list: 120 | rain = 0 121 | # print(len(i[1:22])) 122 | for j in i[1:22]: 123 | if '雨' in j or '雪' in j: 124 | rain += 1 125 | rate[int(i[0]) - 1] = rain / 21.0 126 | for xx in [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]: 127 | print('{0} rain norain'.format(xx), np.sum(rate <= xx) * 1.0 / rate.shape[0], np.sum(rate >= xx) / rate.shape[0]) 128 | print('rain in all 3 week:', np.sum(rate > 0.5) * 1.0 / rate.shape[0]) 129 | print('rain in all 3 week:', np.sum(rate < 0.7) * 1.0 / rate.shape[0]) 130 | 131 | 132 | ## find out the shop that inflected by weather 133 | 134 | # shop04 = predict[rate >= 0.4, 0] 135 | # shop05 = predict[rate >= 0.5, 0] 136 | # 137 | # print(shop04.shape, shop05.shape) 138 | # 139 | # extsamelist = {} 140 | # for i in shop04: 141 | # extsamelist[i] = 1 142 | # for j in shop05: 143 | # if i == j: 144 | # extsamelist.pop(i) 145 | # 146 | # print(extsamelist.__len__()) 147 | # 148 | # np.savetxt('final/final_not_same_4_5.csv', np.array(list(extsamelist.keys())), fmt='%d', delimiter=',') 149 | # np.savetxt('final/final_shop4.csv', shop04, fmt='%d', delimiter=',') 150 | # np.savetxt('final/final_shop5.csv', shop05, fmt='%d', delimiter=',') 151 | 152 | 153 | ''' 154 | 雨夹雪 5 155 | 中雪 1 156 | 中到大雪 2 157 | 晴 612 158 | 小雪 2 159 | 多云 560 160 | 雾 12 161 | 小到中雨 5 162 | 阴 202 163 | 小雨 216 164 | 霾 46 165 | 阵雨 37 166 | 小到中雪 2 167 | 阵雪 2 168 | 中雨 18 169 | ''' 170 | -------------------------------------------------------------------------------- /main/analysis/test_week2.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Roger' 2 | 3 | import numpy as np 4 | 5 | ## simple test week for week tend. 6 | ## and we find out this is no use in the middle of the game 7 | 8 | def find_week(path, data_name, shop, time, analysis_name): 9 | week_list = ['周一','周二','周三','周四','周五','周六','周日'] 10 | f = open(path + analysis_name, 'w') 11 | shopdata = shop 12 | dayofweek = time.dayofweek 13 | # sum_all_week = np.zeros([2000,7]) 14 | avg_week = np.zeros([2000,7]) 15 | # avg_16_week = np.zeros([,7]) 16 | for i in range(2000): 17 | for j in range(7): 18 | # sum_all_week[i,j] = np.sum(shopdata[dayofweek == j,i]) 19 | avg_week[i,j] = np.sum(shopdata[dayofweek == j,i]) * 1.0/ shopdata[dayofweek == j,i].shape[0] 20 | 21 | # np.savetxt('sum_all_week.csv', sum_all_week,delimiter=',', fmt='%d') 22 | np.savetxt(path + data_name, avg_week,delimiter=',', fmt='%d') 23 | 24 | # mean tend 25 | f.write('均值趋势分析:\n') 26 | max_per_week = np.zeros(2000) 27 | min_per_week = np.zeros(2000) 28 | for i in range(2000): 29 | for j in range(7): 30 | if avg_week[i,j] == np.max(avg_week[i]): 31 | max_per_week[i] = j 32 | if avg_week[i,j] == np.min(avg_week[i]): 33 | min_per_week[i] = j 34 | print(max_per_week.shape) 35 | for i in range(7): 36 | print(np.sum(max_per_week == i)) 37 | f.write('{0}最大的商家有 {1} 个, 占比 {2} %\n'.format(week_list[i], np.sum(max_per_week == i), (np.sum(max_per_week == i) / 2000 * 100).round(2))) 38 | 39 | if __name__ == '__main__': 40 | shop = np.loadtxt('../data/shopid_day_num.txt', delimiter=',') 41 | print(shop.shape) 42 | # shop = shop.T 43 | # time = pd.date_range('2015-7-1', '2016-10-31', name='Date', freq='D') 44 | # print('2015-7-11' in time) 45 | # shop = np.concatenate((shop[0:165, :], np.zeros([1, 2000]), shop[165:, :]), axis=0) 46 | # shop_data = pd.DataFrame(data=shop[1:, :], index=time, columns=range(1, 2001)) 47 | # print(dt.datetime(2016,10,31) - dt.datetime(2016,1,1)) 48 | # find_week('analysis/','all_week_avg.csv',shop[1:,:],time,'all_week_avg.als') 49 | # find_week('analysis/','16_week_avg.csv',shop[-304:],time[-304:],'16_week_avg.als') 50 | # find_week('analysis/','last3_week_avg.csv',shop[-21:,:],time[-21:],'last3_week_avg.als') 51 | # find_week('analysis/','lask5_week_avg.csv',shop[-35:,:],time[-35:],'last5_week_avg.als') 52 | # series = pd.date_range('2016-10-11', '2016-11-14') 53 | # print('2016-10-11' in series) 54 | -------------------------------------------------------------------------------- /main/analysis/testweek.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Roger' 2 | 3 | # py3 to py2 4 | import numpy as np 5 | import pandas as pd 6 | 7 | ## analysis and try to find out some rules from the relation between MONTHS and WEE. 8 | 9 | # load data and result 10 | result = np.loadtxt('zj/roger_base_test.csv', delimiter=',') 11 | shop = np.loadtxt('shopid_day_num.txt', delimiter=',') 12 | timerange = pd.date_range('2016-1-1', '2016-10-31', freq='D') 13 | 14 | weeknum = timerange.weekday 15 | shop = shop[:, -305:] 16 | 17 | weekbegin = 3 18 | 19 | ## cnt for weeks, output the weeks cnt in file 20 | ## count the avg of weekdays and weekends 21 | ## count the rate of the comparing 22 | with open('als/week/weeks_cnt.txt', 'w') as f: 23 | f.write('id,end_bigger,end_smaller,end_equal\n') 24 | print('write to als/week/weeks_cnt.txt') 25 | all = [] 26 | for i in range(weekbegin, 304, 7): 27 | weekday_avg = np.mean(shop[:, i:i + 5], axis=1) 28 | weekend_avg = np.mean(shop[:, i + 5:i + 7], axis=1) 29 | bigger = np.sum(weekend_avg > weekday_avg) / 2000.0 # the rate of bigger 30 | smaller = np.sum(weekend_avg < weekday_avg) / 2000.0 # the rate of smaller 31 | same = np.sum(weekend_avg == weekday_avg) / 2000.0 # the rate of same 32 | f.write('{0},{1},{2}\n'.format(round(bigger, 2), round(smaller, 2), round(same, 2))) 33 | if bigger > smaller: 34 | all.append(i) 35 | print('rate of bigger weeks:', all.__len__() / (301.0 / 7.0)) 36 | print(all) # print the biggers 37 | 38 | ## cnt for weeks, no output 39 | ## count the rate between last two weeks and first two weeks every month 40 | ## if there is any relation between them 41 | 42 | monthnum = timerange.month 43 | first_two_week = np.zeros([2000, 126]) 44 | last_two_week = np.zeros([2000, 126]) 45 | for i in range(9): 46 | wk = monthnum == (i + 2) 47 | first_two_week[:, 14 * i: 14 * (i + 1)] = shop[:, wk][:, 0:14] 48 | wk = monthnum == (i + 1) 49 | last_two_week[:, 14 * i: 14 * (i + 1)] = shop[:, wk][:, -14:] 50 | 51 | rate = np.zeros([2000, 9]) # init the rate 52 | 53 | for i in range(9): 54 | first_mean = np.mean(first_two_week[:, 14 * i: (i + 1) * 14], axis=1) # first two weeks' avg 55 | last_mean = np.mean(last_two_week[:, 14 * i: (i + 1) * 14], axis=1) # last two weeks' avg 56 | rate[:, i] = np.mean(first_two_week[:, 14 * i: (i + 1) * 14], axis=1) / np.mean( 57 | last_two_week[:, 14 * i: (i + 1) * 14], axis=1) 58 | 59 | # np.nan_to_num change the inf to the max int which can not easy analysis so that we try to transform by ourselves 60 | for i in range(9): 61 | for j in range(2000): 62 | if np.isnan(rate[j, i]): 63 | rate[j, i] = 0 64 | if np.isinf(rate[j, i]): 65 | rate[j, i] = 999 66 | 67 | # print the result 68 | print(np.mean(first_two_week[4, 14 * 1: (1 + 1) * 14])) 69 | print(np.mean(last_two_week[4, 14 * 1: (1 + 1) * 14])) 70 | np.savetxt('als/week/last_first_rate.csv', rate, delimiter=',', fmt='%2.4f') 71 | 72 | # divide the rate into big and small rate 73 | length = 5 74 | big = rate[:, -1] > 1 75 | small = rate[:, -1] < 1 76 | 77 | for i in range(2, 2): 78 | big = np.logical_and(big, rate[:, -i] > 1) 79 | small = np.logical_and(small, rate[:, -i] < 1) 80 | 81 | print(np.sum(big)) 82 | print(np.sum(small)) 83 | 84 | ## analysis two week's relation in first two weeks 85 | for i in range(0, 140, 14): 86 | first = np.mean(first_two_week[:, i: i + 7], axis=1) 87 | last = np.mean(first_two_week[:, i + 7: i + 14], axis=1) 88 | bigger = np.sum(first < last) / 2000.0 89 | print('month bigger:', bigger) 90 | 91 | ## analysis if there is any tend between weeks 92 | ## include increase and decrease with stable rate or f_l weeks rate 93 | ## find out the month which always increase or decrease 94 | 95 | bgthen = np.zeros(2000) 96 | lwthen = np.zeros(2000) 97 | 98 | for monidx in range(10): 99 | rate = np.zeros(2000) 100 | for i in range(2000): 101 | cnt_inc = 0 102 | cnt_dec = 0 103 | for j in range(monidx * 14, 140, 14): 104 | first = np.mean(first_two_week[i, j: j + 7]) 105 | last = np.mean(first_two_week[i, j + 7: j + 14]) 106 | if first > last: 107 | cnt_inc += 1 108 | if first < last: 109 | cnt_dec += 1 110 | rate[i] += last * 1.0/ first 111 | 112 | rate[i] = rate[i] / (10.0 - monidx) 113 | bgthen[i] = cnt_inc / (10.0 - monidx) 114 | lwthen[i] = cnt_dec / (10.0 - monidx) 115 | 116 | result[bgthen == 1, -7:] = result[bgthen == 1, 1:-7] * rate[bgthen == 1].reshape(np.sum(bgthen == 1), 1) 117 | result[bgthen == 0, 1:-7] = result[bgthen == 0, 1:-7] * 0.99 118 | 119 | print('month', monidx + 1, 'f > l always', np.sum(bgthen == 1)) 120 | print('month', monidx + 1, 'f < l always', np.sum(lwthen == 1)) 121 | print('rate f > l', rate[bgthen == 1]) 122 | 123 | np.savetxt('test/onlydown_with_5month.csv', result, fmt='%d', delimiter=',') 124 | 125 | ## analysis the tend of weeks 126 | weekbegin = 3 127 | week_mean = np.zeros([2000, 43]) 128 | idxw = 0 129 | for i in range(weekbegin, 304, 7): 130 | week_mean[:, idxw] = np.mean(shop[:, i:i + 7], axis=1) 131 | for j in range(2000): 132 | if week_mean[j, idxw] == 0: 133 | week_mean[j, idxw] = 1 134 | idxw += 1 135 | 136 | week_tend = np.zeros([2000, 43]) 137 | for i in range(1, week_mean.shape[1]): 138 | week_tend[:, i - 1] = week_mean[:, i - 1] * 1.0/ week_mean[:, i] 139 | 140 | week_tend[:, -1] = week_mean[:, -1] * 1.0/ np.mean(result[:, 1:8]) 141 | # weekend_avg = np.mean(shop[:,i+5:i+7], axis=1) 142 | 143 | # load the weektend data 144 | np.savetxt('als/week/weektend.csv', week_tend, delimiter=',') 145 | 146 | week_part = week_tend[-20:] 147 | print(week_tend) 148 | 149 | # output the result for rules test 150 | cntd = 0 151 | cnta = 0 152 | for i in range(2000): 153 | if week_tend[i, -4] < 1 and week_tend[i, -2] < 1 and week_tend[i, -3] < 1: 154 | cntd += 1 155 | result[i, -7:] = result[i, -7:] * 0.98 156 | if week_tend[i, -2] > 1 and week_tend[i, -3] > 1: 157 | cnta += 1 158 | result[i, -7:] = result[i, -7:] * 1.04 159 | print(cntd, cnta) 160 | np.savetxt('test/justbesttest.csv', result, delimiter=',', fmt='%d') 161 | -------------------------------------------------------------------------------- /main/analysis/weather/cat_1.csv: -------------------------------------------------------------------------------- 1 | 休闲娱乐,2,213,275,0.7745,27.01,22.13,0.8193 2 | 购物,1,122,366,0.3333,27,32.04,0.8427 3 | 美发/美容/美甲,1,115,373,0.3083,17.88,15.07,0.8428 4 | 医疗健康,2,210.5,277.5,0.7586,12.805,14.81,0.8646 5 | 超市便利店,579,199.8411,288.1589,0.6935,87.6833,87.4788,0.9977 6 | 美食,1415,202.5512,285.4488,0.7096,65.0138,64.905,0.9983 7 | -------------------------------------------------------------------------------- /main/analysis/weather/cat_2.csv: -------------------------------------------------------------------------------- 1 | 网吧网咖,2.0000,213.0000,275.0000,0.7745,27.0100,22.1300,0.8193 2 | 本地购物,1.0000,122.0000,366.0000,0.3333,27.0000,32.0400,0.8427 3 | 美容美发,1.0000,115.0000,373.0000,0.3083,17.8800,15.0700,0.8428 4 | 药店,2.0000,210.5000,277.5000,0.7586,12.8050,14.8100,0.8646 5 | 汤/粥/煲/砂锅/炖菜,7.0000,210.0000,278.0000,0.7554,58.5071,51.6957,0.8836 6 | 其他美食,44.0000,208.8182,279.1818,0.7480,48.9818,45.0309,0.9193 7 | 烧烤,9.0000,213.4444,274.5556,0.7774,40.9122,37.7400,0.9225 8 | 火锅,33.0000,195.3333,292.6667,0.6674,40.3794,37.3697,0.9255 9 | 小吃,156.0000,208.2051,279.7949,0.7441,44.9542,42.2478,0.9398 10 | 休闲茶饮,177.0000,202.8814,285.1186,0.7116,52.7896,55.1674,0.9569 11 | 休闲食品,150.0000,219.6467,268.3533,0.8185,50.6305,52.6908,0.9609 12 | 个人护理,1.0000,195.0000,293.0000,0.6655,38.1700,37.0800,0.9714 13 | 便利店,206.0000,200.1165,287.8835,0.6951,57.1211,58.5078,0.9763 14 | 烘焙糕点,122.0000,205.4262,282.5738,0.7270,58.5862,57.2634,0.9774 15 | 中餐,78.0000,203.6154,284.3846,0.7160,40.7091,40.1079,0.9852 16 | 超市,372.0000,199.7016,288.2984,0.6927,104.7406,103.6573,0.9897 17 | 快餐,639.0000,196.0939,291.9061,0.6718,83.6543,83.8044,0.9982 18 | -------------------------------------------------------------------------------- /main/analysis/weather/cat_3.csv: -------------------------------------------------------------------------------- 1 | 美食特产,1,172,316,0.5443,12.31,20.07,0.6134 2 | 闽菜,1,216,272,0.7941,11.94,15.55,0.7678 3 | 上海本帮菜,1,226,262,0.8626,11.6,14.5,0.8 4 | 其它烧烤,1,115,373,0.3083,25.17,20.84,0.828 5 | 自助餐,3,228.6667,259.3333,0.8817,51.9767,44.3333,0.8529 6 | 香锅/烤鱼,1,232,256,0.9063,25.14,21.45,0.8532 7 | 砂锅/煲类/炖菜,4,198.25,289.75,0.6842,77.08,67.115,0.8707 8 | 咖啡,6,196.1667,291.8333,0.6722,35.2433,30.8283,0.8747 9 | 咖啡厅,2,165,323,0.5108,35.66,31.23,0.8758 10 | 川味/重庆火锅,13,187.7692,300.2308,0.6254,51.1954,45.2831,0.8845 11 | 海鲜,3,148,340,0.4353,36.7,41.1,0.8929 12 | 西北菜,6,218.3333,269.6667,0.8096,54.3333,48.6133,0.8947 13 | 西餐,19,209.8421,278.1579,0.7544,51.7916,47.1984,0.9113 14 | 熟食,4,214,274,0.781,38.8875,35.5625,0.9145 15 | 零食,22,218.8182,269.1818,0.8129,42.2586,38.7005,0.9158 16 | 粥,3,225.6667,262.3333,0.8602,33.7433,31.1367,0.9228 17 | 其他餐饮美食,7,204,284,0.7183,64.2429,59.5543,0.927 18 | 饮品/甜点,67,197.194,290.806,0.6781,64.9054,69.9036,0.9285 19 | 中式烧烤,8,225.75,262.25,0.8608,42.88,39.8525,0.9294 20 | 其它烘焙糕点,12,189.5833,298.4167,0.6353,46.6675,43.3733,0.9294 21 | 其它小吃,87,203.4023,284.5977,0.7147,45.9418,42.9179,0.9342 22 | 其它地方菜,20,174.4,313.6,0.5561,31.898,29.8425,0.9356 23 | 生鲜水果,111,221.1351,266.8649,0.8286,52.7559,56.2577,0.9378 24 | 面点,50,215.72,272.28,0.7923,45.9678,43.3896,0.9439 25 | 湖北菜,2,195,293,0.6655,11.08,11.72,0.9454 26 | 日韩料理,15,205.8,282.2,0.7293,37.702,35.6473,0.9455 27 | 粤菜,12,222.3333,265.6667,0.8369,53.99,56.9392,0.9482 28 | 东北菜,3,240.6667,247.3333,0.973,35.92,34.2567,0.9537 29 | 川菜,13,203.6923,284.3077,0.7165,48.0831,45.8608,0.9538 30 | 其它快餐,14,209.1429,278.8571,0.75,36.2007,34.5736,0.9551 31 | 台湾菜,2,224,264,0.8485,26.29,27.5,0.956 32 | 冰激凌,10,185.5,302.5,0.6132,37.693,39.259,0.9601 33 | 其它火锅,11,180.9091,307.0909,0.5891,39.8727,38.4055,0.9632 34 | 湘菜,1,195,293,0.6655,18.72,18.09,0.9663 35 | 米粉/米线,15,209.4667,278.5333,0.752,37.4647,36.3373,0.9699 36 | 麻辣烫/串串香,9,223.8889,264.1111,0.8477,25.3756,24.6733,0.9723 37 | 奶茶,92,210.1739,277.8261,0.7565,47.1238,48.2725,0.9762 38 | 面包,71,201.8169,286.1831,0.7052,55.8706,54.8242,0.9813 39 | 蛋糕,39,216.8718,271.1282,0.7999,67.1974,65.9777,0.9818 40 | 江浙菜,13,222.6923,265.3077,0.8394,44.4915,45.1023,0.9865 41 | 其它休闲食品,16,213.4375,274.5625,0.7774,49.7919,49.2206,0.9885 42 | 西式快餐,405,192.8469,295.1531,0.6534,102.3037,102.5533,0.9976 43 | ,585,199.6444,288.3556,0.6924,86.9968,86.7884,0.9976 44 | 中式快餐,220,201.2409,286.7591,0.7018,52.3422,52.4223,0.9985 45 | -------------------------------------------------------------------------------- /main/analysis/weather/city.csv: -------------------------------------------------------------------------------- 1 | 柳州,1,229,259,0.8842,14.03,28.3,0.4958 2 | 德阳,1,188,300,0.6267,7.63,13.99,0.5454 3 | 东营,1,79,409,0.1932,80.24,49.25,0.6138 4 | 邯郸,1,101,387,0.261,51.9,33.87,0.6526 5 | 锦州,1,104,384,0.2708,48.06,72.46,0.6633 6 | 张家口,1,133,355,0.3746,14.77,10.74,0.7271 7 | 洛阳,1,119,369,0.3225,94.61,69.39,0.7334 8 | 阳江,1,247,241,1.0249,13.77,18.55,0.7423 9 | 梧州,1,241,247,0.9757,47.12,61.42,0.7672 10 | 江门,5,224,264,0.8485,59.718,46.812,0.7839 11 | 东莞,13,242,246,0.9837,80.6062,63.5623,0.7886 12 | 乐山,1,213,275,0.7745,93.83,115.76,0.8106 13 | 六安,1,150,338,0.4438,43.28,35.16,0.8124 14 | 十堰,2,193,295,0.6542,46.28,37.995,0.821 15 | 蚌埠,3,166,322,0.5155,81.2167,67.0633,0.8257 16 | 通辽,1,100,388,0.2577,50.03,60.36,0.8289 17 | 惠州,7,228,260,0.8769,69.2357,57.7586,0.8342 18 | 濮阳,1,119,369,0.3225,70.75,59.7,0.8438 19 | 邢台,1,118,370,0.3189,84.6,99.95,0.8464 20 | 青岛,23,105,383,0.2742,43.3304,51.1148,0.8477 21 | 佛山,19,238,250,0.952,66.8926,57.0068,0.8522 22 | 石家庄,7,117,371,0.3154,63.2571,73.9329,0.8556 23 | 自贡,1,190,298,0.6376,36.95,43.06,0.8581 24 | 大连,15,109,379,0.2876,57.6247,66.9787,0.8603 25 | 龙岩,1,259,229,1.131,27.87,24.08,0.864 26 | 上饶,1,220,268,0.8209,38.11,43.99,0.8663 27 | 南昌,19,195,293,0.6655,47.7858,55.1137,0.867 28 | 清远,1,144,344,0.4186,35.6,30.93,0.8688 29 | 珠海,9,208,280,0.7429,41.8178,48.0178,0.8709 30 | 徐州,4,124,364,0.3407,77.9475,89.465,0.8713 31 | 昆明,3,263,225,1.1689,56.5933,49.3467,0.872 32 | 衢州,3,99,389,0.2545,123.5433,108.02,0.8743 33 | 宁德,2,271,217,1.2488,37.225,42.35,0.879 34 | 株洲,3,225,263,0.8555,42.5133,48.2433,0.8812 35 | 天津,18,122,366,0.3333,43.1233,48.8978,0.8819 36 | 中山,3,210,278,0.7554,50.4233,44.7367,0.8872 37 | 舟山,3,223,265,0.8415,81.6767,92.0267,0.8875 38 | 金华,23,222,266,0.8346,75.49,84.9626,0.8885 39 | 铜陵,1,221,267,0.8277,106.79,119.52,0.8935 40 | 哈尔滨,6,136,352,0.3864,60.7917,67.9883,0.8941 41 | 贵阳,3,256,232,1.1034,65.7867,73.2833,0.8977 42 | 咸阳,1,136,352,0.3864,45.97,51.2,0.8979 43 | 汕尾,1,216,272,0.7941,52.76,47.69,0.9039 44 | 宜昌,3,226,262,0.8626,44.46,40.32,0.9069 45 | 泰州,3,183,305,0.6,86.5633,78.5167,0.907 46 | 南宁,15,230,258,0.8915,61.008,67.22,0.9076 47 | 南京,130,172,316,0.5443,75.2141,68.2918,0.908 48 | 营口,1,104,384,0.2708,64.65,58.75,0.9087 49 | 黄冈,2,212,276,0.7681,52,47.64,0.9162 50 | 聊城,1,98,390,0.2513,30.29,27.76,0.9165 51 | 石河子,1,87,401,0.217,50.02,54.43,0.919 52 | 丽水,1,246,242,1.0165,94.73,103.05,0.9193 53 | 长沙,15,246,242,1.0165,42.9127,46.51,0.9227 54 | 漳州,5,237,251,0.9442,67.766,62.548,0.923 55 | 合肥,21,196,292,0.6712,59.5176,55.0152,0.9244 56 | 潍坊,3,101,387,0.261,53.0067,57.2833,0.9253 57 | 成都,37,256,232,1.1034,57.1208,61.6884,0.926 58 | 温州,67,248,240,1.0333,62.9046,67.8131,0.9276 59 | 太原,3,137,351,0.3903,60.6467,56.4267,0.9304 60 | 思茅,1,327,161,2.0311,55.56,59.69,0.9308 61 | 葫芦岛,1,97,391,0.2481,49.49,53.14,0.9313 62 | 宿迁,1,125,363,0.3444,71.07,66.2,0.9315 63 | 湖州,7,221,267,0.8277,92.0686,98.7486,0.9324 64 | 武汉,124,195,293,0.6655,58.5257,54.5768,0.9325 65 | 廊坊,1,102,386,0.2642,25.52,27.31,0.9345 66 | 湛江,2,232,256,0.9062,30.425,28.435,0.9346 67 | 南通,11,190,298,0.6376,110.5955,103.6155,0.9369 68 | 信阳,1,181,307,0.5896,88.73,94.66,0.9374 69 | 烟台,2,109,379,0.2876,144.91,154.395,0.9386 70 | 天门,1,187,301,0.6213,138.21,146.54,0.9432 71 | 镇江,3,170,318,0.5346,53.55,50.52,0.9434 72 | 淮安,5,133,355,0.3746,93.79,99.41,0.9435 73 | 宝鸡,1,130,358,0.3631,51.51,54.57,0.9439 74 | 襄阳,3,161,327,0.4924,89.0233,84.1633,0.9454 75 | 无锡,26,190,298,0.6376,89.6192,94.7662,0.9457 76 | 安康,1,163,325,0.5015,31.17,32.96,0.9457 77 | 扬州,5,160,328,0.4878,130.452,123.392,0.9459 78 | 荆门,1,178,310,0.5742,27.02,25.57,0.9463 79 | 深圳,88,211,277,0.7617,70.8694,67.3188,0.9499 80 | 肇庆,1,240,248,0.9677,66.43,63.19,0.9512 81 | 长治,1,153,335,0.4567,68.05,64.91,0.9539 82 | 莆田,2,233,255,0.9137,48.28,46.06,0.954 83 | 汉中,1,186,302,0.6159,46.83,49.05,0.9547 84 | 苏州,66,196,292,0.6712,103.5926,99.048,0.9561 85 | 济宁,2,80,408,0.1961,55.055,52.8,0.959 86 | 厦门,30,222,266,0.8346,59.9823,57.5963,0.9602 87 | 西安,17,115,373,0.3083,73.1859,70.2747,0.9602 88 | 济南,24,110,378,0.291,45.1775,47.0179,0.9609 89 | 芜湖,2,210,278,0.7554,67.68,70.255,0.9633 90 | 保定,1,114,374,0.3048,33.7,34.89,0.9659 91 | 荆州,1,209,279,0.7491,35.31,36.51,0.9671 92 | 北京,163,115,373,0.3083,58.8226,60.7881,0.9677 93 | 咸宁,2,226,262,0.8626,65.805,63.72,0.9683 94 | 泉州,8,215,273,0.7875,58.115,59.9763,0.969 95 | 台州,7,232,256,0.9062,62.3743,64.3286,0.9696 96 | 上海,285,226,262,0.8626,74.0352,76.3519,0.9697 97 | 南平,3,247,241,1.0249,65.0767,67.0867,0.97 98 | 威海,1,105,383,0.2742,58.06,56.45,0.9723 99 | 福州,41,260,228,1.1404,78.5571,80.5322,0.9755 100 | 黄石,3,219,269,0.8141,66.47,68.1,0.9761 101 | 重庆,19,200,288,0.6944,72.9121,74.6268,0.977 102 | 辽阳,1,129,359,0.3593,48.37,47.27,0.9773 103 | 三亚,1,152,336,0.4524,48.34,49.36,0.9793 104 | 盐城,2,147,341,0.4311,109.21,111.345,0.9808 105 | 杭州,225,254,234,1.0855,87.7192,86.1151,0.9817 106 | 黄山,2,271,217,1.2488,75.89,74.815,0.9858 107 | 阜阳,2,232,256,0.9062,80.545,81.63,0.9867 108 | 宁波,45,220,268,0.8209,77.7107,76.9093,0.9897 109 | 孝感,4,184,304,0.6053,39.245,39.63,0.9903 110 | 抚顺,1,132,356,0.3708,60.88,60.32,0.9908 111 | 常州,20,187,301,0.6213,72.524,71.961,0.9922 112 | 玉林,1,257,231,1.1126,74.75,75.31,0.9926 113 | 沈阳,13,106,382,0.2775,51.8315,52.2146,0.9927 114 | 广州,136,216,272,0.7941,75.7895,76.3099,0.9932 115 | 嘉兴,11,231,257,0.8988,102.1018,102.5191,0.9959 116 | 三明,1,255,233,1.0944,49.09,48.91,0.9963 117 | 达州,1,196,292,0.6712,91.47,91.76,0.9968 118 | 绍兴,30,235,253,0.9289,84.2593,84.04,0.9974 119 | 日照,1,125,363,0.3444,113.79,114.06,0.9976 120 | 郑州,14,118,370,0.3189,63.4293,63.5643,0.9979 121 | 绵阳,1,160,328,0.4878,60.43,60.48,0.9992 122 | 淮北,1,151,337,0.4481,46.5,46.5,1 123 | -------------------------------------------------------------------------------- /main/analysis/week/weeks_cnt.txt: -------------------------------------------------------------------------------- 1 | id,end_bigger,end_smaller,end_equal 2 | 0.41,0.21,0.38 3 | 0.39,0.24,0.37 4 | 0.34,0.27,0.38 5 | 0.37,0.22,0.41 6 | 0.15,0.44,0.42 7 | 0.45,0.1,0.45 8 | 0.38,0.22,0.4 9 | 0.49,0.16,0.35 10 | 0.48,0.2,0.32 11 | 0.48,0.21,0.31 12 | 0.51,0.19,0.3 13 | 0.54,0.18,0.27 14 | 0.41,0.33,0.26 15 | 0.53,0.21,0.26 16 | 0.5,0.24,0.26 17 | 0.49,0.27,0.25 18 | 0.46,0.31,0.24 19 | 0.51,0.26,0.22 20 | 0.52,0.27,0.21 21 | 0.54,0.27,0.19 22 | 0.52,0.3,0.18 23 | 0.56,0.27,0.16 24 | 0.3,0.54,0.15 25 | 0.58,0.29,0.13 26 | 0.6,0.3,0.11 27 | 0.53,0.38,0.1 28 | 0.53,0.38,0.09 29 | 0.57,0.34,0.09 30 | 0.58,0.34,0.09 31 | 0.55,0.37,0.08 32 | 0.59,0.34,0.07 33 | 0.58,0.35,0.07 34 | 0.57,0.36,0.07 35 | 0.59,0.36,0.05 36 | 0.6,0.36,0.05 37 | 0.63,0.36,0.01 38 | 0.52,0.47,0.02 39 | 0.72,0.27,0.01 40 | 0.53,0.46,0.01 41 | 0.52,0.48,0.0 42 | 0.7,0.3,0.0 43 | 0.69,0.31,0.0 44 | 0.66,0.34,0.0 45 | -------------------------------------------------------------------------------- /main/data_processing/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/data_processing/__init__.py -------------------------------------------------------------------------------- /main/data_processing/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/data_processing/__init__.pyc -------------------------------------------------------------------------------- /main/data_processing/avg_smoothing.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | ''' 3 | 如果这一天的数据为0,则将该天用前三个星期对应天的平均值替换 4 | 从最后last_days开始计算,这里用后123天 5 | ''' 6 | def cal_avg(filename,fileto,last_days): 7 | fr=open(filename) 8 | fr_to=open(fileto,"w") 9 | flag=0 10 | for line in fr.readlines(): 11 | if flag==0: 12 | fr_to.write(line) 13 | flag=1 14 | continue 15 | data=line.strip().split(",") 16 | for i in range(len(data)-last_days,len(data)): 17 | if float(data[i])==0: 18 | data[i]=str((float(data[i-7])+float(data[i-14])+float(data[i-21]))/3.0) 19 | fr_to.write(",".join(data)+"\n") 20 | fr_to.close() 21 | 22 | if __name__ == '__main__': 23 | filename="../../data/statistics/count_user_pay.csv" 24 | fileto="../../data/statistics/count_user_pay_avg.csv" 25 | cal_avg(filename,fileto,123) -------------------------------------------------------------------------------- /main/data_processing/avg_smoothing.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/data_processing/avg_smoothing.pyc -------------------------------------------------------------------------------- /main/data_processing/run.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from avg_smoothing import * 3 | from smoothing import * 4 | from split_test_train import * 5 | 6 | def run(): 7 | 8 | ''' 9 | avg_smoothing 10 | :return: 11 | ''' 12 | filename = "../../data/statistics/count_user_pay.csv" 13 | fileto = "../../data/statistics/count_user_pay_avg.csv" 14 | cal_avg(filename, fileto, 123) 15 | 16 | ''' 17 | smoothing 18 | ''' 19 | get_static_week() 20 | data1 = pd.read_csv('./week_output.csv', names=range(0, 15)) 21 | standardDF = data1.ix[:, 1:7] 22 | # print standardDF.shape 23 | data2 = pd.read_csv('../../data/statistics/shop_day_num.txt', names=range(0, 495)) 24 | week4(data2, standardDF) 25 | week3(data2, standardDF) 26 | week2(data2, standardDF) 27 | week1(data2, standardDF) 28 | week0(data2, standardDF) 29 | 30 | ''' 31 | split_test_train 32 | ''' 33 | # 2016 - 9-13 至 2016 - 9-19 34 | weekName = "weekZ" 35 | split_week(weekName, num_start_day=440, num_end_day=446) 36 | # 2016 - 9-20 至 2016 - 9-26 37 | weekName = "weekA" 38 | split_week(weekName, num_start_day=447, num_end_day=453) 39 | # 2016 - 10 - 11 至 2016 - 10 -17 40 | weekName = "weekB" 41 | split_week(weekName, num_start_day=468, num_end_day=474) 42 | # 2016 - 10 - 18 至 2016 - 10 -24 43 | weekName = "weekC" 44 | split_week(weekName, num_start_day=475, num_end_day=481) 45 | # 2016 - 10 - 25 至 2016 - 10 -31 46 | weekName = "weekD" 47 | split_week(weekName, num_start_day=482, num_end_day=488) 48 | 49 | weekName = "weekA_view" 50 | split_week_view(weekName, num_start_day=447, num_end_day=453) 51 | weekName = "weekB_view" 52 | split_week_view(weekName, num_start_day=468, num_end_day=474) 53 | weekName = "weekC_view" 54 | split_week_view(weekName, num_start_day=475, num_end_day=481) 55 | weekName = "weekD_view" 56 | split_week_view(weekName, num_start_day=482, num_end_day=488) -------------------------------------------------------------------------------- /main/data_processing/run.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/data_processing/run.pyc -------------------------------------------------------------------------------- /main/data_processing/smoothing.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | import datetime, math 3 | import pandas as pd 4 | import numpy as np 5 | 6 | ''' 7 | 对ABCDE五周的数据异常点进行处理,数据进行平滑 8 | get_static_week()函数通过对最后三个月数据处理得到标准的一星期的数据,保存到week_out.csv文件中 9 | 根据balance函数对五周的数据分别进行处理,对数据进行平滑 10 | ''' 11 | 12 | 13 | def get_static_week(): 14 | startDay = datetime.datetime.strptime("2016-10-31", "%Y-%m-%d") 15 | DUR = 14 16 | holiday = ['2016-01-01', '2016-01-02', '2016-01-03', '2016-02-07', '2016-02-08', '2016-02-09', '2016-02-10', 17 | '2016-02-11', '2016-02-12', '2016-02-13', '2016-04-02', '2016-04-03', '2016-04-04', '2016-04-30', 18 | '2016-05-01', '2016-05-02', '2016-06-09', '2016-06-10', '2016-06-11', '2016-09-15', '2016-09-16', 19 | '2016-09-17', '2016-10-01', '2016-10-02', '2016-10-03', '2016-10-04', '2016-10-05', '2016-10-06', 20 | '2016-10-07', '2016-02-15', '2016-06-12', '2016-09-18', '2016-10-08', '2016-10-09'] 21 | 22 | f_out1 = open('./feat_week.csv', 'w') 23 | print >> f_out1, "shopid,daym0,daym1,daym2,daym3,daym4,daym5,daym6,dayper0,dayper1,dayper2,dayper3,dayper4,dayper5,dayper6,days0,days1,days2,days3,days4,days5,days6" 24 | paynd = None 25 | for line in open('./shop_pay_statistics.txt'): 26 | line = line.strip() 27 | if not line: 28 | continue 29 | array = line.split(',', -1) 30 | 31 | shutdays = 0 32 | for i in range(len(array) - 90, len(array)): 33 | if int(array[i]) == 0: 34 | shutdays += 1 35 | else: 36 | if shutdays >= 7: 37 | if i + 7 < len(array) and int(array[i + 7]) != 0: 38 | array[i] = str(int(round((int(array[i]) + int(array[i + 7])) / 2))) 39 | else: 40 | array[i] = str(int(round(int(array[i]) * 1.3))) 41 | shutdays = 0 42 | 43 | shopid = array[0] 44 | # print shopid 45 | csum = [0] * 7 46 | dsum = [0] * 7 47 | psum = [0] * 7 48 | msum = [0.0] * 7 49 | stdsum = [0.0] * 7 50 | errsum = [0] * 7 51 | zerosum = [0] * 7 52 | 53 | for i in range(0, 7): 54 | lastday = startDay - datetime.timedelta(days=i) 55 | day = lastday.weekday() 56 | offset = 0 + i 57 | while csum[day] < 5 and offset < 60: 58 | if (startDay - datetime.timedelta(days=offset)).strftime("%Y-%m-%d") in holiday: 59 | offset += 7 60 | continue 61 | if int(array[len(array) - offset - 1]) != 0: 62 | dsum[day] += int(array[len(array) - offset - 1]) 63 | csum[day] += 1 64 | elif offset < 35: 65 | zerosum[day] += 1 66 | offset += 7 67 | for i in range(0, 7): 68 | msum[i] = round(float(dsum[i]) / csum[day], 2) 69 | if zerosum[i] >= 3: 70 | print shopid, 'errorzero', i, zerosum[i], msum[i] 71 | for i in range(0, 7): 72 | psum[i] = round(float(msum[i]) / sum(msum), 3) 73 | dsum = [0] * 7 74 | csum = [0] * 7 75 | 76 | for i in range(len(array) - 35, len(array)): 77 | day = (datetime.datetime.strptime("2015-06-26", "%Y-%m-%d") + datetime.timedelta(days=i - 1)).weekday() 78 | if (datetime.datetime.strptime("2015-06-26", "%Y-%m-%d") + datetime.timedelta(days=i - 1)).strftime( 79 | "%Y-%m-%d") in holiday: 80 | continue 81 | stdsum[day] += (int(array[i]) - msum[day]) ** 2 82 | if int(array[i]) != 0 and not 0.5 < (1.0 * int(array[i])) / msum[day] < 2.0: # 0.5 2.0 83 | errsum[day] += 1 84 | elif int(array[i]) != 0 and not 0.3 < (1.0 * int(array[i])) / msum[day] < 3.0: # 0.3 3 85 | errsum[day] += 2 86 | if int(array[i]) != 0 and 0.33 < (1.0 * int(array[i])) / msum[day] < 2.5: # 3 87 | dsum[day] += int(array[i]) 88 | csum[day] += 1 89 | for i in range(len(array) - 14, len(array)): 90 | day = (datetime.datetime.strptime("2015-06-26", "%Y-%m-%d") + datetime.timedelta(days=i - 1)).weekday() 91 | if (datetime.datetime.strptime("2015-06-26", "%Y-%m-%d") + datetime.timedelta(days=i - 1)).strftime( 92 | "%Y-%m-%d") in holiday: 93 | continue 94 | stdsum[day] += (int(array[i]) - msum[day]) ** 2 95 | if int(array[i]) != 0 and 0.75 < (1.0 * int(array[i])) / msum[day] < 1.5: 96 | dsum[day] += int(array[i]) 97 | csum[day] += 1 98 | for i in range(0, 7): 99 | if csum[i] <= 1: 100 | print shopid, 'error few sample', i, csum, msum[i] 101 | csum[i] = 1 102 | dsum[i] = msum[i] 103 | if errsum[i] >= 3: 104 | print shopid, 'error big std sample', i, errsum[i], msum[i] 105 | # TODO 1918 106 | msum[i] = round(float(dsum[i]) / csum[i], 2) 107 | allsum = sum(dsum) 108 | for i in range(0, 7): 109 | stdsum[i] = round(math.sqrt(float(stdsum[i]) / csum[i]) / (allsum / sum(csum)), 2) 110 | print >> f_out1, shopid + "," + ",".join(map(lambda x: str(x), msum)) + "," + ",".join( 111 | map(lambda x: str(x), psum)) + "," + ",".join(map(lambda x: str(x), stdsum)) 112 | 113 | f_out1.close() 114 | 115 | data = pd.read_csv('./feat_week.csv', index_col=['shopid']) 116 | 117 | data.iloc[22, 0:7] = [117, 122, 136, 114, 123, 43, 33] 118 | data.iloc[523, 5:7] = [5, 5] 119 | data.iloc[809, 0:7] = data.iloc[809, 0:7] * 1.5 120 | data.iloc[1823, 0:7] = data.iloc[809, 0:7] * 0 121 | data.iloc[1917, 3] = 6.0 122 | data.iloc[631, 0:7] = [49.0] * 7 123 | 124 | week = pd.concat([data.iloc[:, 1:7], data.iloc[:, 0:1]], axis=1) 125 | output = pd.concat([week * 1.02, week * 1.02], axis=1) 126 | output.astype(int).to_csv('./week_output.csv', header=None) 127 | 128 | def balanceDf2(weekDF, standardDF, times=15): 129 | ans=[] 130 | for i in range(weekDF.shape[0]): 131 | tmp = np.array(balance(np.array(weekDF.iloc[i, :]), np.array(standardDF.iloc[i, :]), times)) 132 | ans.append(tmp) 133 | return ans 134 | 135 | 136 | def balance(weekList, standardList, times): 137 | if sum(standardList) == 0: 138 | return weekList 139 | diff = weekList - standardList 140 | mean = diff.mean() 141 | count = 0 142 | while count < times and (abs(diff - mean)).max() > max(min(abs(mean), 40), 2): 143 | pos = (abs(diff - mean)).argmax() 144 | diff[pos] = (diff[pos] + mean) / 2 145 | mean = diff.mean() 146 | count += 1 147 | weekList = (diff + standardList).round() 148 | return weekList 149 | 150 | def writeto(dates,weekList,fileto): 151 | fr_to=open(fileto,"w") 152 | fr_to.write("shop_id") 153 | for date in dates: 154 | fr_to.write(","+date) 155 | fr_to.write("\n") 156 | for i in range(0,2000): 157 | fr_to.write(str(i+1)) 158 | for data in weekList[i]: 159 | fr_to.write(","+str(data)) 160 | fr_to.write("\n") 161 | fr_to.close() 162 | 163 | def week4(data2,standardDF): 164 | weekDF = data2.ix[:, 488:494] 165 | weekList = balanceDf2(weekDF=weekDF, standardDF=standardDF) 166 | dates = ['2016-10-25', '2016-10-26', '2016-10-27', '2016-10-28', '2016-10-29', '2016-10-30', '2016-10-31'] 167 | writeto(dates, weekList, "../../data/weekABCD/week4.csv") 168 | 169 | def week3(data2,standardDF): 170 | weekDF = data2.ix[:, 481:487] 171 | weekList = balanceDf2(weekDF=weekDF, standardDF=standardDF) 172 | dates = ['2016-10-18', '2016-10-19', '2016-10-20', '2016-10-21', '2016-10-22', '2016-10-23', '2016-10-24'] 173 | writeto(dates, weekList, "../../data/weekABCD/week3.csv") 174 | 175 | def week2(data2,standardDF): 176 | weekDF = data2.ix[:, 474:480] 177 | weekList = balanceDf2(weekDF=weekDF, standardDF=standardDF) 178 | dates = ['2016-10-11', '2016-10-12', '2016-10-13', '2016-10-14', '2016-10-15', '2016-10-16', '2016-10-17'] 179 | writeto(dates, weekList, "../../data/weekABCD/week2.csv") 180 | 181 | def week1(data2,standardDF): 182 | weekDF = data2.ix[:, 453:459] 183 | weekList = balanceDf2(weekDF=weekDF, standardDF=standardDF) 184 | dates = ['2016-09-20', '2016-09-21', '2016-09-22', '2016-09-23', '2016-09-24', '2016-09-25', '2016-09-26'] 185 | writeto(dates, weekList, "../../data/weekABCD/week1.csv") 186 | 187 | def week0(data2,standardDF): 188 | weekDF = data2.ix[:, 446:452] 189 | weekList = balanceDf2(weekDF=weekDF, standardDF=standardDF) 190 | dates = ['2016-09-13', '2016-09-14', '2016-09-15', '2016-09-16', '2016-09-17', '2016-09-18', '2016-09-19'] 191 | writeto(dates, weekList, "../../data/weekABCD/week0.csv") 192 | 193 | if __name__ == '__main__': 194 | get_static_week() 195 | data1 = pd.read_csv('./week_output.csv', names=range(0, 15)) 196 | standardDF = data1.ix[:, 1:7] 197 | # print standardDF.shape 198 | data2 = pd.read_csv('../../data/statistics/shop_day_num.txt', names=range(0, 495)) 199 | week4(data2,standardDF) 200 | week3(data2,standardDF) 201 | week2(data2,standardDF) 202 | week1(data2,standardDF) 203 | week0(data2,standardDF) 204 | -------------------------------------------------------------------------------- /main/data_processing/smoothing.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/data_processing/smoothing.pyc -------------------------------------------------------------------------------- /main/data_processing/split_test_train.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pandas as pd 3 | from datetime import datetime,timedelta 4 | 5 | ''' 6 | 线下测试集和训练集生产 7 | 这里线下取了五周ZABCD的数据作为线下测试数据 8 | Z:2016 - 09 - 13 至 2016 - 09-19 9 | A:2016 - 09 - 20 至 2016 - 09-26 10 | B:2016 - 10 - 11 至 2016 - 10 -17 11 | C:2016 - 10 - 18 至 2016 - 10 -24 12 | D:2016 - 10 - 25 至 2016 - 10 -31 13 | ''' 14 | 15 | #本函数用于将count_user_pay中,列名称全部转变为datetime格式 16 | def transform_count_user_pay_datetime(count_user_pay): 17 | col = count_user_pay.columns 18 | tmp = [] 19 | tmp1 = [] 20 | for one in col: 21 | tmp.append(one.replace('count_user_pay_','')) 22 | for one in tmp: 23 | tmp1.append(one.replace('_','-')) 24 | col = [] 25 | col.append(tmp1[0]) 26 | for one in tmp1[1:]: 27 | col.append(datetime.strptime(one,'%Y-%m-%d')) 28 | count_user_pay.columns = col 29 | return count_user_pay 30 | 31 | #本函数用于将count_user_view中,列名称全部转变为datetime格式,并且返回。 32 | def transform_count_user_view_datetime(count_user_view): 33 | col = count_user_view.columns 34 | tmp = [] 35 | tmp1 = [] 36 | for one in col: 37 | tmp.append(one.replace('count_user_view_','')) 38 | for one in tmp: 39 | tmp1.append(one.replace('_','-')) 40 | col = [] 41 | col.append(tmp1[0]) 42 | for one in tmp1[1:]: 43 | col.append(datetime.strptime(one,'%Y-%m-%d')) 44 | count_user_view.columns = col 45 | return count_user_view 46 | 47 | def split_week(weekName,num_start_day=0, num_end_day=488, week=False, fr='D'): 48 | start_day = '2015-07-01' 49 | start_day = datetime.strptime(start_day, '%Y-%m-%d') + timedelta(days=num_start_day) 50 | end_day = start_day + timedelta(days=num_end_day - num_start_day) 51 | dates = pd.date_range(start=start_day, end=end_day, freq=fr) 52 | 53 | try: 54 | dates = dates.drop(datetime(2015, 12, 12)) 55 | except ValueError: 56 | print '' 57 | 58 | count_user_pay = pd.read_csv('../../data/statistics/count_user_pay.csv') 59 | count_user_pay.index = count_user_pay.shop_id.values 60 | count_user_pay = transform_count_user_pay_datetime(count_user_pay) 61 | values = count_user_pay.ix[[i for i in range(1,2001)],dates] 62 | # print values[:] 63 | values.to_csv('../../data/weekABCD/' + weekName + '.csv') 64 | 65 | def split_week_view(weekName,num_start_day=0, num_end_day=488, week=False, fr='D'): 66 | start_day = '2015-07-01' 67 | start_day = datetime.strptime(start_day, '%Y-%m-%d') + timedelta(days=num_start_day) 68 | end_day = start_day + timedelta(days=num_end_day - num_start_day) 69 | dates = pd.date_range(start=start_day, end=end_day, freq=fr) 70 | 71 | try: 72 | dates = dates.drop(datetime(2015, 12, 12)) 73 | except ValueError: 74 | print '' 75 | 76 | count_user_pay = pd.read_csv('../../data/count_pay_and_view/count_user_view.csv') 77 | count_user_pay.index = count_user_pay.shop_id.values 78 | count_user_pay = transform_count_user_view_datetime(count_user_pay) 79 | values = count_user_pay.ix[[i for i in range(1,2001)],dates] 80 | print values[:] 81 | values.to_csv('../../data/weekABCD/' + weekName + '.csv') 82 | 83 | 84 | if __name__ == '__main__': 85 | #2016 - 9-13 至 2016 - 9-19 86 | weekName = "weekZ" 87 | split_week(weekName, num_start_day=440, num_end_day=446) 88 | #2016 - 9-20 至 2016 - 9-26 89 | weekName = "weekA" 90 | split_week(weekName, num_start_day=447, num_end_day=453) 91 | #2016 - 10 - 11 至 2016 - 10 -17 92 | weekName = "weekB" 93 | split_week(weekName, num_start_day=468, num_end_day=474) 94 | # 2016 - 10 - 18 至 2016 - 10 -24 95 | weekName = "weekC" 96 | split_week(weekName, num_start_day=475, num_end_day=481) 97 | # 2016 - 10 - 25 至 2016 - 10 -31 98 | weekName="weekD" 99 | split_week(weekName,num_start_day=482,num_end_day=488) 100 | 101 | 102 | weekName = "weekA_view" 103 | split_week_view(weekName, num_start_day=447, num_end_day=453) 104 | weekName = "weekB_view" 105 | split_week_view(weekName, num_start_day=468, num_end_day=474) 106 | weekName = "weekC_view" 107 | split_week_view(weekName, num_start_day=475, num_end_day=481) 108 | weekName="weekD_view" 109 | split_week_view(weekName,num_start_day=482,num_end_day=488) -------------------------------------------------------------------------------- /main/data_processing/split_test_train.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/data_processing/split_test_train.pyc -------------------------------------------------------------------------------- /main/draw_picture/draw.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | import numpy as np 3 | import pandas as pd 4 | import matplotlib.pyplot as plt 5 | import random 6 | from datetime import datetime, timedelta 7 | import sys 8 | 9 | sys.path.append('../main') 10 | from unit import * 11 | 12 | 13 | # 单个商家客流量的走势图,可调整时间段,也可以按指定的周几绘图 14 | def draw_single_shop(shop_id, num_start_day=0, num_end_day=488, week=False, fr='D'): 15 | start_day = '2015-07-01' 16 | start_day = datetime.strptime(start_day, '%Y-%m-%d') + timedelta(days=num_start_day) 17 | end_day = start_day + timedelta(days=num_end_day - num_start_day) 18 | dates = pd.date_range(start=start_day, end=end_day, freq=fr) 19 | 20 | try: 21 | dates = dates.drop(datetime(2015, 12, 12)) 22 | except ValueError: 23 | print '' 24 | 25 | delta = (end_day - start_day).days 26 | count_user_pay = pd.read_csv('../../data/statistics/count_user_pay.csv') 27 | count_user_pay.index = count_user_pay.shop_id.values 28 | count_user_pay = transform_count_user_pay_datetime(count_user_pay) 29 | values = count_user_pay.ix[shop_id, dates] 30 | fig = plt.figure(random.randint(1, 10000)) 31 | ax = fig.add_subplot(111) 32 | 33 | xticklabels_date = values.index 34 | xticklabels_week = [] 35 | for one in xticklabels_date: 36 | xticklabels_week.append(one.strftime('%a')) 37 | if (week): 38 | xticklabels = xticklabels_week 39 | else: 40 | xticklabels = xticklabels_date 41 | if (delta < 100): 42 | ax.set_xticks([i for i in range(len(values))]) 43 | ax.set_xticklabels(xticklabels, rotation=-90) 44 | ax.set_title( 45 | 'shop_id:' + str(shop_id) + ' ' + start_day.strftime('%Y-%m-%d') + ' ~ ' + end_day.strftime('%Y-%m-%d')) 46 | ax.grid() 47 | plt.subplots_adjust(bottom=0.2) 48 | ax.plot(values, label=shop_id) 49 | ax.legend(loc='best') 50 | 51 | 52 | # 多个商家客流量的走势图,可调整时间段,也可以按指定的周几绘图,可以计算avg. 53 | def draw_multi_shops(shop_id=[i for i in range(1, 2001)], num_start_day=0, num_end_day=488, week=False, fr='D', 54 | _mean=False, _min=False, _std=False, _25=False, _50=False, _75=False, _max=False): 55 | if (type(num_start_day) == type(num_end_day) == type(1)): 56 | start_day = '2015-07-01' 57 | start_day = datetime.strptime(start_day, '%Y-%m-%d') + timedelta(days=num_start_day) 58 | end_day = start_day + timedelta(days=num_end_day - num_start_day) 59 | else: 60 | start_day = datetime.strptime(num_start_day, '%Y-%m-%d') 61 | end_day = datetime.strptime(num_end_day, '%Y-%m-%d') 62 | dates = pd.date_range(start=start_day, end=end_day, freq=fr) 63 | 64 | try: 65 | dates = dates.drop(datetime(2015, 12, 12)) 66 | except ValueError: 67 | print '' 68 | 69 | delta = (end_day - start_day).days 70 | count_user_pay = pd.read_csv('../../data/statistics/count_user_pay.csv') 71 | count_user_pay.index = count_user_pay.shop_id.values 72 | count_user_pay = transform_count_user_pay_datetime(count_user_pay) 73 | values = count_user_pay.ix[shop_id, dates] 74 | 75 | fig = plt.figure(num=random.randint(1, 10000)) 76 | ax = fig.add_subplot(111) 77 | xticklabels_date = values.columns 78 | xticklabels_week = [] 79 | for one in xticklabels_date: 80 | xticklabels_week.append(one.strftime('%a')) 81 | if (week): 82 | xticklabels = xticklabels_week 83 | else: 84 | xticklabels = xticklabels_date 85 | 86 | if (delta < 100): 87 | ax.set_xticks([i for i in range(len(values.columns))]) 88 | ax.set_xticklabels(xticklabels, rotation=-90) 89 | ax.set_title('[pay] ' + start_day.strftime('%Y-%m-%d') + ' ~ ' + end_day.strftime('%Y-%m-%d')) 90 | ax.grid() 91 | if (_mean): 92 | _mean = (values.describe()).ix['mean'] 93 | ax.plot(_mean, label='avg') 94 | elif (_std): 95 | _std = (values.describe()).ix['std'] 96 | ax.plot(_std, label='std') 97 | elif (_min): 98 | _min = (values.describe()).ix['min'] 99 | ax.plot(_min, label='min') 100 | elif (_25): 101 | _25 = (values.describe()).ix['25%'] 102 | ax.plot(_25, label='25%') 103 | elif (_50): 104 | _50 = (values.describe()).ix['50%'] 105 | ax.plot(_50, label='50%') 106 | elif (_75): 107 | _75 = (values.describe()).ix['75%'] 108 | ax.plot(_75, label='75%') 109 | elif (_max): 110 | _max = (values.describe()).ix['max'] 111 | ax.plot(_max, label='max') 112 | else: 113 | for i in shop_id: 114 | ax.plot(values.ix[i], label=str(i)) 115 | plt.subplots_adjust(bottom=0.2) 116 | ax.legend(loc='best') 117 | 118 | 119 | # 多个商家浏览量的走势图,可调整时间段,也可以按指定的周几绘图,可以计算avg. 120 | def draw_multi_shops_view(shop_id=[i for i in range(1, 2001)], num_start_day=0, num_end_day=273, week=False, fr='D', 121 | _mean=False, _min=False, _std=False, _25=False, _50=False, _75=False, _max=False): 122 | if (type(num_start_day) == type(num_end_day) == type(1)): 123 | start_day = '2016-02-01' 124 | start_day = datetime.strptime(start_day, '%Y-%m-%d') + timedelta(days=num_start_day) 125 | end_day = start_day + timedelta(days=num_end_day - num_start_day) 126 | else: 127 | start_day = datetime.strptime(num_start_day, '%Y-%m-%d') 128 | end_day = datetime.strptime(num_end_day, '%Y-%m-%d') 129 | dates = pd.date_range(start=start_day, end=end_day, freq=fr) 130 | 131 | try: 132 | dates = dates.drop(datetime(2016, 7, 22)) 133 | dates = dates.drop(datetime(2016, 7, 25)) 134 | except ValueError: 135 | print '' 136 | 137 | delta = (end_day - start_day).days 138 | count_user_view = pd.read_csv('../../data/statistics/count_user_view.csv') 139 | count_user_view.index = count_user_view.shop_id.values 140 | count_user_view = transform_count_user_view_datetime(count_user_view) 141 | values = count_user_view.ix[shop_id, dates] 142 | 143 | fig = plt.figure(num=random.randint(1, 10000)) 144 | ax = fig.add_subplot(111) 145 | xticklabels_date = values.columns 146 | xticklabels_week = [] 147 | for one in xticklabels_date: 148 | xticklabels_week.append(one.strftime('%a')) 149 | if (week): 150 | xticklabels = xticklabels_week 151 | else: 152 | xticklabels = xticklabels_date 153 | 154 | if (delta < 100): 155 | ax.set_xticks([i for i in range(len(values.columns))]) 156 | ax.set_xticklabels(xticklabels, rotation=-90) 157 | ax.set_title('[view] ' + start_day.strftime('%Y-%m-%d') + ' ~ ' + end_day.strftime('%Y-%m-%d')) 158 | ax.grid() 159 | if (_mean): 160 | _mean = (values.describe()).ix['mean'] 161 | ax.plot(_mean, label='avg') 162 | elif (_std): 163 | _std = (values.describe()).ix['std'] 164 | ax.plot(_std, label='std') 165 | elif (_min): 166 | _min = (values.describe()).ix['min'] 167 | ax.plot(_min, label='min') 168 | elif (_25): 169 | _25 = (values.describe()).ix['25%'] 170 | ax.plot(_25, label='25%') 171 | elif (_50): 172 | _50 = (values.describe()).ix['50%'] 173 | ax.plot(_50, label='50%') 174 | elif (_75): 175 | _75 = (values.describe()).ix['75%'] 176 | ax.plot(_75, label='75%') 177 | elif (_max): 178 | _max = (values.describe()).ix['max'] 179 | ax.plot(_max, label='max') 180 | else: 181 | for i in shop_id: 182 | ax.plot(values.ix[i], label=str(i)) 183 | plt.subplots_adjust(bottom=0.2) 184 | ax.legend(loc='best') 185 | 186 | 187 | '''本函数用于将count_user_pay中,列名称全部转变为datetime格式,并且返回。''' 188 | 189 | 190 | def transform_count_user_pay_datetime(count_user_pay): 191 | col = count_user_pay.columns 192 | tmp = [] 193 | tmp1 = [] 194 | for one in col: 195 | tmp.append(one.replace('count_user_pay_', '')) 196 | for one in tmp: 197 | tmp1.append(one.replace('_', '-')) 198 | col = [] 199 | col.append(tmp1[0]) 200 | for one in tmp1[1:]: 201 | col.append(datetime.strptime(one, '%Y-%m-%d')) 202 | count_user_pay.columns = col 203 | return count_user_pay 204 | 205 | 206 | '''本函数用于将count_user_view中,列名称全部转变为datetime格式,并且返回。''' 207 | 208 | 209 | def transform_count_user_view_datetime(count_user_view): 210 | col = count_user_view.columns 211 | tmp = [] 212 | tmp1 = [] 213 | for one in col: 214 | tmp.append(one.replace('count_user_view_', '')) 215 | for one in tmp: 216 | tmp1.append(one.replace('_', '-')) 217 | col = [] 218 | col.append(tmp1[0]) 219 | for one in tmp1[1:]: 220 | col.append(datetime.strptime(one, '%Y-%m-%d')) 221 | count_user_view.columns = col 222 | return count_user_view 223 | 224 | 225 | # 画数据的折线图 226 | def draw(filename1, filename2, filename3): 227 | fr1 = open(filename1) 228 | 229 | index = [] 230 | pre_x = [] 231 | pre_y = [] 232 | for line in fr1.readlines(): 233 | data = line.strip().split(",") 234 | shop_id = data[0] 235 | index.append(shop_id) 236 | x = [] 237 | y = [] 238 | i = 1 239 | for num in data[1:]: 240 | x.append(i) 241 | y.append(int(num)) 242 | i += 1 243 | pre_x.append(x) 244 | pre_y.append(y) 245 | 246 | fr2 = open(filename2) 247 | now_x = [] 248 | now_y = [] 249 | for line in fr2.readlines(): 250 | data = line.strip().split(",") 251 | shop_id = data[0] 252 | x = [] 253 | y = [] 254 | i = 1 255 | for num in data[1:]: 256 | x.append(i) 257 | y.append(int(num)) 258 | i += 1 259 | now_x.append(x) 260 | now_y.append(y) 261 | 262 | fr3 = open(filename3) 263 | now_x_avg = [] 264 | now_y_avg = [] 265 | for line in fr3.readlines(): 266 | data = line.strip().split(",") 267 | shop_id = data[0] 268 | x = [] 269 | y = [] 270 | i = 1 271 | for num in data[1:]: 272 | x.append(i) 273 | y.append(int(num.split(".")[0])) 274 | i += 1 275 | now_x_avg.append(x) 276 | now_y_avg.append(y) 277 | 278 | # print now_x 279 | # print now_y 280 | for i in range(len(index)): 281 | if pre_y[i] != now_y[i]: 282 | print index[i] 283 | plt.figure() 284 | plt.plot(pre_x[i], pre_y[i], color="red", linewidth=1) 285 | plt.plot(now_x[i], now_y[i], "b", linewidth=1) 286 | plt.plot(now_x_avg[i], now_y_avg[i], "g", linewidth=1) 287 | plt.savefig("../pictures/image/" + index[i] + ".jpg") 288 | plt.close() 289 | 290 | 291 | def ali_eval(p1, p2): 292 | result = (p1 - p2) / (p1 + p2) 293 | result = np.nan_to_num(result) 294 | return np.mean(np.abs(result)) 295 | 296 | 297 | def cal_diff(filename1, filename2): 298 | a = np.loadtxt(filename1, delimiter=',') 299 | b = np.loadtxt(filename2, delimiter=',') 300 | import math 301 | sum = 0 302 | for i in range(0, a.shape[0]): 303 | for j in range(1, a.shape[1]): 304 | sum += math.fabs(a[i, j] - b[i, j]) / (a[i, j] + b[i, j]) 305 | return sum / (a.shape[0] * (a.shape[1] - 1)) 306 | 307 | 308 | if __name__ == '__main__': 309 | pass 310 | -------------------------------------------------------------------------------- /main/fuse/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/fuse/__init__.py -------------------------------------------------------------------------------- /main/fuse/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/fuse/__init__.pyc -------------------------------------------------------------------------------- /main/fuse/fuse.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import numpy as np 3 | 4 | ''' 5 | 模型融合 6 | 7 | 这里直接对多个模型进行了加权融合 8 | 1.对模型得到的结果进行融合 9 | 2.对模型加规则后的结果进行融合 10 | 3.模型主要是ExtraTree中特征选择,时间序列模型,RandomForestRegressor以及GBDT 11 | ''' 12 | 13 | def model_fuse(filename1, filename2, fileto, x=0.6): 14 | a = np.loadtxt(filename1, delimiter=',') 15 | b = np.loadtxt(filename2, delimiter=',') 16 | a[:, 1:] = (a[:, 1:] * x + b[:, 1:] * (1 - x) + 0.5).round() 17 | np.savetxt(fileto, a, delimiter=',', fmt='%d') 18 | 19 | 20 | if __name__ == '__main__': 21 | pass 22 | -------------------------------------------------------------------------------- /main/fuse/fuse.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/fuse/fuse.pyc -------------------------------------------------------------------------------- /main/fuse/run.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from fuse import model_fuse 3 | import time 4 | 5 | def run_fuse(): 6 | version = time.strftime('%Y-%m-%d', time.localtime(time.time())) + '_' 7 | filename1='../../data/results/result_2017-03-16_special_day_weather_huopot.csv' 8 | filename2='../../data/results/result_2017-03-11_special_day_weather_huopot.csv' 9 | filename3 = '../../data/results/result_' + version + 'fuse.csv' 10 | model_fuse(filename1,filename2,filename3) 11 | 12 | if __name__ == '__main__': 13 | run_fuse() -------------------------------------------------------------------------------- /main/fuse/run.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/fuse/run.pyc -------------------------------------------------------------------------------- /main/model/RandomForestRegreessor.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pandas as pd 3 | from pandas import DataFrame 4 | from sklearn.ensemble import GradientBoostingRegressor 5 | from sklearn.ensemble import RandomForestRegressor 6 | import numpy as np 7 | import time 8 | import sys 9 | from unit import repeat_result 10 | ''' 11 | RF 12 | ''' 13 | def RF(): 14 | version = time.strftime('%Y-%m-%d', time.localtime(time.time())) + '_' 15 | 16 | train_x = pd.read_csv('../../data/test_train/' + version + 'train_on_x.csv') 17 | train_y = pd.read_csv('../../data/test_train/' + version + 'train_on_y.csv') 18 | test_x = pd.read_csv('../../data/test_train/' + version + 'test_on_x.csv') 19 | 20 | ET = RandomForestRegressor(n_estimators=2000, random_state=1, n_jobs=-1, min_samples_split=2, min_samples_leaf=2, 21 | max_depth=25) 22 | 23 | ET.fit(train_x, train_y) 24 | pre = (ET.predict(test_x) + 0.5).round() 25 | features = ET.feature_importances_ 26 | feature_sort = (features / np.sum(features) * 100).round(4) 27 | feature_index = np.argsort(feature_sort) 28 | for i in feature_index: 29 | print'{0} : {1}'.format(train_x.columns[i], feature_sort[i]) 30 | pre=repeat_result(pre) 31 | np.savetxt('../../data/results/result_' + version + '.csv', np.concatenate((np.arange(1, 2001).reshape(2000, 1), pre), axis=1), delimiter=',', 32 | fmt='%d') 33 | 34 | if __name__ == '__main__': 35 | RF() 36 | -------------------------------------------------------------------------------- /main/model/RandomForestRegreessor.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/model/RandomForestRegreessor.pyc -------------------------------------------------------------------------------- /main/model/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/model/__init__.py -------------------------------------------------------------------------------- /main/model/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/model/__init__.pyc -------------------------------------------------------------------------------- /main/model/base_model.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | from functools import reduce 4 | from sklearn.ensemble import ExtraTreesRegressor, GradientBoostingRegressor 5 | from sklearn.ensemble import RandomForestRegressor 6 | from sklearn.feature_selection import SelectFromModel 7 | import time 8 | from unit import * 9 | 10 | 11 | ''' 12 | 我们竞赛中主要使用的模型,使用sklearn的ExtraTreeRegress 13 | 14 | 1. 使用平滑所有的数据集 15 | 2. 线下offlineTest 16 | train AB->C 17 | test BC->D 18 | 3.线上onlineTest 19 | train ABC->D 20 | test BCD 21 | 4.使用ExtraTreesRegressor 连续预测7天数值,第二星期复制 22 | 23 | 使用的主要特征有: 24 | 1.商店的laction,三级cate 25 | 2.前三星期每天的流量 26 | 3.用户的浏览记录 27 | 4.三周整体的sum,mean,median,max,min,var,std 28 | 5.前三周每周一,每周二...,每周日的平均值 29 | 5.三星期每星期的sum,mean,median,max,min,var,std 30 | 6.三星期每星期相对于前面一天的浮动 31 | 7.前五个月整体的sum,mean,median,max,min,var,std 32 | 8.前五个月每个月的sum,mean,median,max,min,var,std 33 | 9.前五个月每星期相对于前一个星期的浮动 34 | ''' 35 | 36 | #ET参数 37 | params = { 38 | 'n_estimators': 1662, 39 | 'n_jobs': -1, 40 | 'random_state': 1, 41 | 'min_samples_split': 2, 42 | 'min_samples_leaf': 1, 43 | 'max_depth': 24, 44 | 'max_features': 40 45 | } 46 | 47 | #特征的合并 48 | def merge(a, b, shop): 49 | fc = lambda x, y: pd.merge(x, y, on='shop_id') 50 | trade = reduce(fc, a).drop('shop_id', axis=1) 51 | visit = reduce(fc, b).drop('shop_id', axis=1) 52 | 53 | cate = shop_cate_feature(shop) 54 | 55 | jL = [calcOpenDay(trade), cate, shop_location_feature(shop)] 56 | jL.extend(ExtractMonthFeature()) 57 | jL.extend(ExtractYearFeature()) 58 | jL.extend(ExtractTrainFeature(trade)) 59 | # jL.extend(calcWeekGainRate(trade)) 60 | # jL.extend(week_basic_feature(trade)) 61 | 62 | trade['sum'], trade['mean'], trade['median'], \ 63 | trade['max'], trade['min'], trade['var'],trade['std'], trade['mad']= basic_feature(trade) 64 | # 65 | all_data = pd.read_csv('../../data/statistics/count_user_pay.csv') 66 | trade['Allsum'], trade['Allmean'], trade['Allmedian'], \ 67 | trade['Allmax'], trade['Allvar'], trade['Allstd'], trade['Allmad'] = global_day_feature(all_data) 68 | # jL.extend(global_month_feature(all_data)) 69 | # jL.extend(global_day_feature(all_data)) 70 | # jL.extend(day_feature(all_data)) 71 | 72 | labelindex = {i: 'visit_{0}'.format(i) for i in visit.columns.values} 73 | jL.append(visit.rename_axis(labelindex, axis='columns')) 74 | 75 | return reduce(lambda x, y: x.join(y, how='left'), jL) 76 | 77 | #线下测试调参 78 | def offlineTest(trade, visit, shop_info, version): 79 | merge(trade[:2], visit[:2], shop_info).to_csv('../../data/test_train/' + version + 'train_off_x.csv', index=False) 80 | trade[2].drop('shop_id', axis=1).to_csv('../../data/test_train/' + version + 'train_off_y.csv', index=False) 81 | 82 | merge(trade[1:3], visit[1:3], shop_info).to_csv('../../data/test_train/' + version + 'test_off_x.csv', index=False) 83 | trade[3].drop('shop_id', axis=1).to_csv('../../data/test_train/' + version + 'test_off_y.csv', index=False) 84 | 85 | train_off_x, train_off_y = pd.read_csv('../../data/test_train/' + version + 'train_off_x.csv'), pd.read_csv( 86 | '../../data/test_train/' + version + 'train_off_y.csv') 87 | test_off_x, test_off_y = pd.read_csv('../../data/test_train/' + version + 'test_off_x.csv'), pd.read_csv( 88 | '../../data/test_train/' + version + 'test_off_y.csv') 89 | 90 | ET = ExtraTreesRegressor(**params) 91 | ET.fit(train_off_x, train_off_y) 92 | features = ET.feature_importances_ 93 | feature_sort = (features / np.sum(features) * 100).round(4) 94 | feature_index = np.argsort(feature_sort) 95 | 96 | for i in feature_index: 97 | print('{0} : {1}'.format(train_off_x.columns.values[i], feature_sort[i])) 98 | 99 | ret = ET.predict(test_off_x + 0.5).round() 100 | print(calc_score(ret, test_off_y.values)) 101 | 102 | #线上训练预测 103 | def onlineTest(trade, visit, shop_info, version): 104 | trade[3] = pd.read_csv(path + 'week4.csv') 105 | merge(trade[:3], visit[:3], shop_info).to_csv('../../data/test_train/' + version + 'train_on_x.csv', index=False) 106 | trade[3].drop('shop_id', axis=1).to_csv('../../data/test_train/' + version + 'train_on_y.csv', index=False) 107 | 108 | merge(trade[1:4], visit[1:4], shop_info).to_csv('../../data/test_train/' + version + 'test_on_x.csv', index=False) 109 | 110 | train_on_x, train_on_y = pd.read_csv('../../data/test_train/' + version + 'train_on_x.csv'), pd.read_csv( 111 | '../../data/test_train/' + version + 'train_on_y.csv') 112 | test_on_x = pd.read_csv('../../data/test_train/' + version + 'test_on_x.csv') 113 | 114 | ET = ExtraTreesRegressor(**params) 115 | ET.fit(train_on_x, train_on_y) 116 | A = ET.predict(test_on_x).round() 117 | pre = repeat_result(A) 118 | np.savetxt('../../data/results/result_' + version + '.csv', np.concatenate((np.arange(1, 2001).reshape(2000, 1), pre), axis=1), delimiter=',', 119 | fmt='%d') 120 | 121 | if __name__ == "__main__": 122 | version = time.strftime('%Y-%m-%d', time.localtime(time.time())) + '_' 123 | path = "../../data/weekABCD/" 124 | trade = [pd.read_csv(path + 'week' + str(i) + '.csv') for i in range(1, 4)] + [pd.read_csv(path + 'weekD.csv')] 125 | # trade = [pd.read_csv(path + 'week' + chr(i) + '.csv') for i in range(ord('A'), ord('E'))] 126 | visit = [pd.read_csv(path + 'week' + chr(i) + '_view.csv') for i in range(ord('A'), ord('E'))] 127 | shop_info = pd.read_csv('../../data/statistics/shop_info_num.csv') 128 | 129 | # 0线下,1线上数据提交 130 | (offlineTest, onlineTest)[0](trade, visit, shop_info, version) 131 | (offlineTest, onlineTest)[1](trade, visit, shop_info, version) 132 | 133 | 134 | -------------------------------------------------------------------------------- /main/model/base_model.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/model/base_model.pyc -------------------------------------------------------------------------------- /main/model/gbdt.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pandas as pd 3 | from pandas import DataFrame 4 | from sklearn.ensemble import GradientBoostingRegressor 5 | from sklearn.ensemble import RandomForestRegressor 6 | import numpy as np 7 | import time 8 | from unit import repeat_result 9 | import sys 10 | 11 | def gbdt(): 12 | version = time.strftime('%Y-%m-%d', time.localtime(time.time())) + '_' 13 | 14 | train_x = pd.read_csv('../../data/test_train/' + version + 'train_on_x.csv') 15 | train_y = pd.read_csv('../../data/test_train/' + version + 'train_on_y.csv') 16 | test_x = pd.read_csv('../../data/test_train/' + version + 'test_on_x.csv') 17 | 18 | param = {'subsample': [1, 1, 1, 1, 1, 1, 1], 19 | 'min_samples_leaf': [1, 1, 1, 1, 1, 1, 1], 20 | 'n_estimators': [200, 100, 200, 200, 200, 200, 100], 21 | 'min_samples_split': [4, 8, 2, 8, 2, 4, 4], 22 | 'learning_rate': [0.05, 0.1, 0.05, 0.05, 0.05, 0.05, 0.1], 23 | 'max_features': [270, 'auto', 280, 'auto', 270, 280, 270], 24 | 'random_state': [1, 1, 1, 1, 1, 1, 1] , 25 | 'max_depth': [4, 6, 4, 4, 4, 4, 4]} 26 | 27 | result = DataFrame() 28 | 29 | for i in range(0, 7): 30 | GB = GradientBoostingRegressor(n_estimators=param['n_estimators'][i], learning_rate=0.05, random_state=1, \ 31 | min_samples_split=param['min_samples_split'][i], min_samples_leaf=1, 32 | max_depth=param['max_depth'][i], max_features=param['max_features'][i], 33 | subsample=0.85) 34 | 35 | GB.fit(train_x, train_y.icol(i)) 36 | pre = (GB.predict(test_x)).round() 37 | 38 | result['col' + str(i)] = pre 39 | pre=repeat_result(result.values) 40 | np.savetxt('../../data/results/result_' + version + '.csv', np.concatenate((np.arange(1, 2001).reshape(2000, 1), pre), axis=1), delimiter=',', 41 | fmt='%d') 42 | 43 | if __name__ == '__main__': 44 | run() -------------------------------------------------------------------------------- /main/model/gbdt.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/model/gbdt.pyc -------------------------------------------------------------------------------- /main/model/multi_mode.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import pandas as pd 4 | from sklearn.ensemble import RandomForestRegressor 5 | from sklearn.ensemble import ExtraTreesRegressor 6 | import sys 7 | import numpy as np 8 | import random 9 | import time 10 | from unit import * 11 | feature_more_or_less = "_less_feature" # _more_feature 12 | version = time.strftime('%Y-%m-%d', time.localtime(time.time())) + '_' 13 | 14 | train_x = pd.read_csv('../../data/test_train/' + version + feature_more_or_less + 'train_off_x.csv') 15 | train_y = pd.read_csv('../../data/test_train/' + version + feature_more_or_less+ 'train_off_y.csv') 16 | test_x = pd.read_csv('../../data/test_train/' + version + feature_more_or_less + 'test_off_x.csv') 17 | test_y = pd.read_csv('../../data/test_train/' + version + feature_more_or_less + 'test_off_y.csv') 18 | 19 | clfs = [ExtraTreesRegressor(n_estimators=1200, random_state=1, n_jobs=-1, min_samples_split=2, min_samples_leaf=2, 20 | max_depth=25, max_features=45), 21 | ExtraTreesRegressor(n_estimators=1200, random_state=1, n_jobs=-1, min_samples_split=2, min_samples_leaf=2, 22 | max_depth=25, max_features=30), 23 | ExtraTreesRegressor(n_estimators=1200, random_state=1, n_jobs=-1, min_samples_split=2, min_samples_leaf=2, 24 | max_depth=25, max_features=20) 25 | ] 26 | 27 | train_x_pre = [] # train_x.values.tolist() 28 | test_x_pre = [] # test_x.values.tolist() 29 | ans=np.zeros((2000,7)) 30 | for clf in clfs: 31 | clf.fit(train_x, train_y) 32 | train_pre = (clf.predict(train_x) + 0.5).round() 33 | test_pre = (clf.predict(test_x) + 0.5).round() 34 | score = calcscore(test_pre, test_y.values) 35 | print score 36 | ans+=test_pre 37 | 38 | 39 | feature_more_or_less = "_more_feature" 40 | 41 | train_x = pd.read_csv('../../data/test_train/' + version + feature_more_or_less + 'train_off_x.csv') 42 | train_y = pd.read_csv('../../data/test_train/' + version + feature_more_or_less+ 'train_off_y.csv') 43 | test_x = pd.read_csv('../../data/test_train/' + version + feature_more_or_less + 'test_off_x.csv') 44 | test_y = pd.read_csv('../../data/test_train/' + version + feature_more_or_less + 'test_off_y.csv') 45 | # 46 | print train_x.shape[1] 47 | 48 | clfs = [ExtraTreesRegressor(n_estimators=1200, random_state=1, n_jobs=-1, min_samples_split=2, min_samples_leaf=2, 49 | max_depth=25, max_features=190), 50 | ExtraTreesRegressor(n_estimators=1200, random_state=1, n_jobs=-1, min_samples_split=2, min_samples_leaf=2, 51 | max_depth=25, max_features=160), 52 | ExtraTreesRegressor(n_estimators=1200, random_state=1, n_jobs=-1, min_samples_split=2, min_samples_leaf=2, 53 | max_depth=25, max_features=130), 54 | ] 55 | 56 | print ">>>>>>>>>>>>>>>>>>>>>>>>>>>" 57 | score = calcscore(ans/3, test_y.values) 58 | print score 59 | 60 | for clf in clfs: 61 | clf.fit(train_x, train_y) 62 | train_pre = (clf.predict(train_x) + 0.5).round() 63 | test_pre = (clf.predict(test_x) + 0.5).round() 64 | score = calcscore(test_pre, test_y.values) 65 | print score 66 | ans += test_pre 67 | 68 | ans=ans/6 69 | score = calcscore(ans, test_y.values) 70 | print score 71 | -------------------------------------------------------------------------------- /main/model/old_model/arima_pred.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Roger' 2 | 3 | from product import * 4 | 5 | ## arima model for predict 6 | ## with bic or smape loss 7 | base_path = "../../../data" 8 | f = open(base_path + '/results/predict_arma_61_os_bic_loss_b.csv', 'w') 9 | k = open(base_path + '/results/testroger.csv') 10 | 11 | qnm = {} 12 | for line in k.readlines(): 13 | item = line.split(',') 14 | qnm[int(item[0])] = line 15 | 16 | warnings.filterwarnings('ignore') 17 | best_model_list = {} 18 | pd_index = pd.date_range('2016-9-1', periods=75) 19 | 20 | index, shop = load_data_as_npdict() 21 | 22 | 23 | def evalx(shop_series, results_ARMA): 24 | correct = shop_series 25 | predict = results_ARMA 26 | return ali_eval(correct, predict) 27 | 28 | 29 | total_bic = 0 30 | for i in shop: 31 | # eval with last 14 days 32 | # precess data 33 | train = shop[i][-61:] 34 | train_mean = np.mean(train) 35 | for it in range(train.shape[0]): 36 | if train[it] > train_mean * 3 or train[it] < train_mean * 0.1: 37 | train[it] = train_mean 38 | 39 | train_eval = train[:-14] 40 | test_eval = train[-14:] 41 | 42 | train_eval = np.append(train_eval, np.zeros(14)) 43 | # log 44 | train_eval[:-14] = np.log(train_eval[:-14]) 45 | 46 | df = pd.Series(train_eval, index=pd_index[:-14], dtype='f') 47 | # print(df) 48 | 49 | 50 | #### find d 51 | # TODO: change if there is some use 52 | d = 0 53 | df_diff = copy.deepcopy(df) 54 | # print(df) 55 | low_val = 99999 56 | for d_tmp in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]: 57 | df_diff = one_step_diff(df, d_tmp) 58 | value = test_stationarity(df_diff) 59 | # print(value) 60 | if value: 61 | if value < low_val: 62 | d = d_tmp 63 | low_val = value 64 | df_diff = one_step_diff(df, d) 65 | dd = df_diff[d:-14] 66 | 67 | # grid search 68 | # find out the best parameters with df_eval (bic or eval) 69 | P = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 70 | Q = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 71 | p_b = 0 72 | q_b = 0 73 | bic_b = 999999999 74 | for p in P: 75 | for q in Q: 76 | df_eval = copy.deepcopy(df_diff) 77 | # print(df_eval) 78 | try: 79 | model = ARMA(dd, order=(p, q)) 80 | result_arma = model.fit(disp=-1, method='css') 81 | df_eval[-14:] = result_arma.predict('2016-10-18', '2016-10-31', dynamic=True) 82 | df_eval = one_step_recover(df_eval, d) 83 | df_eval = np.exp(df_eval) 84 | value = evalx(test_eval, df_eval[-14:]) 85 | if value < bic_b: 86 | p_b = p 87 | q_b = q 88 | model_b = model 89 | bic_b = value 90 | except: 91 | continue 92 | 93 | print('{0}th : d={1} p={2} q={3} loss={4}'.format(i, d, p_b, q_b, bic_b)) 94 | 95 | ## fit 96 | train = np.append(train, np.zeros(14)) 97 | # log it 98 | train[:-14] = np.log(train[:-14]) 99 | 100 | df = pd.Series(train, index=pd_index, dtype='f') 101 | df_diff = one_step_diff(df, d) 102 | dd = df_diff[d:-14] 103 | model = ARMA(dd, order=(p_b, q_b)) 104 | 105 | # if the series is not stable, then drop it 106 | try: 107 | result_arma = model.fit(disp=-1, method='css') 108 | predict_ts = result_arma.predict() 109 | df_diff[-14:] = result_arma.predict('2016-11-1', '2016-11-14', dynamic=True) 110 | df_diff = one_step_recover(df_diff, d) 111 | recover = np.exp(df_diff) 112 | r = [int(x) for x in recover[-14:]] 113 | for index in range(r.__len__()): 114 | if r[index] < 0: 115 | r[index] = 0 116 | s = ','.join([str(x) for x in r]) 117 | f.write('{0},{1}\n'.format(i, s)) 118 | except: 119 | f.write(qnm[i]) 120 | print('ouch!') 121 | 122 | total_bic += bic_b 123 | 124 | # output the mean bic 125 | print('mean bic: {0}'.format(total_bic * 1.0 / 2000)) 126 | -------------------------------------------------------------------------------- /main/model/old_model/arima_test.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Roger' 2 | 3 | import product 4 | import numpy as np 5 | 6 | ## simple test with average 7 | base_path = "../../../data/" 8 | data = np.loadtxt(base_path + 'statistics/shopid_day_num.txt', delimiter=',') 9 | best_day = [0, 0, 0] 10 | best_score = 99999999 11 | 12 | ## ignore guoqing and zero 13 | tmp = np.zeros([2000, 28]) 14 | for i in range(2000): 15 | sum = 1 16 | for j in range(1, data.shape[1]): 17 | if sum > 28: 18 | continue 19 | if data[i][-j] != 0: 20 | tmp[i][-sum] = data[i][-j] 21 | sum += 1 22 | 23 | data = tmp[:, -21:] 24 | train = tmp[:, :-7] 25 | test = tmp[:, -7:] 26 | 27 | for day_21 in np.arange(0, 1, 0.01): 28 | for day_14 in np.arange(0, 1 - day_21, 0.01): 29 | tmp_rlt = np.zeros([data.shape[0], 7]) 30 | for j in range(0, 7): 31 | tmp_rlt[:, j] = train[:, j - 1] * day_21 + train[:, 6 + j] * day_14 + train[:, 13 + j] * ( 32 | 1 - day_21 - day_14) 33 | value = product.ali_eval(test, tmp_rlt) 34 | if value < best_score: 35 | best_score = value 36 | best_day = [day_21, day_14, 1 - day_21 - day_14] 37 | 38 | print(best_day, best_score) 39 | 40 | result = np.zeros([data.shape[0], 15]) 41 | 42 | ## last 21days every 7 sum 43 | for i in range(2000): 44 | result[i, 0] = i + 1 45 | 46 | for j in range(1, 8): 47 | result[:, j] = data[:, j - 1] * best_day[0] + data[:, 6 + j] * best_day[1] + data[:, 13 + j] * best_day[2] 48 | result[:, 7 + j] = result[:, j] 49 | 50 | np.savetxt(base_path + 'results/result_avg7_common_with_last_week.csv', result, delimiter=',', fmt='%d') 51 | -------------------------------------------------------------------------------- /main/model/old_model/linearmodel.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Roger' 2 | 3 | import numpy as np 4 | from sklearn import linear_model 5 | 6 | ## this is the base test for linear model to predict linear model 7 | ## we consider about the increasing model to transform our model 8 | base_path = "../../../data/statistics/" 9 | 10 | 11 | # def eval 12 | def eval(cor, pdt): 13 | answer = (cor - pdt) * 1.0/ (cor + pdt) 14 | answer = np.nan_to_num(answer) 15 | return np.sum(np.fabs(answer)) * 1.0 / answer.shape[0] 16 | 17 | 18 | # load data 19 | def load_data(): 20 | data = np.loadtxt(base_path + 'shopid_day_num.txt', delimiter=',') 21 | return data[:, 1:] 22 | 23 | 24 | # sum data 25 | def process_data(data): 26 | result = np.zeros(data.shape) 27 | result[0] = data[0] 28 | for i in range(1, data.shape[0]): 29 | result[i] = data[i] + result[i - 1] 30 | return result 31 | 32 | 33 | # transform the sum data to real data 34 | def rereal_data(base, data): 35 | result = np.zeros(data.shape) 36 | result[0] = data[0] - base 37 | for i in range(1, data.shape[0]): 38 | result[i] = data[i] - data[i - 1] 39 | return result 40 | 41 | 42 | # predict with Ridge 43 | def predict(alphas, offset, d): 44 | reg = linear_model.RidgeCV(alphas=alphas) 45 | data = process_data(d) 46 | train = data[:-offset] 47 | test = d[-offset:] 48 | x = np.linspace(1, data.shape[0], data.shape[0]) 49 | 50 | reg.fit(x[:-offset, None], train) 51 | result = reg.predict(x[-offset:, None]) 52 | 53 | r = rereal_data(result[0], result) 54 | return eval(r[1:], test[1:]) 55 | 56 | 57 | # predict for all 58 | def predict_all(alphas, offset, d): 59 | sum = 0 60 | for i in range(d.shape[0]): 61 | sum += predict(alphas, offset, d[i]) 62 | 63 | return sum * 1.0/ d.shape[0] 64 | 65 | 66 | # test 67 | if __name__ == '__main__': 68 | par = [0.1, 0.2, 0.3, 0.4, 0.5, 1, 5, 10] 69 | data = load_data() 70 | # predict(par,14, data[0,-offset:]) 71 | best_result = 9999 72 | best_offset = 0 73 | for offset in range(1, 92): 74 | re_of = offset + 14 75 | re = predict_all(par, 14, data[:, -re_of:]) 76 | if re < best_result: 77 | best_result = re 78 | best_offset = offset 79 | 80 | print(best_offset) 81 | print(best_result) 82 | -------------------------------------------------------------------------------- /main/model/old_model/prepare.py: -------------------------------------------------------------------------------- 1 | __author__ = 'roger' 2 | 3 | import numpy as np 4 | import datetime 5 | 6 | ## prepare data 7 | base_path = "../../../data/statistics/" 8 | 9 | 10 | def load_data_as_npdict(): 11 | shop = {} 12 | index = {} 13 | begin_time = datetime.date(2015, 7, 1) 14 | with open(base_path + 'shopid_day_num.txt', 'r') as f: 15 | for line in f.readlines(): 16 | item = line.strip().split(',') 17 | shopId = int(item[0]) 18 | if shopId not in shop: 19 | shop[shopId] = np.array(item[1:], 'f') 20 | 21 | for i in range(489): 22 | if begin_time + datetime.timedelta(i) != datetime.date(2015, 12, 12): 23 | index[i] = begin_time + datetime.timedelta(i) 24 | return index, shop 25 | 26 | 27 | def change_date_to_str(date): 28 | return '-'.join([str(date.year), str(date.month), str(date.day)]) 29 | 30 | 31 | if __name__ == '__main__': 32 | index, shop = load_data_as_npdict() 33 | for i in shop: 34 | print(shop[i]) 35 | -------------------------------------------------------------------------------- /main/model/old_model/product.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Roger' 2 | 3 | import copy 4 | import warnings 5 | 6 | import pandas as pd 7 | from statsmodels.tsa.arima_model import ARMA 8 | from test import test_stationarity 9 | 10 | from prepare import * 11 | 12 | ## some little tools for fast test and model 13 | ## we define grid searh for model model and predict 14 | ## eval with bic or smape 15 | warnings.filterwarnings('ignore') 16 | 17 | P_range = [0, 1, 2, 3, 4, 5, 6, 7] 18 | Q_range = [0, 1, 2, 3, 4, 5, 6, 7] 19 | 20 | 21 | ## common eval 22 | def ali_eval(correct, predict): 23 | answer = (correct - predict) * 1.0/ (correct + predict) 24 | answer = np.nan_to_num(answer) 25 | return np.sum(np.fabs(answer)) * 1.0/ answer.shape[0] 26 | 27 | 28 | ## ARIMA eval 29 | def bic(shop_series, results_ARMA): 30 | return results_ARMA.bic 31 | 32 | 33 | def eval1(shop_series, results_ARMA): 34 | index = shop_series.values.shape[0] // 2 35 | correct = shop_series.values[-index:] 36 | predict = results_ARMA.predict().values[-index:] 37 | return ali_eval(correct, predict) 38 | 39 | 40 | def eval2(shop_series, results_ARMA): 41 | correct = shop_series.values 42 | predict = results_ARMA.forecast(14)[0] 43 | # print(predict) 44 | 45 | return ali_eval(correct, predict) 46 | 47 | 48 | ## difference 49 | def find_best_one_step(series): 50 | for i in range(14): 51 | tmp = one_step_diff(series, i) 52 | if test_stationarity(tmp): 53 | return i 54 | 55 | return 0 56 | 57 | 58 | ## one step difference 59 | def one_step_diff(series, d=0): 60 | if d == 0: 61 | return series 62 | size = series.shape[0] 63 | result = copy.deepcopy(series) 64 | for i in range(size - 1, d - 1, -1): 65 | result[i] = result[i] - result[i - d] 66 | 67 | return result 68 | 69 | 70 | ## one step diff recover 71 | def one_step_recover(series, d=0): 72 | if d == 0: 73 | return series 74 | size = series.shape[0] 75 | result = copy.deepcopy(series) 76 | for i in range(d, size): 77 | result[i] = result[i] + result[i - d] 78 | 79 | return result 80 | 81 | 82 | ## load data 83 | def load_data_and_create_series(begin_time, days): 84 | index, shop = load_data_as_npdict() 85 | 86 | # TODO: pre process data 87 | pd_index = pd.date_range(begin_time, periods=days) 88 | 89 | shop_series_list = {} 90 | 91 | for i in shop: 92 | # TODO: series analysis 93 | if i not in shop_series_list: 94 | train = shop[i][-days:] 95 | train_mean = np.mean(train) 96 | for it in range(days): 97 | if train[it] > train_mean * 5 or train[it] < train_mean * 0.05: 98 | train[it] = train_mean 99 | shop_series_list[i] = pd.Series(train, index=pd_index, dtype='f') 100 | return shop_series_list 101 | 102 | 103 | def find_best_model(shop_series, eval): 104 | init_value = 999999999 105 | best_p = 0 106 | best_q = 0 107 | best_model = None 108 | 109 | # simple cutdown 110 | if eval == eval2: 111 | train = shop_series[:-14] 112 | test = shop_series[-14:] 113 | else: 114 | train = shop_series 115 | test = shop_series 116 | 117 | ################ 118 | train = np.log(train) 119 | d = find_best_one_step(train) 120 | train = one_step_diff(train, d) 121 | ################ 122 | for p in P_range: 123 | for q in Q_range: 124 | try: 125 | model = ARMA(train[d:], order=(p, q)) # TODO: ARIMA zero problem 126 | results_ARMA = model.fit(disp=-1, method='css') 127 | value = eval(test, results_ARMA) 128 | # print(value) 129 | if value < init_value: 130 | best_p = p 131 | best_q = q 132 | init_value = value 133 | except: 134 | # print("something wrong!") 135 | continue 136 | 137 | print(d, best_p, best_q, init_value) 138 | best_model = ARMA(train[d:], order=(best_p, best_q)) 139 | best_model = best_model.fit(disp=-1, method='css') 140 | return d, init_value, train, best_model 141 | 142 | 143 | def find_all_best_model(shop_series_list, eval=bic): 144 | value = 0 145 | sum = 0 146 | best_model_list = {} 147 | for id in shop_series_list: 148 | print('find {0}th model:'.format(id)) 149 | d, init_value, train, best_model = find_best_model(shop_series_list[id], eval) 150 | value += init_value 151 | sum += 1 152 | if best_model is not None: 153 | # best_model_list[id] = best_model 154 | result = best_model.predict('2016-11-1', '2016-11-14', dynamic=True) 155 | result = np.append(train.values, result.values) 156 | print(result) 157 | result = one_step_recover(result, d) 158 | print(result) 159 | result = np.exp(result) 160 | best_model_list[id] = result[-14:] 161 | else: 162 | print('Ouch!') 163 | print('mean lost: {0}'.format(value * 1.0 / sum)) 164 | return best_model_list 165 | 166 | 167 | # discard 168 | def predict_result(best_model_list): 169 | result_list = {} 170 | for id in best_model_list: 171 | # result = best_model_list[id].predict('2016-11-1', '2016-11-14', dynamic=True) 172 | # result_list[id] = result.values 173 | result = best_model_list[id].forecast(28)[0] 174 | result_list[id] = result[-14:] 175 | print(result[-14:]) 176 | return result_list 177 | 178 | 179 | def save_result(result_list): 180 | f = open('predict_arma_61_os_bic.csv', 'w') 181 | for i in result_list: 182 | r = [int(x) for x in result_list[i]] 183 | for index in range(r.__len__()): 184 | if r[index] < 0: 185 | r[index] = 0 186 | s = ','.join([str(x) for x in r]) 187 | f.write('{0},{1}\n'.format(i, s)) 188 | 189 | 190 | if __name__ == '__main__': 191 | shop_series_list = load_data_and_create_series('2016-9-1', 61) 192 | # count_stationaryity(shop_series_list,7) 193 | for i in range(20, 2000): 194 | shop_series_list.pop(i) 195 | best_model_list = find_all_best_model(shop_series_list, eval=bic) 196 | # result_list = predict_result(best_model_list) 197 | # 198 | save_result(best_model_list) 199 | -------------------------------------------------------------------------------- /main/model/old_model/test.py: -------------------------------------------------------------------------------- 1 | __author__ = 'Roger' 2 | 3 | import pandas as pd 4 | from statsmodels.tsa.stattools import adfuller 5 | 6 | from prepare import * 7 | 8 | 9 | ## some test stationary for datas 10 | 11 | 12 | # stationarity with ADF test 13 | def test_stationarity(timeseries): 14 | # Determing rolling statistics 15 | # rolmean = pd.rolling_mean(timeseries, window=window) 16 | # rolstd = pd.rolling_std(timeseries, window=window) 17 | 18 | # Plot rolling statistics: 19 | # orig = plt.plot(timeseries, color='blue',label='Original') 20 | # mean = plt.plot(rolmean, color='red', label='Rolling Mean') 21 | # std = plt.plot(rolstd, color='black', label = 'Rolling Std') 22 | # plt.legend(loc='best') 23 | # plt.title('Rolling Mean & Standard Deviation') 24 | # plt.show(block=False) 25 | 26 | # Perform Dickey-Fuller test: 27 | # print('Results of Dickey-Fuller Test:') 28 | try: 29 | dftest = adfuller(timeseries, autolag='AIC') 30 | dfoutput = pd.Series(dftest[0:4], 31 | index=['Test Statistic', 'p-value', '#Lags Used', 'Number of Observations Used']) 32 | for key, value in dftest[4].items(): 33 | dfoutput['Critical Value (%s)' % key] = value 34 | # print(dfoutput) 35 | if dfoutput['Test Statistic'] < dfoutput['Critical Value (1%)']: 36 | return dfoutput['p-value'] 37 | else: 38 | return False 39 | except: 40 | return False 41 | 42 | 43 | # count stationaryity 44 | def count_stationaryity(timeseries, window): 45 | sum = 0 46 | for series in timeseries: 47 | if test_stationarity(timeseries[series], window) == True: 48 | sum += 1 49 | 50 | print(sum) 51 | 52 | 53 | # test 54 | if __name__ == '__main__': 55 | index, shop = load_data_as_npdict() 56 | sum = 0 57 | days = 61 58 | # time series 59 | pd_index = pd.date_range('2016-10-1', periods=days) 60 | for i in shop: 61 | # mean 62 | data = shop[i][-days:] 63 | data_mean = np.mean(data) 64 | for i in range(days): 65 | if data[i] < 0.01 * data_mean or data[i] > 3 * data_mean: 66 | data[i] = data_mean 67 | 68 | df = pd.Series(data, index=pd_index) 69 | value = test_stationarity(df, 7) 70 | # print(value['Test Statistic']) 71 | if value['Test Statistic'] < value['Critical Value (1%)']: 72 | sum += 1 73 | # print(data_mean) 74 | 75 | print(sum) 76 | -------------------------------------------------------------------------------- /main/model/predict_two_week.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | from functools import reduce 4 | from sklearn.ensemble import ExtraTreesRegressor, GradientBoostingRegressor 5 | from sklearn.ensemble import RandomForestRegressor 6 | from sklearn.feature_selection import SelectFromModel 7 | import time 8 | from unit import * 9 | 10 | 11 | ''' 12 | 我们竞赛中主要使用的模型,使用sklearn的ExtraTreeRegress 13 | 14 | 1. 使用平滑所有的数据集 15 | 2. 线下offlineTest 16 | train ZA->BC 17 | test AB->CD 18 | 3.线上onlineTest 19 | train ZAB->CD 20 | test BCD->EF(ans) 21 | 4.使用ExtraTreesRegressor 连续预测14天数值 22 | 23 | ''' 24 | 25 | #ET参数 26 | params = { 27 | 'n_estimators': 1662, 28 | 'n_jobs': -1, 29 | 'random_state': 1, 30 | 'min_samples_split': 2, 31 | 'min_samples_leaf': 1, 32 | 'max_depth': 24, 33 | 'max_features': 40 34 | } 35 | 36 | #特征的合并 37 | def merge(a, b, shop): 38 | fc = lambda x, y: pd.merge(x, y, on='shop_id') 39 | trade = reduce(fc, a).drop('shop_id', axis=1) 40 | visit = reduce(fc, b).drop('shop_id', axis=1) 41 | 42 | cat1 = ndarray2df(shop.cate_1_name.values.reshape(2000, 1), 'cat1_') 43 | cat2 = ndarray2df(shop.cate_2_name.values, 'cat2_') 44 | cat3 = ndarray2df(shop.cate_3_name.values.reshape(2000, 1), 'cat3_') 45 | 46 | location = ndarray2df(shop.location_id.values.reshape(2000, 1), 'loc_') 47 | 48 | jL = [calcOpenDay(trade), cat1, cat2, cat3, location] 49 | jL.extend(ExtractMonthFeature()) 50 | jL.extend(ExtractYearFeature()) 51 | jL.extend(ExtractTrainFeature(trade)) 52 | 53 | trade['sum'], trade['mean'], trade['median'], \ 54 | trade['max'], trade['min'], trade['var'] = \ 55 | trade.sum(axis=1), trade.mean(axis=1), trade.median(axis=1), \ 56 | trade.max(axis=1), trade.min(axis=1), trade.var(axis=1) 57 | 58 | labelindex = {i: 'visit_{0}'.format(i) for i in visit.columns.values} 59 | jL.append(visit.rename_axis(labelindex, axis='columns')) 60 | 61 | return reduce(lambda x, y: x.join(y, how='left'), jL) 62 | 63 | #线下测试调参 64 | def offlineTest(trade, visit, shop_info, version): 65 | merge(trade[:2], visit[:2], shop_info).to_csv('../../data/test_train/' + version + 'train_off_x.csv', index=False) 66 | trade[2:4].drop('shop_id', axis=1).to_csv('../../data/test_train/' + version + 'train_off_y.csv', index=False) 67 | 68 | merge(trade[1:3], visit[1:3], shop_info).to_csv('../../data/test_train/' + version + 'test_off_x.csv', index=False) 69 | trade[3:5].drop('shop_id', axis=1).to_csv('../../data/test_train/' + version + 'test_off_y.csv', index=False) 70 | 71 | train_off_x, train_off_y = pd.read_csv('../../data/test_train/' + version + 'train_off_x.csv'), pd.read_csv( 72 | '../../data/test_train/' + version + 'train_off_y.csv') 73 | test_off_x, test_off_y = pd.read_csv('../../data/test_train/' + version + 'test_off_x.csv'), pd.read_csv( 74 | '../../data/test_train/' + version + 'test_off_y.csv') 75 | 76 | ET = ExtraTreesRegressor(**params) 77 | ET.fit(train_off_x, train_off_y) 78 | features = ET.feature_importances_ 79 | feature_sort = (features / np.sum(features) * 100).round(4) 80 | feature_index = np.argsort(feature_sort) 81 | 82 | for i in feature_index: 83 | print('{0} : {1}'.format(train_off_x.columns.values[i], feature_sort[i])) 84 | 85 | ret = ET.predict(test_off_x + 0.5).round() 86 | print(calcscore(ret, test_off_y.values)) 87 | 88 | #线上训练预测 89 | def onlineTest(trade, visit, shop_info, version): 90 | merge(trade[:3], visit[:3], shop_info).to_csv('../../data/test_train/' + version + 'train_on_x.csv', index=False) 91 | trade[3:5].drop('shop_id', axis=1).to_csv('../../data/test_train/' + version + 'train_on_y.csv', index=False) 92 | 93 | merge(trade[2:5], visit[1:4], shop_info).to_csv('../../data/test_train/' + version + 'test_on_x.csv', index=False) 94 | 95 | train_on_x, train_on_y = pd.read_csv('../../data/test_train/' + version + 'train_on_x.csv'), pd.read_csv( 96 | '../../data/test_train/' + version + 'train_on_y.csv') 97 | test_on_x = pd.read_csv('../../data/test_train/' + version + 'test_on_x.csv') 98 | 99 | ET = ExtraTreesRegressor(**params) 100 | ET.fit(train_on_x, train_on_y) 101 | A = ET.predict(test_on_x).round() 102 | pre = repeat_result(A) 103 | np.savetxt('../../data/results/result_' + version + '.csv', 104 | np.concatenate((np.arange(1, 2001).reshape(2000, 1), pre), axis=1), delimiter=',', 105 | fmt='%d') 106 | 107 | if __name__ == "__main__": 108 | version = time.strftime('%Y-%m-%d', time.localtime(time.time())) + '_' 109 | path = "../../data/weekABCD/" 110 | trade = [pd.read_csv(path + 'week' + str(i) + '.csv') for i in range(0, 4)] + [pd.read_csv(path + 'weekD.csv')] 111 | # trade = [pd.read_csv(path + 'week' + chr(i) + '.csv') for i in range(ord('A'), ord('E'))] 112 | visit = [pd.read_csv(path + 'week' + chr(i) + '_view.csv') for i in range(ord('A'), ord('E'))] 113 | shop_info = pd.read_csv('../../data/statistics/shop_info_num.csv') 114 | 115 | # 0线下,1线上数据提交 116 | (offlineTest, onlineTest)[0](trade, visit, shop_info, version) 117 | 118 | 119 | -------------------------------------------------------------------------------- /main/model/run.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from base_model import * 3 | from gbdt import * 4 | from RandomForestRegreessor import * 5 | from use_first_week_predict_second_week import * 6 | 7 | def run(): 8 | ''' 9 | base_model 10 | :return: 11 | ''' 12 | version = time.strftime('%Y-%m-%d', time.localtime(time.time())) + '_' 13 | path = "../../data/weekABCD/" 14 | trade = [pd.read_csv(path + 'week' + str(i) + '.csv') for i in range(1, 4)] + [pd.read_csv(path + 'weekD.csv')] 15 | # trade = [pd.read_csv(path + 'week' + chr(i) + '.csv') for i in range(ord('A'), ord('E'))] 16 | visit = [pd.read_csv(path + 'week' + chr(i) + '_view.csv') for i in range(ord('A'), ord('E'))] 17 | shop_info = pd.read_csv('../../data/statistics/shop_info_num.csv') 18 | 19 | # 0线下,1线上数据提交 20 | (offlineTest, onlineTest)[0](trade, visit, shop_info, version) 21 | (offlineTest, onlineTest)[1](trade, visit, shop_info, version) 22 | 23 | ''' 24 | GBDT 25 | ''' 26 | gbdt() 27 | 28 | ''' 29 | RF 30 | ''' 31 | RF() -------------------------------------------------------------------------------- /main/model/run.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/model/run.pyc -------------------------------------------------------------------------------- /main/model/unit.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import pandas as pd 3 | import numpy as np 4 | 5 | """ 6 | ########################## 工具函数 ######################### 7 | """ 8 | 9 | 10 | def ndarray2df(arr, column_name='col_'): 11 | """将一个ndarray转为DataFrame类型""" 12 | cname = ['col_0'] if len(arr.shape) == 1 else [column_name + str(i) for i in range(arr.shape[1])] 13 | return pd.DataFrame(arr, columns=cname) 14 | 15 | 16 | def calc_score(p, d): 17 | """用于线下测试预测的评分""" 18 | return np.mean(np.abs(np.nan_to_num((p - d) * 1.0 / (p + d)))) 19 | 20 | 21 | def repeat_result(ret): 22 | """复制第一周结果接在第一周结果之后,在首列之前加入shop_id列""" 23 | return np.concatenate((ret, ret), axis=1) 24 | 25 | 26 | # 计算成绩 27 | def calcscore(p, d): 28 | return np.mean(np.abs(np.nan_to_num((p - d) * 1.0 / (p + d)))) 29 | 30 | 31 | """ 32 | ########################## 特征抽取 ################ 33 | """ 34 | 35 | 36 | # 获取训练三周对应的特征,包括每周的平均值,相对于前一天的幅度 37 | def ExtractTrainFeature(train): 38 | Rng, weekAvg = [], [] 39 | for i in range(len(train)): 40 | d, tot, num = train.ix[i, :], np.zeros(7), np.zeros(7) 41 | Rng.append([100 if int(d[j - 1]) == 0 else d[j]*1.0 / d[j - 1] for j in range(1, len(d))]) 42 | for j in range(len(d)): 43 | if d[j] > 0: 44 | tot[j % 7] += d[j] 45 | num[j % 7] += 1 46 | weekAvg.append([tot[k] / num[k] if num[k] else 1 for k in range(7)]) 47 | return ndarray2df(np.asarray(Rng), 'Rng_'), \ 48 | ndarray2df(np.asarray(weekAvg), 'weekAvg_') 49 | 50 | 51 | def repeatRet(ret): 52 | return np.concatenate((np.arange(1, 2001).reshape(2000, 1), ret, ret), axis=1) 53 | 54 | 55 | # 计算开业率 56 | def calcOpenDay(train): 57 | return ndarray2df(np.where(train.ix[:, :] > 0, 1, 0), 'openDay_') 58 | 59 | 60 | # 获取最后一个月(除了10月1号一星期的数据)的平均值,求和以及中位数 61 | def ExtractMonthFeature(): 62 | shop = np.loadtxt('../../data/statistics/count_user_pay_avg_no_header.csv', delimiter=',').T 63 | dateRange = pd.date_range('2016-3-1', '2016-10-31', freq='D', name='Date') 64 | shop = pd.DataFrame(data=shop[-245:, :], index=dateRange, columns=range(1, 2001)) 65 | monthSum = ndarray2df(shop.ix['2016-10-8':'2016-10-31'].sum(axis=0).values.reshape(2000, 1), 'monthsum_') 66 | monthMean = ndarray2df(shop.ix['2016-10-8':'2016-10-31'].mean(axis=0).values.reshape(2000, 1), 'monthmean_') 67 | monthMedian = ndarray2df(shop.ix['2016-10-8':'2016-10-31'].median(axis=0).values.reshape(2000, 1), 'monthmedian_') 68 | return monthSum, monthMean, monthMedian 69 | 70 | 71 | # 获取每一个月方差,平均值和中位数 每星期之间的方法和每星期的浮动 多个月整体的sum,median和mean 72 | def ExtractYearFeature(): 73 | shop = np.loadtxt('../../data/statistics/count_user_pay_avg_no_header.csv', delimiter=',').T 74 | dateRange = pd.date_range('2016-3-1', '2016-10-31', freq='D', name='Date') 75 | shop = pd.DataFrame(data=shop[-245:, :], index=dateRange, columns=range(1, 2001)) 76 | yearVar, yearRng = np.zeros((2000, 7)), np.zeros((2000, 6)) 77 | tmp = shop.ix['2016-3-1':'2016-9-26'].values 78 | for i in range(2000): 79 | tw = tmp[:, i].reshape(30, 7) 80 | yearVar[i, :] = np.var(tw, axis=0) 81 | avg = np.mean(tw, axis=0) 82 | for j in range(1, 7): 83 | yearRng[i, j - 1] = 10 if int(avg[j - 1]) == 0 else avg[j]*1.0 / avg[j - 1] 84 | yearMedian, yearAvg = np.zeros((2000, 8)), np.zeros((2000, 8)) 85 | for i, m in enumerate(('31', '30', '31', '30', '31', '31', '30', '31')): 86 | tmp = shop.ix['2016-' + str(i + 3) + '-1':'2016-' + str(i + 3) + '-' + m] 87 | yearMedian[:, i] = tmp.median(axis=0).values 88 | yearAvg[:, i] = tmp.mean(axis=0).values 89 | 90 | yearMRng = np.zeros((2000, 8)) 91 | for i in range(2000): 92 | for j in range(1, 8): 93 | yearMRng[i, j - 1] = 10 if int(yearAvg[i, j - 1]) == 0 else yearAvg[i, j]*1.0 / yearAvg[i, j - 1] 94 | 95 | yearMax = shop.ix['2016-3-1':'2016-10-30'].max(axis=0).values.reshape(2000, 1) 96 | yearMin = shop.ix['2016-3-1':'2016-10-30'].min(axis=0).values.reshape(2000, 1) 97 | yearStd = shop.ix['2016-3-1':'2016-10-30'].std(axis=0).values.reshape(2000, 1) 98 | 99 | return ndarray2df(yearMedian, 'yearMedian_'), \ 100 | ndarray2df(yearMax, 'yearMax_'), \ 101 | ndarray2df(yearMin, 'yearMin_'), \ 102 | ndarray2df(yearStd, 'yearStd_'), \ 103 | ndarray2df(yearVar, 'yearVar_'), \ 104 | ndarray2df(yearRng, 'yearRng'), \ 105 | ndarray2df(yearMRng, 'yearMRng_') 106 | 107 | 108 | def calc_open_day(train): 109 | """将有交易的天设置为1,没有交易的天设置为0""" 110 | return ndarray2df(np.where(train.ix[:, :] > 0, 1, 0), 'open_day_') 111 | 112 | 113 | def open_ratio(threshold=0, start=0, end=488, bigger=True): 114 | """计算开业率""" 115 | count_user_pay = pd.read_csv('../../data/statistics/count_user_pay.csv') 116 | open_ratio_arr, tot = [], end - start + 1 117 | for row in range(len(count_user_pay)): 118 | shop = count_user_pay.ix[row][start:end] 119 | open_ratio_arr.append(round((shop > 0).sum() / float(tot), 4)) 120 | open_ratio_arr = np.asarray(open_ratio_arr) 121 | index = bigger and open_ratio_arr >= threshold or open_ratio_arr <= threshold 122 | return pd.DataFrame({'shop_id': (count_user_pay.shop_id)[index].values, 'open_ratio': open_ratio_arr[index]}) 123 | 124 | 125 | def basic_feature(train): 126 | """基本统计量""" 127 | return train.sum(axis=1), train.mean(axis=1), train.median(axis=1), \ 128 | train.max(axis=1), train.min(axis=1), train.var(axis=1), \ 129 | train.std(axis=1), train.mad(axis=1) 130 | 131 | 132 | def week_ratio_feature(train, train_sum, week, weekend): 133 | """每周7天的特征""" 134 | fc = lambda x: train[x].sum(axis=1) / train_sum.replace(0, 1) 135 | for i, day in enumerate(week): 136 | for j in range(len(day)): 137 | day[j] = day[j][:-2] + str(int(day[j][-2:]) + i) 138 | ratio_tues, ratio_wed, ratio_thurs, ratio_fri, ratio_sat, ratio_sun, ratio_mon = list(map(fc, week)) 139 | ratio_wk = (train[weekend]).sum(axis=1) / (train_sum.replace(0, 1)) 140 | return ratio_mon, ratio_tues, ratio_wed, ratio_thurs, ratio_fri, ratio_sat, ratio_sun, ratio_wk 141 | 142 | 143 | def global_day_feature(data, index=-61): 144 | """全局数据按天基本统计量""" 145 | return data.ix[:, index:].sum(axis=1), data.ix[:, index:].mean(axis=1), \ 146 | data.ix[:, index:].median(axis=1), data.ix[:, index:].max(axis=1), \ 147 | data.ix[:, index:].var(axis=1), data.ix[:, index:].std(axis=1), \ 148 | data.ix[:, index:].mad(axis=1) 149 | 150 | 151 | def global_month_feature(data): 152 | """全局数据按月基本统计量""" 153 | month_sum, month_average, month_median, months = [], [], [], [31, 30, 31] 154 | month_max, month_min, month_std, month_var = [], [], [], [] 155 | for i in range(1, len(months)): 156 | months[i] += months[i - 1] 157 | 158 | for i in range(len(data)): 159 | data_ = data.ix[i, :].values 160 | month_sum_, month_average_, month_median_, month_max_, month_min_, month_std_, month_var_ = list( 161 | map(lambda f: f(data_[-months[0]:]), [np.sum, np.mean, np.median, np.max, np.min, np.std, np.var])) 162 | for j in range(1, len(months)): 163 | d = data_[-months[j]:-months[j - 1]] 164 | month_average_.insert(0, np.mean(d)) 165 | month_sum_.insert(0, np.sum(d)) 166 | month_median_.insert(0, np.median(d)) 167 | month_max_.insert(0, np.max(d)) 168 | month_min_.insert(0, np.min(d)) 169 | month_std_.insert(0, np.std(d)) 170 | month_var_.insert(0, np.var(d)) 171 | 172 | month_average.append(month_average_) 173 | month_sum.append(month_sum_) 174 | month_median.append(month_median_) 175 | month_max.append(month_max_) 176 | month_min.append(month_min_) 177 | month_std.append(month_std_) 178 | month_var.append(month_var_) 179 | 180 | return ndarray2df(np.asarray(month_sum), 'month_sum_'), \ 181 | ndarray2df(np.asarray(month_average), 'month_avg_'), \ 182 | ndarray2df(np.asarray(month_median), 'month_median_'), \ 183 | ndarray2df(np.asarray(month_max), 'month_max_'), \ 184 | ndarray2df(np.asarray(month_min_), 'month_min_'), \ 185 | ndarray2df(np.asarray(month_std), 'month_std_'), \ 186 | ndarray2df(np.asarray(month_var), 'month_var_') 187 | 188 | 189 | def day_feature(data): 190 | """相邻天的差值以及周内各天的均值""" 191 | diff, day_avg = [], [] 192 | for i in range(len(data)): 193 | d = data.ix[i, :].values 194 | diff.append([d[j] - d[j - 1] for j in range(1, len(d))]) 195 | sum_, tot_ = np.zeros(7), np.zeros(7) 196 | for j in range(len(d)): 197 | sum_[j % 7] += d[j] 198 | tot_[j % 7] += int(d[j] > 0) 199 | day_avg.append([float(sum_[j]) / tot_[j] if tot_[j] else 0 for j in range(7)]) 200 | return ndarray2df(np.asarray(diff), 'diff_'), ndarray2df(np.asarray(day_avg), 'seven_day_') 201 | 202 | 203 | def week_basic_feature(data): 204 | """每周的基本统计量""" 205 | week_sum, week_avg, week_median = [], [], [] 206 | week_max, week_min, week_std, week_var = [], [], [], [] 207 | for i in range(len(data)): 208 | d = data.ix[i, :].values 209 | arr = [d[:7], d[7:]] 210 | week_avg.append(list(map(np.mean, arr))) 211 | week_sum.append(list(map(np.sum, arr))) 212 | week_median.append(list(map(np.median, arr))) 213 | week_max.append(list(map(np.max, arr))) 214 | week_min.append(list(map(np.min, arr))) 215 | week_std.append(list(map(np.std, arr))) 216 | week_var.append(list(map(np.var, arr))) 217 | 218 | return ndarray2df(np.asarray(week_sum), 'week_sum_'), \ 219 | ndarray2df(np.asarray(week_avg), 'week_avg_'), \ 220 | ndarray2df(np.asarray(week_median), 'week_median_'), \ 221 | ndarray2df(np.asarray(week_max), 'week_max_'), \ 222 | ndarray2df(np.asarray(week_min), 'week_min_'), \ 223 | ndarray2df(np.asarray(week_std), 'week_std_'), \ 224 | ndarray2df(np.asarray(week_var), 'week_var_') 225 | 226 | 227 | def calc_open_ratio(): 228 | """计算开业率""" 229 | return 0.5 * (open_ratio(start=447, end=453).open_ratio + open_ratio(start=468, end=474).open_ratio) 230 | 231 | 232 | def shop_cate_feature(shop): 233 | """shop类型特征""" 234 | return ndarray2df(shop.cate_1_name.values.reshape(2000, 1), 'cat1_'), \ 235 | ndarray2df(shop.cate_2_name.values.reshape(2000, 1), 'cat2_'), \ 236 | ndarray2df(shop.cate_3_name.values.reshape(2000, 1), 'cat3_') 237 | 238 | 239 | def shop_location_feature(shop): 240 | """商店location_id特征""" 241 | return ndarray2df(shop.location_id.values.reshape(2000, 1), 'loc_') 242 | 243 | 244 | def calcWeekGainRate(train): 245 | """计算训练集中相邻周的总交易量的比率""" 246 | weekGainRate = [] 247 | for i in range(len(train)): 248 | d = train.ix[i, :] 249 | Gain = [] 250 | for j in range(1, int(len(d) / 7)): 251 | a, b = sum(d.values[(j - 1) * 7:j * 7]), sum(d.values[j * 7:(j + 1) * 7]) 252 | Gain.append(float(b) / a if a > 0 else 1) 253 | weekGainRate.append(Gain) 254 | return ndarray2df(np.asarray(weekGainRate), 'weekGainRate_') 255 | 256 | 257 | if __name__ == '__main__': 258 | pass 259 | -------------------------------------------------------------------------------- /main/model/unit.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/model/unit.pyc -------------------------------------------------------------------------------- /main/model/use_first_week_predict_second_week.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | from functools import reduce 4 | from sklearn.ensemble import ExtraTreesRegressor, GradientBoostingRegressor 5 | from sklearn.ensemble import RandomForestRegressor 6 | from sklearn.feature_selection import SelectFromModel 7 | import time 8 | from unit import * 9 | 10 | ''' 11 | 我们竞赛中主要使用的模型,使用sklearn的ExtraTreeRegress 12 | 13 | 1. 使用平滑所有的数据集 14 | 2. 线下offlineTest 15 | train AB->C 16 | test BC->D 17 | 3.线上onlineTest 18 | train ABC->D 19 | test BCD->E 20 | test CDE->F 21 | 4.使用ExtraTreesRegressor 连续预测7天数值 22 | 5.第二星期利用预测出来的第一星期的结果进行预测 23 | 6.如果先对第一周预测出来的结果利用规则先进行修正,第二周预测的效果会更好 24 | ''' 25 | 26 | # ET参数 27 | params = { 28 | 'n_estimators': 1662, 29 | 'n_jobs': -1, 30 | 'random_state': 1, 31 | 'min_samples_split': 2, 32 | 'min_samples_leaf': 1, 33 | 'max_depth': 24, 34 | 'max_features': 40 35 | } 36 | 37 | 38 | # 特征的合并 39 | def merge(a, b, shop): 40 | fc = lambda x, y: pd.merge(x, y, on='shop_id') 41 | trade = reduce(fc, a).drop('shop_id', axis=1) 42 | visit = reduce(fc, b).drop('shop_id', axis=1) 43 | 44 | cat1 = ndarray2df(shop.cate_1_name.values.reshape(2000, 1), 'cat1_') 45 | cat2 = ndarray2df(shop.cate_2_name.values, 'cat2_') 46 | cat3 = ndarray2df(shop.cate_3_name.values.reshape(2000, 1), 'cat3_') 47 | 48 | location = ndarray2df(shop.location_id.values.reshape(2000, 1), 'loc_') 49 | 50 | jL = [calcOpenDay(trade), cat1, cat2, cat3, location] 51 | jL.extend(ExtractMonthFeature()) 52 | jL.extend(ExtractYearFeature()) 53 | jL.extend(ExtractTrainFeature(trade)) 54 | 55 | trade['sum'], trade['mean'], trade['median'], \ 56 | trade['max'], trade['min'], trade['var'] = \ 57 | trade.sum(axis=1), trade.mean(axis=1), trade.median(axis=1), \ 58 | trade.max(axis=1), trade.min(axis=1), trade.var(axis=1) 59 | 60 | labelindex = {i: 'visit_{0}'.format(i) for i in visit.columns.values} 61 | jL.append(visit.rename_axis(labelindex, axis='columns')) 62 | 63 | return reduce(lambda x, y: x.join(y, how='left'), jL) 64 | 65 | 66 | # 线下测试调参 67 | def offlineTest(trade, visit, shop_info, version): 68 | merge(trade[:2], visit[:2], shop_info).to_csv('../../data/test_train/' + version + 'train_off_x.csv', index=False) 69 | trade[2].drop('shop_id', axis=1).to_csv('../../data/test_train/' + version + 'train_off_y.csv', index=False) 70 | 71 | merge(trade[1:3], visit[1:3], shop_info).to_csv('../../data/test_train/' + version + 'test_off_x.csv', index=False) 72 | trade[3].drop('shop_id', axis=1).to_csv('../../data/test_train/' + version + 'test_off_y.csv', index=False) 73 | 74 | train_off_x, train_off_y = pd.read_csv('../../data/test_train/' + version + 'train_off_x.csv'), pd.read_csv( 75 | '../../data/test_train/' + version + 'train_off_y.csv') 76 | test_off_x, test_off_y = pd.read_csv('../../data/test_train/' + version + 'test_off_x.csv'), pd.read_csv( 77 | '../../data/test_train/' + version + 'test_off_y.csv') 78 | 79 | ET = ExtraTreesRegressor(**params) 80 | ET.fit(train_off_x, train_off_y) 81 | features = ET.feature_importances_ 82 | feature_sort = (features / np.sum(features) * 100).round(4) 83 | feature_index = np.argsort(feature_sort) 84 | 85 | for i in feature_index: 86 | print('{0} : {1}'.format(train_off_x.columns.values[i], feature_sort[i])) 87 | 88 | ret = ET.predict(test_off_x + 0.5).round() 89 | print(calcscore(ret, test_off_y.values)) 90 | 91 | 92 | # 线上训练预测 93 | def onlineTest(trade, visit, shop_info, version): 94 | trade[3] = pd.read_csv(path + 'week4.csv') 95 | merge(trade[:3], visit[:3], shop_info).to_csv('../../data/test_train/' + version + 'train_on_x.csv', index=False) 96 | trade[3].drop('shop_id', axis=1).to_csv('../../data/test_train/' + version + 'train_on_y.csv', index=False) 97 | 98 | merge(trade[1:4], visit[1:4], shop_info).to_csv('../../data/test_train/' + version + 'test_on_x.csv', index=False) 99 | 100 | train_on_x, train_on_y = pd.read_csv('../../data/test_train/' + version + 'train_on_x.csv'), pd.read_csv( 101 | '../../data/test_train/' + version + 'train_on_y.csv') 102 | test_on_x = pd.read_csv('../../data/test_train/' + version + 'test_on_x.csv') 103 | 104 | ET = ExtraTreesRegressor(**params) 105 | ET.fit(train_on_x, train_on_y) 106 | A = ET.predict(test_on_x).round() 107 | pre = repeat_result(A) 108 | np.savetxt('../../data/results/result_' + version + '.csv', 109 | np.concatenate((np.arange(1, 2001).reshape(2000, 1), pre), axis=1), delimiter=',', 110 | fmt='%d') 111 | 112 | ################################################################################ 113 | merge(trade[2:5], visit[1:4], shop_info).to_csv('../../data/test_train/' + version + 'test_on_x.csv', index=False) 114 | test_on_x = pd.read_csv('../../data/test_train/' + version + 'test_on_x.csv') 115 | ET.fit(train_on_x, train_on_y) 116 | A = ET.predict(test_on_x).round() 117 | 118 | np.savetxt('../../data/results/result_' + version + '_2.csv', 119 | np.concatenate((np.arange(1, 2001).reshape(2000, 1), A), axis=1), delimiter=',', 120 | fmt='%d') 121 | 122 | 123 | if __name__ == "__main__": 124 | version = time.strftime('%Y-%m-%d', time.localtime(time.time())) + '_' 125 | path = "../../data/weekABCD/" 126 | trade = [pd.read_csv(path + 'week' + str(i) + '.csv') for i in range(1, 4)] + [pd.read_csv(path + 'weekD.csv')] 127 | # trade = [pd.read_csv(path + 'week' + chr(i) + '.csv') for i in range(ord('A'), ord('E'))] 128 | visit = [pd.read_csv(path + 'week' + chr(i) + '_view.csv') for i in range(ord('A'), ord('E'))] 129 | shop_info = pd.read_csv('../../data/statistics/shop_info_num.csv') 130 | 131 | # 0线下,1线上数据提交 132 | (offlineTest, onlineTest)[0](trade, visit, shop_info, version) 133 | -------------------------------------------------------------------------------- /main/model/use_first_week_predict_second_week.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/model/use_first_week_predict_second_week.pyc -------------------------------------------------------------------------------- /main/rule/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/rule/__init__.py -------------------------------------------------------------------------------- /main/rule/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/rule/__init__.pyc -------------------------------------------------------------------------------- /main/rule/hot_pot.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import numpy as np 3 | 4 | ''' 5 | 这里对火锅店进行处理,对于第二周上浮一定比例 6 | 统计了部分2015年11月1-7 相对于 11月8-14 的比例,发现整体提高了一些 7 | ''' 8 | 9 | 10 | def hot_pot(): 11 | filename = "../../data/statistics/shop_info.txt" 12 | fr = open(filename) 13 | is_hot = {} 14 | for line in fr.readlines(): 15 | data = line.strip().split(",") 16 | if data[-2] == "火锅": 17 | is_hot[int(data[0])] = 1 18 | return is_hot 19 | 20 | 21 | def base_hot_pot(filename, fileto, is_hot): 22 | predict = np.loadtxt(filename, delimiter=',') 23 | for i in range(predict.shape[0]): 24 | # print len(predict[i,1:]) 25 | for j in range(1, len(predict[i])): 26 | if j > 7 and is_hot.get(predict[i, 0], 0) == 1: 27 | predict[i, j] = predict[i, j] * 1.025 + 0.5 28 | np.savetxt(fileto, predict, fmt='%d', delimiter=',') 29 | 30 | if __name__ == '__main__': 31 | pass -------------------------------------------------------------------------------- /main/rule/hot_pot.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/rule/hot_pot.pyc -------------------------------------------------------------------------------- /main/rule/run.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | from weather import * 3 | from hot_pot import * 4 | from special_day import * 5 | import time 6 | 7 | def all_rule(): 8 | version = time.strftime('%Y-%m-%d', time.localtime(time.time())) + '_' 9 | filename1='../../data/results/result_' + version + '.csv' 10 | filename2='../../data/results/result_' + version + 'special_day.csv' 11 | filename3 = '../../data/results/result_' + version + 'special_day_weather.csv' 12 | filename4 = '../../data/results/result_' + version + 'special_day_weather_huopot.csv' 13 | shop_city = getShop_City() 14 | big_city(filename1, filename2, shop_city) 15 | 16 | weather_rule(filename2, filename3) 17 | 18 | is_hot = hot_pot() 19 | base_hot_pot(filename3, filename4, is_hot) 20 | 21 | if __name__ == '__main__': 22 | all_rule() -------------------------------------------------------------------------------- /main/rule/run.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/rule/run.pyc -------------------------------------------------------------------------------- /main/rule/special_day.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import numpy as np 3 | 4 | ''' 5 | 某些特殊天的规则 6 | 对11月11号的数据进行一定幅度的调整 7 | (具体参数通过2015年统计得到) 8 | 统计发现对于大城市,11的提高反而会少一些 9 | 对于23和1556两个商家存在太多的异常天,我们人工进行了修正 10 | ''' 11 | 12 | def getShop_City(): 13 | filename="../../data/statistics/shop_info.txt" 14 | shop_city = {} 15 | fr = open(filename) 16 | for line in fr.readlines(): 17 | data = line.strip().split(",") 18 | shop_city[int(data[0])] = data[1] 19 | return shop_city 20 | 21 | 22 | def big_city(filename, fileto, shop_city): 23 | list_23 = [23, 102, 106, 104, 110, 94, 91, 115, 102, 106, 104, 117, 95, 91, 112] 24 | list_1556 = [1556, 208, 192, 201, 196, 170, 179, 213, 208, 192, 201, 216, 178, 179, 206] 25 | citys = ["上海", "杭州", "北京", "广州", "南京", "武汉", "深圳"] # 26 | predict = np.loadtxt(filename, delimiter=',') 27 | for i in range(predict.shape[0]): 28 | shop_id = predict[i, 0] 29 | for j in range(1, len(predict[i])): 30 | if predict[i, 0] == 1824: 31 | predict[i, j] = 51 32 | if predict[i, 0] == 23: 33 | predict[i, j] = list_23[j] 34 | if predict[i, 0] == 1556: 35 | predict[i, j] = list_1556[j] 36 | if j == 11: 37 | if shop_city[shop_id] in citys: 38 | predict[i, j] = predict[i, j] * 1.03 + 0.5 # 1.03 39 | else: 40 | predict[i, j] = predict[i, j] * 1.09 + 0.5 # 1.09 41 | if j == 12: 42 | predict[i, j] = predict[i, j] * 1.025 + 0.5 # 1.025 43 | if j == 14: 44 | predict[i, j] = predict[i, j] * 0.96 + 0.5 45 | np.savetxt(fileto, predict, fmt='%d', delimiter=',') 46 | 47 | 48 | if __name__ == '__main__': 49 | pass 50 | 51 | -------------------------------------------------------------------------------- /main/rule/special_day.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/rule/special_day.pyc -------------------------------------------------------------------------------- /main/rule/weather.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import numpy as np 3 | 4 | ''' 5 | 天气的规则 6 | 统计了前21天下雨天占的比例 如果前段时间雨很多,则再晴天提高一定的比例 7 | (具体参数通过2015年统计得到,发现前段时间的天气会影响后面晴天以及雨天的销售量) 8 | 9 | 雨夹雪 5 10 | 中雪 1 11 | 中到大雪 2 12 | 晴 612 13 | 小雪 2 14 | 多云 560 15 | 雾 12 16 | 小到中雨 5 17 | 阴 202 18 | 小雨 216 19 | 霾 46 20 | 阵雨 37 21 | 小到中雪 2 22 | 阵雪 2 23 | 中雨 18 24 | ''' 25 | def weather_rule(filename, fileto): 26 | predict = np.loadtxt(filename, delimiter=',') 27 | weather = [] 28 | ww = {} 29 | wt = {} 30 | with open('../../data/statistics/weather-10-11.csv') as f: 31 | for line in f.readlines(): 32 | item = line.strip().split(',') 33 | weather.append(item) 34 | 35 | with open('../../data/statistics/weather_city.csv') as f: 36 | for line in f.readlines(): 37 | item = line.strip().split(',') 38 | if int(item[0]) not in wt: 39 | wt[int(item[0])] = float(item[11]) 40 | 41 | rate = np.zeros(2000) 42 | for i in weather: 43 | rain = 0 44 | # print(len(i[1:22])) 45 | for j in i[1:22]: 46 | if '雨' in j or '雪' in j: 47 | rain += 1 48 | 49 | rate[int(i[0]) - 1] = rain / 21.0 50 | 51 | # for xx in [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]: 52 | # print('{0} rain norain'.format(xx), np.sum(rate <= xx) / rate.shape[0], np.sum(rate >= xx) / rate.shape[0]) 53 | # print('rain in all 3 week:', np.sum(rate > 0.5) / rate.shape[0]) 54 | # print('rain in all 3 week:', np.sum(rate < 0.7) / rate.shape[0]) 55 | 56 | for i in weather: 57 | idx = int(i[0]) - 1 58 | cdx = 0 59 | wit = wt[int(i[0])] 60 | # print(len(i[22:36])) 61 | for j in i[22:36]: 62 | cdx += 1 63 | weight = 1 64 | if rate[idx] <= 1: 65 | if '大' in j: 66 | weight *= 0.97 67 | elif '中' in j: 68 | weight *= 0.99 69 | if '雨' in j: 70 | weight *= 0.98 71 | if '雪' in j: 72 | weight *= 0.99 73 | if '霾' in j: 74 | weight *= 0.99 75 | 76 | if rate[idx] >= 0.4: #0.4 77 | if '晴' in j: 78 | weight *= 1.08 # 1.08 79 | elif '多云' in j: 80 | weight *= 1.04 #1.04 81 | elif '阴' in j: 82 | weight *= 1.05 #1.05 83 | elif '雾' in j: 84 | weight *= 1.05 #1.05 85 | 86 | if j not in ww: 87 | ww[j] = weight 88 | predict[idx][cdx] *= weight 89 | np.savetxt(fileto, predict, fmt='%d', delimiter=',') 90 | 91 | 92 | if __name__ == '__main__': 93 | pass 94 | 95 | -------------------------------------------------------------------------------- /main/rule/weather.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/main/rule/weather.pyc -------------------------------------------------------------------------------- /notebook/Untitled.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": false 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "__author__ = 'Roger'\n", 12 | "\n", 13 | "import pandas as pd\n", 14 | "import numpy as np\n", 15 | "import matplotlib.pylab as plt\n", 16 | "from matplotlib.pylab import rcParams\n", 17 | "from statsmodels.tsa.stattools import adfuller\n", 18 | "from statsmodels.graphics.tsaplots import plot_acf, plot_pacf\n", 19 | "from statsmodels.tsa.arima_model import ARIMA,ARMA\n", 20 | "import datetime\n", 21 | "\n", 22 | "%matplotlib inline\n", 23 | "\n", 24 | "## draw arima predict result so that we can analysis easily\n", 25 | "## output the data\n", 26 | "\n", 27 | "# test for stationarity with adf\n", 28 | "def test_stationarity(timeseries):\n", 29 | " # Determing rolling statistics\n", 30 | "# rolmean = pd.rolling_mean(timeseries, window=window)\n", 31 | "# rolstd = pd.rolling_std(timeseries, window=window)\n", 32 | "\n", 33 | " # Plot rolling statistics\n", 34 | "# orig = plt.plot(timeseries, color='blue',label='Original')\n", 35 | "# mean = plt.plot(rolmean, color='red', label='Rolling Mean')\n", 36 | "# std = plt.plot(rolstd, color='black', label = 'Rolling Std')\n", 37 | "# plt.legend(loc='best')\n", 38 | "# plt.title('Rolling Mean & Standard Deviation')\n", 39 | "# plt.show(block=False)\n", 40 | "\n", 41 | " # Perform Dickey-Fuller test:\n", 42 | " print('Results of Dickey-Fuller Test:')\n", 43 | " dftest = adfuller(timeseries, autolag='AIC')\n", 44 | " dfoutput = pd.Series(dftest[0:4], index=['Test Statistic','p-value','#Lags Used','Number of Observations Used'])\n", 45 | " for key,value in dftest[4].items():\n", 46 | " dfoutput['Critical Value (%s)'%key] = value\n", 47 | " print(dfoutput)\n", 48 | " if dfoutput['Test Statistic'] < dfoutput['Critical Value (1%)']:\n", 49 | " return True\n", 50 | " else:\n", 51 | " return False\n", 52 | "\n", 53 | "def load_data_as_npdict():\n", 54 | " shop = {}\n", 55 | " index = {}\n", 56 | " begin_time = datetime.date(2015, 7, 1)\n", 57 | " with open('../data/shopid_day_num.txt', 'r') as f:\n", 58 | " for line in f.readlines():\n", 59 | " item = line.strip().split(',')\n", 60 | " shopId = int(item[0])\n", 61 | " if shopId not in shop:\n", 62 | " shop[shopId] = np.array(item[1:], 'f')\n", 63 | "\n", 64 | " for i in range(489):\n", 65 | " if begin_time + datetime.timedelta(i) != datetime.date(2015, 12, 12):\n", 66 | " index[i] = begin_time + datetime.timedelta(i)\n", 67 | " return index, shop\n", 68 | "\n", 69 | "index, shop = load_data_as_npdict()\n", 70 | "\n", 71 | "# test = [5,6,10,18,23,65]\n", 72 | "# test = [1,2,3,4,5,6]\n", 73 | "test = [18]\n", 74 | "\n", 75 | "# time series\n", 76 | "pd_index = pd.date_range('2016-9-1', periods=61)\n", 77 | "print(pd_index)\n", 78 | "\n", 79 | "# for i in test:\n", 80 | "# df = pd.Series(shop[i][-61:],index = pd_index)\n", 81 | "# pvalue = test_stationarity(df,7)\n", 82 | "# print(pvalue)\n", 83 | " # print(df.head())\n", 84 | "# test_stationarity(df,8)\n", 85 | "# draw_acf_pacf(df)\n", 86 | "\n", 87 | "for i in test:\n", 88 | " df = pd.Series(shop[i][-61:],index = pd_index,dtype='f')\n", 89 | " model = ARIMA(df,(0,0,3))\n", 90 | " results_AR = model.fit(disp=-1, method='css')\n", 91 | " result = results_AR.predict('2016-11-1', '2016-11-14', dynamic=True)\n", 92 | " print(result.values)\n", 93 | " result_s = pd.Series(result)\n", 94 | " \n", 95 | " df['2016-10-20'] = 1\n", 96 | " df_log = np.log(df)\n", 97 | " print(df)\n", 98 | " plt.plot(df)\n", 99 | " plt.plot(df_log, color='red')\n", 100 | "# test_stationarity(df_log, 3)\n", 101 | " \n", 102 | " plt.plot(df)\n", 103 | " plt.title('RSS: %.4f'% np.sum((results_AR.fittedvalues-df)**2))\n", 104 | " plt.plot(results_AR.fittedvalues, color='red')\n", 105 | " plt.plot(result, color='red')\n", 106 | " plt.show()\n", 107 | " \n", 108 | "for i in test:\n", 109 | " df = pd.Series(shop[i][-61:],index = pd_index,dtype='f')\n", 110 | "# model = ARIMA(df,(0,0,3))\n", 111 | "# results_AR = model.fit(disp=-1, method='css')\n", 112 | "# result = results_AR.predict('2016-11-1', '2016-11-8', dynamic=True)\n", 113 | "# result_s = pd.Series(result)\n", 114 | "# df.add(result_s)\n", 115 | " \n", 116 | " print(df)\n", 117 | "\n", 118 | "# diff" 119 | ] 120 | }, 121 | { 122 | "cell_type": "code", 123 | "execution_count": null, 124 | "metadata": { 125 | "collapsed": true 126 | }, 127 | "outputs": [], 128 | "source": [ 129 | "\n", 130 | "# pd_index = pd.date_range('2016-10-1', periods=31)\n", 131 | "# df = pd.Series(shop[23][-31:],index = pd_index,dtype='f')\n", 132 | "# df_log = np.log(df)\n", 133 | "# test_stationarity(df,5)\n", 134 | "# test_stationarity(df_log,5)\n", 135 | "\n", 136 | "# difference\n", 137 | "def diff_ts(ts, d):\n", 138 | " global shift_ts_list\n", 139 | " # dynamic predict the difference\n", 140 | " global last_data_shift_list\n", 141 | " shift_ts_list = []\n", 142 | " last_data_shift_list = []\n", 143 | " tmp_ts = ts\n", 144 | " for i in d:\n", 145 | " last_data_shift_list.append(tmp_ts[-i])\n", 146 | " print(last_data_shift_list)\n", 147 | " shift_ts = tmp_ts.shift(i)\n", 148 | " shift_ts_list.append(shift_ts)\n", 149 | " tmp_ts = tmp_ts - shift_ts\n", 150 | " tmp_ts.dropna(inplace=True)\n", 151 | " return tmp_ts\n", 152 | "\n", 153 | "# revive\n", 154 | "def predict_diff_recover(predict_value, d):\n", 155 | " if isinstance(predict_value, float):\n", 156 | " tmp_data = predict_value\n", 157 | " for i in range(len(d)):\n", 158 | " tmp_data = tmp_data + last_data_shift_list[-i-1]\n", 159 | " elif isinstance(predict_value, np.ndarray):\n", 160 | " tmp_data = predict_value[0]\n", 161 | " for i in range(len(d)):\n", 162 | " tmp_data = tmp_data + last_data_shift_list[-i-1]\n", 163 | " else:\n", 164 | " tmp_data = predict_value\n", 165 | " for i in range(len(d)):\n", 166 | " try:\n", 167 | " tmp_data = tmp_data.add(shift_ts_list[-i-1])\n", 168 | " except:\n", 169 | " raise ValueError('What you input is not pd.Series type!')\n", 170 | " tmp_data.dropna(inplace=True)\n", 171 | " return tmp_data\n" 172 | ] 173 | }, 174 | { 175 | "cell_type": "code", 176 | "execution_count": null, 177 | "metadata": { 178 | "collapsed": false 179 | }, 180 | "outputs": [], 181 | "source": [ 182 | "## draw image to show the relations between them\n", 183 | "index, shop = load_data_as_npdict()\n", 184 | "for i in [3,4,5,8,12,15,21,22]:\n", 185 | " s = shop[i][-30:]\n", 186 | " p = np.zeros(s.shape)\n", 187 | " for ii in range(s.shape[0]):\n", 188 | " if ii == 0:\n", 189 | " p[ii] = p[ii] + s[ii]\n", 190 | " else:\n", 191 | " p[ii] = p[ii - 1] + s[ii]\n", 192 | " plt.plot(s,color='red')\n", 193 | " plt.show()\n", 194 | " plt.plot(p,color='blue')\n", 195 | " plt.show()" 196 | ] 197 | }, 198 | { 199 | "cell_type": "code", 200 | "execution_count": null, 201 | "metadata": { 202 | "collapsed": false 203 | }, 204 | "outputs": [], 205 | "source": [ 206 | "# show the distribute and tend\n", 207 | "index, shop = load_data_as_npdict()\n", 208 | "for i in [3,4,5,8,12,15,21,22]:\n", 209 | " s = shop[i]\n", 210 | " p = np.zeros(s.shape)\n", 211 | " for ii in range(7,s.shape[0]):\n", 212 | " if s[ii-7] < s[ii]:\n", 213 | " p[ii] = 1\n", 214 | " else:\n", 215 | " p[ii] = 0\n", 216 | "\n", 217 | " plt.plot(s[-90:],color='red')\n", 218 | " plt.show()\n", 219 | " plt.scatter(range(30),p[-30:],color='blue')\n", 220 | " plt.axis([0,45,-2,2])\n", 221 | " plt.show()" 222 | ] 223 | }, 224 | { 225 | "cell_type": "code", 226 | "execution_count": null, 227 | "metadata": { 228 | "collapsed": false 229 | }, 230 | "outputs": [], 231 | "source": [ 232 | "## define the difference and recover function\n", 233 | "def one_step_diff(series ,d = 0):\n", 234 | " if d == 0:\n", 235 | " return series\n", 236 | " size = series.shape[0]\n", 237 | " print(size)\n", 238 | " result = series[:]\n", 239 | " for i in range(size - 1, d - 1, -1):\n", 240 | " result[i] = result[i] - result[i - d]\n", 241 | "\n", 242 | " return result\n", 243 | "\n", 244 | "\n", 245 | "def one_step_recover(series, d=0):\n", 246 | " if d == 0:\n", 247 | " return series\n", 248 | " size = series.shape[0]\n", 249 | " result = series[:]\n", 250 | " for i in range(d, size):\n", 251 | " result[i] = result[i] + result[i - d]\n", 252 | "\n", 253 | " return result\n", 254 | "\n", 255 | "## simple test\n", 256 | "pd_index = pd.date_range('2016-10-1', periods=30)\n", 257 | "df = pd.Series(np.append(shop[1][-15:], np.zeros(15)),index = pd_index,dtype='f')\n", 258 | "print(df)\n", 259 | "result = diff_ts(df,[5])\n", 260 | "result2 = one_step_diff(df, 5)\n", 261 | "print(result)\n", 262 | "print(result2)\n", 263 | "print(predict_diff_recover(result,[5]))\n", 264 | "print(one_step_recover(result2, 5))" 265 | ] 266 | }, 267 | { 268 | "cell_type": "code", 269 | "execution_count": null, 270 | "metadata": { 271 | "collapsed": false 272 | }, 273 | "outputs": [], 274 | "source": [ 275 | "import warnings\n", 276 | "warnings.filterwarnings('ignore')\n", 277 | "pd_index = pd.date_range('2016-10-11', periods=35)\n", 278 | "print(pd_index)\n", 279 | "\n", 280 | "# output the image to analysis the specific shop with arima\n", 281 | "\n", 282 | "for i in [1,2,3,4,700]:\n", 283 | " train = shop[i][-21:]\n", 284 | " \n", 285 | " \n", 286 | " train_mean = np.mean(train)\n", 287 | " for it in range(train.shape[0]):\n", 288 | " if train[it] > train_mean * 3 or train[it] < train_mean * 0.1:\n", 289 | " train[it] = train_mean\n", 290 | " \n", 291 | " train = np.append(shop[i][-21:],np.zeros(14))\n", 292 | " train[:-14] = np.log(train[:-14])\n", 293 | " df = pd.Series(train,index = pd_index, dtype='f')\n", 294 | "# print(df)\n", 295 | " d = 0\n", 296 | " df_diff = df\n", 297 | " while test_stationarity(df_diff) != True:\n", 298 | " d += 1\n", 299 | " df_diff = one_step_diff(df,d)\n", 300 | " \n", 301 | " dd = df_diff[d:-14]\n", 302 | "# print(dd)\n", 303 | "# df = pd.Series(,index = pd_index,dtype='f')\n", 304 | "# df_log = np.log(df)\n", 305 | "\n", 306 | " P = [0,1,2,3,4,5,6,7,8,9]\n", 307 | " Q = [0,1,2,3,4,5,6,7,8,9]\n", 308 | " p_b = 0\n", 309 | " q_b = 0\n", 310 | " model_b = None\n", 311 | " bic_b = 999999999\n", 312 | " for p in P:\n", 313 | " for q in Q:\n", 314 | " try:\n", 315 | " model = ARMA(dd, order=(p,q))\n", 316 | " result_arma = model.fit(disp=-1, method='css')\n", 317 | " if result_arma.bic < bic_b:\n", 318 | " p_b = p\n", 319 | " q_b = q\n", 320 | " model_b = model\n", 321 | " bic_b = result_arma.bic\n", 322 | " except:\n", 323 | " continue\n", 324 | " \n", 325 | " print(d,p_b,q_b,bic_b)\n", 326 | " model = model_b\n", 327 | " result_arma = model.fit(disp=-1, method='css')\n", 328 | " predict_ts = result_arma.predict()\n", 329 | " df_diff[-14:] = result_arma.predict('2016-11-1', '2016-11-14', dynamic=True)\n", 330 | " #print(predict_ts)\n", 331 | " #print(df_diff)\n", 332 | " \n", 333 | " df_diff = one_step_recover(df_diff,d)\n", 334 | " \n", 335 | " recover = np.exp(df_diff)\n", 336 | " predict_ts.plot(color='red')\n", 337 | " recover[:-14].plot(color='blue')\n", 338 | " recover[-14:].plot(color='red')\n", 339 | " plt.show()\n", 340 | " #print(recover)\n", 341 | "# re_result = predict_diff_recover(predict_ts, d=[7])\n", 342 | "# result = np.exp(re_result)\n", 343 | "\n", 344 | "\n", 345 | "# df.plot(color='blue')\n", 346 | "# result.plot(color='red')\n", 347 | "# # rr = result_arma.predict('2016-11-1', '2016-11-14', dynamic=True)\n", 348 | "# # rr.plot(color='green')\n", 349 | "# plt.show()\n", 350 | "# f = result_arma.predict('2016-11-1', '2016-11-14', dynamic=True)\n", 351 | "# f = result_arma.predict()\n", 352 | "# print(f)\n", 353 | "# print(result_arma.forecast(10))" 354 | ] 355 | } 356 | ], 357 | "metadata": { 358 | "kernelspec": { 359 | "display_name": "Python 3", 360 | "language": "python", 361 | "name": "python3" 362 | }, 363 | "language_info": { 364 | "codemirror_mode": { 365 | "name": "ipython", 366 | "version": 3 367 | }, 368 | "file_extension": ".py", 369 | "mimetype": "text/x-python", 370 | "name": "python", 371 | "nbconvert_exporter": "python", 372 | "pygments_lexer": "ipython3", 373 | "version": "3.5.1" 374 | } 375 | }, 376 | "nbformat": 4, 377 | "nbformat_minor": 0 378 | } 379 | -------------------------------------------------------------------------------- /notebook/als_data.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": true 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "__author__ = 'Roger'\n", 12 | "\n", 13 | "import numpy as np\n", 14 | "import matplotlib.pylab as plt\n", 15 | "%matplotlib inline\n", 16 | "\n", 17 | "## draw mean and median picture to analysis" 18 | ] 19 | }, 20 | { 21 | "cell_type": "code", 22 | "execution_count": null, 23 | "metadata": { 24 | "collapsed": false 25 | }, 26 | "outputs": [], 27 | "source": [ 28 | "res = np.loadtxt('../data/all_mon_week3_mean_med_var_std.csv', delimiter=',')\n", 29 | "res = res[:,1:]\n", 30 | "\n", 31 | "# print mean\n", 32 | "for i in range(2000):\n", 33 | " print(res[i])\n", 34 | " fig = plt.figure()\n", 35 | " ax1 = fig.add_subplot(4,1,1)\n", 36 | " ax2 = fig.add_subplot(4,1,2)\n", 37 | " ax3 = fig.add_subplot(4,1,3)\n", 38 | " ax4 = fig.add_subplot(4,1,4)\n", 39 | " x = range(3)\n", 40 | " ax1.set_yticks(x)\n", 41 | " ax2.set_yticks(x)\n", 42 | " ax3.set_yticks(x)\n", 43 | " ax4.set_yticks(x)\n", 44 | " ax1.set_yticklabels(['3week', '2week', '1week'])\n", 45 | " ax2.set_yticklabels(['3week', '2week', '1week'])\n", 46 | " ax3.set_yticklabels(['3week', '2week', '1week'])\n", 47 | " ax4.set_yticklabels(['3week', '2week', '1week'])\n", 48 | "\n", 49 | " ax1.barh(x, res[i,0:3])\n", 50 | " ax2.barh(x, res[i,3:6])\n", 51 | " ax3.barh(x, res[i,6:9])\n", 52 | " ax4.barh(x, res[i,9:12])\n", 53 | " \n", 54 | " ax1.set_title('mean')\n", 55 | " ax2.set_title('median')\n", 56 | " ax3.set_title('var')\n", 57 | " ax4.set_title('std')\n", 58 | " \n", 59 | " plt.savefig('/home/roger/Documents/ijcai_tianchi/als/flg1/{0}.jpg'.format(i))" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": null, 65 | "metadata": { 66 | "collapsed": false 67 | }, 68 | "outputs": [], 69 | "source": [ 70 | "# print mean\n", 71 | "for i in range(3):\n", 72 | " print(res[i])\n", 73 | " fig, ax = plt.subplots()\n", 74 | " x = range(12)\n", 75 | " ax.set_yticks(x)\n", 76 | " ax.set_yticklabels(['a_mean','m_mean','w_mean','a_median','m_median','w_median',\n", 77 | " 'a_var','m_var','w_var','a_std','m_std','w_std'])\n", 78 | " ax.barh(x,res[i])\n", 79 | " \n", 80 | " plt.show()" 81 | ] 82 | }, 83 | { 84 | "cell_type": "code", 85 | "execution_count": null, 86 | "metadata": { 87 | "collapsed": false 88 | }, 89 | "outputs": [], 90 | "source": [ 91 | "# simple test and study for draw picture\n", 92 | "plt.rcdefaults()\n", 93 | "fig, ax = plt.subplots()\n", 94 | "\n", 95 | "people = ('Tom', 'Dick', 'Harry', 'Slim', 'Jim')\n", 96 | "y_pos = np.arange(len(people))\n", 97 | "performance = 3 + 10 * np.random.rand(len(people))\n", 98 | "error = np.random.rand(len(people))\n", 99 | "\n", 100 | "ax.barh(y_pos, performance, xerr=error, align='center',\n", 101 | " color='green', ecolor='black')\n", 102 | "ax.set_yticks(y_pos)\n", 103 | "ax.set_yticklabels(people)\n", 104 | "ax.invert_yaxis() # labels read top-to-bottom\n", 105 | "ax.set_xlabel('Performance')\n", 106 | "ax.set_title('How fast do you want to go today?')\n", 107 | "\n", 108 | "plt.show()" 109 | ] 110 | } 111 | ], 112 | "metadata": { 113 | "kernelspec": { 114 | "display_name": "Python 3", 115 | "language": "python", 116 | "name": "python3" 117 | }, 118 | "language_info": { 119 | "codemirror_mode": { 120 | "name": "ipython", 121 | "version": 3 122 | }, 123 | "file_extension": ".py", 124 | "mimetype": "text/x-python", 125 | "name": "python", 126 | "nbconvert_exporter": "python", 127 | "pygments_lexer": "ipython3", 128 | "version": "3.5.1" 129 | } 130 | }, 131 | "nbformat": 4, 132 | "nbformat_minor": 0 133 | } 134 | -------------------------------------------------------------------------------- /notebook/show.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": { 7 | "collapsed": false 8 | }, 9 | "outputs": [], 10 | "source": [ 11 | "__author__ = 'Roger'\n", 12 | "\n", 13 | "import numpy as np\n", 14 | "import pandas as pd\n", 15 | "import matplotlib.pyplot as plt\n", 16 | "%matplotlib inline\n", 17 | "\n", 18 | "## analysis the image for data\n", 19 | "## analysis\n", 20 | "shop = np.loadtxt('../data/shopid_day_num.txt', delimiter=',')\n", 21 | "result = np.loadtxt('../results/testroger.csv',delimiter=',')\n", 22 | "predict1 = np.loadtxt('../results/testroger.csv', delimiter=',')" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": null, 28 | "metadata": { 29 | "collapsed": false 30 | }, 31 | "outputs": [], 32 | "source": [ 33 | "## plot 21days and result\n", 34 | "\n", 35 | "#define the month length\n", 36 | "month_len = 15\n", 37 | "# define the day length\n", 38 | "day_len = month_len * 4\n", 39 | "\n", 40 | "# count the weeks mean and month mean\n", 41 | "shop_21 = shop[:,-7 * day_len:]\n", 42 | "predict_14 = predict1[:,1:]\n", 43 | "week_mean = np.zeros([2000,day_len + 2])\n", 44 | "month_mean = np.zeros([2000,month_len])\n", 45 | "# print(predict)\n", 46 | "for i in range(day_len):\n", 47 | " week_mean[:,i] = np.mean(shop_21[:,7*i: 7 * (i+1)], axis=1)\n", 48 | "\n", 49 | "for i in range(month_len):\n", 50 | " month_mean[:,i] = np.mean(shop_21[:, 28 * i: 28 * (i + 1)], axis=1)\n", 51 | " \n", 52 | "week_mean[:,day_len] = np.mean(predict_14[:,0:7],axis=1)\n", 53 | "week_mean[:,day_len + 1] = np.mean(predict_14[:,7:14],axis=1)\n", 54 | "# print(avg_mean)\n", 55 | "x = 0\n", 56 | "# output the image with specific shops and analysis the results\n", 57 | "for i in [809]:\n", 58 | "# i = i - 1\n", 59 | " x += 1\n", 60 | "# print(avg_mean[i])\n", 61 | " y = range(0,7 * day_len)\n", 62 | " plt.title(i + 1)\n", 63 | " plt.plot(y, shop_21[i], color='blue')\n", 64 | " y = range(day_len * 7, (day_len + 2) * 7)\n", 65 | "# print(y.__len__(), predict_14[i].shape)\n", 66 | " plt.plot(y, predict_14[i], color='red')\n", 67 | " y = range((day_len + 2) * 7)\n", 68 | " for j in range(day_len):\n", 69 | " plt.plot(y[7 * j: 7 * (j + 1)],np.tile(week_mean[i,j],7), color = 'green')\n", 70 | " for j in range(month_len):\n", 71 | " plt.plot(y[28 * j: 28 * (j + 1)],np.tile(month_mean[i,j],28), color = 'black')\n", 72 | "# plt.show()\n", 73 | "# plt.savefig('/home/roger/Documents/ijcai_tianchi/als/all/{0}'.format(x),dpi=300)\n", 74 | "# plt.close()\n", 75 | " plt.show()" 76 | ] 77 | }, 78 | { 79 | "cell_type": "code", 80 | "execution_count": null, 81 | "metadata": { 82 | "collapsed": false 83 | }, 84 | "outputs": [], 85 | "source": [ 86 | "# print the week tend and analysis\n", 87 | "weekbegin = 3\n", 88 | "week_mean = np.zeros([2000, 43])\n", 89 | "idxw = 0 \n", 90 | "\n", 91 | "for i in range(weekbegin,304,7): \n", 92 | " week_mean[:, idxw] = np.mean(shop[:,i:i+7], axis=1) \n", 93 | " for j in range(2000): \n", 94 | " if week_mean[j, idxw] == 0: \n", 95 | " week_mean[j, idxw] = 1 \n", 96 | " idxw += 1\n", 97 | "week_tend = np.zeros([2000,43]) \n", 98 | "\n", 99 | "for i in range(1, week_mean.shape[1]): \n", 100 | " week_tend[:, i - 1] = week_mean[:, i - 1] / week_mean[:, i]\n", 101 | "week_tend[:,-1] = week_mean[:,-1] / np.mean(result[:,1:8]) \n", 102 | "\n", 103 | "for i in range(20): \n", 104 | " print(week_tend[i,:])\n", 105 | " plt.title(i+1)\n", 106 | " plt.plot(range(43), week_tend[i,:], color= 'red') \n", 107 | " for j in range(43): \n", 108 | " if j % 4 != 0:\n", 109 | " plt.plot([j,j],[0, np.max(week_tend[i])], color='blue')\n", 110 | "# else:\n", 111 | "# plt.plot([j,j], [0, np.max(week_tend[i])], color='red')\n", 112 | " plt.plot(range(43), [1] * 43, color= 'green')\n", 113 | "# plt.savefig('/home/roger/Documents/ijcai_tianchi/als/testweek/{0}'.format(i),dpi=300)\n", 114 | " plt.show()" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": null, 120 | "metadata": { 121 | "collapsed": false 122 | }, 123 | "outputs": [], 124 | "source": [ 125 | "# plot the rate about last two weeks and first two weeks\n", 126 | "test = np.loadtxt('../als/week/last_first_rate.csv', delimiter=',')\n", 127 | "\n", 128 | "for i in range(200):\n", 129 | " plt.plot(range(9), test[i], color='blue')\n", 130 | " plt.show()" 131 | ] 132 | } 133 | ], 134 | "metadata": { 135 | "kernelspec": { 136 | "display_name": "Python 3", 137 | "language": "python", 138 | "name": "python3" 139 | }, 140 | "language_info": { 141 | "codemirror_mode": { 142 | "name": "ipython", 143 | "version": 3 144 | }, 145 | "file_extension": ".py", 146 | "mimetype": "text/x-python", 147 | "name": "python", 148 | "nbconvert_exporter": "python", 149 | "pygments_lexer": "ipython3", 150 | "version": "3.5.1" 151 | } 152 | }, 153 | "nbformat": 4, 154 | "nbformat_minor": 0 155 | } 156 | -------------------------------------------------------------------------------- /pictures/cate_shop_number/cate_1.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/pictures/cate_shop_number/cate_1.csv -------------------------------------------------------------------------------- /pictures/cate_shop_number/cate_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/pictures/cate_shop_number/cate_1.png -------------------------------------------------------------------------------- /pictures/cate_shop_number/cate_2.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/pictures/cate_shop_number/cate_2.csv -------------------------------------------------------------------------------- /pictures/cate_shop_number/cate_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/pictures/cate_shop_number/cate_2.png -------------------------------------------------------------------------------- /pictures/cate_shop_number/cate_3.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/pictures/cate_shop_number/cate_3.csv -------------------------------------------------------------------------------- /pictures/cate_shop_number/cate_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/pictures/cate_shop_number/cate_3.png -------------------------------------------------------------------------------- /pictures/city_shop_number/0-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/pictures/city_shop_number/0-50.png -------------------------------------------------------------------------------- /pictures/city_shop_number/101-121.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/pictures/city_shop_number/101-121.png -------------------------------------------------------------------------------- /pictures/city_shop_number/51-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/pictures/city_shop_number/51-100.png -------------------------------------------------------------------------------- /pictures/city_shop_number/all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/pictures/city_shop_number/all.png -------------------------------------------------------------------------------- /pictures/city_shop_number/city_shop_number.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RogerMonkey/IJCAI_CUP_2017/46b5fb3baf997070a1ee4d5531b6d03dda481426/pictures/city_shop_number/city_shop_number.csv -------------------------------------------------------------------------------- /run.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import sys 3 | from main.data_processing import run as dp_run 4 | from main.model import run as model_run 5 | from main.rule import run as rule_run 6 | from main.fuse import run as fuse_run 7 | 8 | def run(): 9 | ''' 10 | 数据预处理 11 | :return: 12 | ''' 13 | dp_run() 14 | 15 | ''' 16 | 跑模型 17 | ''' 18 | model_run() 19 | 20 | ''' 21 | 模型融合 22 | ''' 23 | fuse_run() 24 | 25 | ''' 26 | 跑规则 27 | ''' 28 | rule_run() 29 | --------------------------------------------------------------------------------