{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "c6458055", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
night_call_dura_ratel3m_night_call_dura_ratel6m_night_call_dura_ratenight_call_cnt_ratel3m_night_call_cnt_ratel6m_night_call_cnt_ratecalled_cnt_ratel3m_called_cnt_ratel6m_called_cnt_ratecontact_ratio...rcn_chnl_idrcn_chnl_typrcn_modeuser_star_valstar_evalu_tmis_fam_v_ntwis_camp_useris_camp_area_userrow_numlabel
01.27260.50825.51383.12502.12774.651287.500088.297984.30231...3050734.0198.0202110000298330
18.43153.69972.04366.97672.03051.329876.744272.081267.81913...GZ_GZPY0612038NaN4.091.0202207000181210
25.01054.72523.54567.69237.36845.452649.038555.526356.48857...218568NaN4.0NaN-311083720
31.49250.60832.83863.84622.22225.660419.230846.666752.83020...2.25E+18NaN4.0133.0202112110327800
40.74240.61460.91350.64720.48540.378437.540538.470940.648615...BASS1_ST999999.0NaN-300035090
..................................................................
391380.65171.45602.20932.55103.05054.377944.642947.283149.907820...112000259399.0311.020220200031930
391390.32080.28050.53180.72990.73170.990127.737230.487830.58319...2703100110024.0203.0202110000467170
391401.39454.39363.66631.85192.12772.447668.518564.775463.46155...NX.01.06.03.10021044.0119.0202107000463790
391411.31340.89970.85860.32260.33330.704264.193562.500063.883314...HB.TS.13.01.G1NaN4.0163.0202111000126700
391423.25975.89135.77817.14294.44446.355943.877637.777835.59328...10191125210399.0250.0202111100435700
\n", "

39143 rows × 85 columns

\n", "
" ], "text/plain": [ " night_call_dura_rate l3m_night_call_dura_rate \\\n", "0 1.2726 0.5082 \n", "1 8.4315 3.6997 \n", "2 5.0105 4.7252 \n", "3 1.4925 0.6083 \n", "4 0.7424 0.6146 \n", "... ... ... \n", "39138 0.6517 1.4560 \n", "39139 0.3208 0.2805 \n", "39140 1.3945 4.3936 \n", "39141 1.3134 0.8997 \n", "39142 3.2597 5.8913 \n", "\n", " l6m_night_call_dura_rate night_call_cnt_rate l3m_night_call_cnt_rate \\\n", "0 5.5138 3.1250 2.1277 \n", "1 2.0436 6.9767 2.0305 \n", "2 3.5456 7.6923 7.3684 \n", "3 2.8386 3.8462 2.2222 \n", "4 0.9135 0.6472 0.4854 \n", "... ... ... ... \n", "39138 2.2093 2.5510 3.0505 \n", "39139 0.5318 0.7299 0.7317 \n", "39140 3.6663 1.8519 2.1277 \n", "39141 0.8586 0.3226 0.3333 \n", "39142 5.7781 7.1429 4.4444 \n", "\n", " l6m_night_call_cnt_rate called_cnt_rate l3m_called_cnt_rate \\\n", "0 4.6512 87.5000 88.2979 \n", "1 1.3298 76.7442 72.0812 \n", "2 5.4526 49.0385 55.5263 \n", "3 5.6604 19.2308 46.6667 \n", "4 0.3784 37.5405 38.4709 \n", "... ... ... ... \n", "39138 4.3779 44.6429 47.2831 \n", "39139 0.9901 27.7372 30.4878 \n", "39140 2.4476 68.5185 64.7754 \n", "39141 0.7042 64.1935 62.5000 \n", "39142 6.3559 43.8776 37.7778 \n", "\n", " l6m_called_cnt_rate contact_ratio ... rcn_chnl_id rcn_chnl_typ \\\n", "0 84.3023 1 ... 30507 3 \n", "1 67.8191 3 ... GZ_GZPY0612038 NaN \n", "2 56.4885 7 ... 218568 NaN \n", "3 52.8302 0 ... 2.25E+18 NaN \n", "4 40.6486 15 ... BASS1_ST 9999 \n", "... ... ... ... ... ... \n", "39138 49.9078 20 ... 112000259 3 \n", "39139 30.5831 9 ... 27031001 1002 \n", "39140 63.4615 5 ... NX.01.06.03.100 2104 \n", "39141 63.8833 14 ... HB.TS.13.01.G1 NaN \n", "39142 35.5932 8 ... 10191125 2103 \n", "\n", " rcn_mode user_star_val star_evalu_tm is_fam_v_ntw is_camp_user \\\n", "0 4.0 198.0 202110 0 0 \n", "1 4.0 91.0 202207 0 0 \n", "2 4.0 NaN -3 1 1 \n", "3 4.0 133.0 202112 1 1 \n", "4 99.0 NaN -3 0 0 \n", "... ... ... ... ... ... \n", "39138 99.0 311.0 202202 0 0 \n", "39139 4.0 203.0 202110 0 0 \n", "39140 4.0 119.0 202107 0 0 \n", "39141 4.0 163.0 202111 0 0 \n", "39142 99.0 250.0 202111 1 0 \n", "\n", " is_camp_area_user row_num label \n", "0 0 29833 0 \n", "1 0 18121 0 \n", "2 0 8372 0 \n", "3 0 32780 0 \n", "4 0 3509 0 \n", "... ... ... ... \n", "39138 0 3193 0 \n", "39139 0 46717 0 \n", "39140 0 46379 0 \n", "39141 0 12670 0 \n", "39142 0 43570 0 \n", "\n", "[39143 rows x 85 columns]" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import numpy as np\n", "import pandas as pd\n", "import os\n", "import warnings\n", "warnings.filterwarnings('ignore')\n", "\n", "data1=pd.read_csv('csvdata/train_a_label.csv', encoding='gbk')\n", "data2=pd.read_csv('csvdata/train_b.csv')\n", "data3=pd.read_csv('csvdata/test_a.csv', encoding='gbk')\n", "data4=pd.read_csv('csvdata/test_b.csv')\n", "data1" ] }, { "cell_type": "code", "execution_count": 2, "id": "deadly-torture", "metadata": { "scrolled": true }, "outputs": [], "source": [ "#补0\n", "data1=data1.fillna(-1)\n", "data2=data2.fillna(-1)\n", "data3=data3.fillna(-1)\n", "data4=data4.fillna(-1)\n", "\n", "data1=data1[['row_num'] + data1.drop(labels=['row_num'],axis=1).columns.tolist() ] \n", "data2=data2[['row_num'] + data2.drop(labels=['row_num'],axis=1).columns.tolist() ] \n", "data3=data3[['row_num'] + data3.drop(labels=['row_num'],axis=1).columns.tolist() ] \n", "data4=data4[['row_num'] + data4.drop(labels=['row_num'],axis=1).columns.tolist() ] \n" ] }, { "cell_type": "code", "execution_count": 3, "id": "narrow-feedback", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
row_numlabeluser_star_valnight_call_dura_ratenight_call_cnt_rateagecust_staropp_belo_cntrcn_model6m_night_call_cnt_ratenight_percent_sixbrand_id
0298330198.01.27263.125024.054.04.65125.112
118121091.08.43156.976716.034.01.329817.642
283720-1.05.01057.69234-1.034.05.452612.702
3327800133.01.49253.846227.034.05.66042.831
435090-1.00.74240.64726-1.0399.00.37846.181
.......................................
3913831930311.00.65172.551054.0399.04.377911.522
39139467170203.00.32080.729935.044.00.990111.191
39140463790119.01.39451.851935.044.02.447630.931
39141126700163.01.31340.322665.024.00.704236.481
39142435700250.03.25977.142945.0599.06.355924.181
\n", "

39143 rows × 12 columns

\n", "
" ], "text/plain": [ " row_num label user_star_val night_call_dura_rate \\\n", "0 29833 0 198.0 1.2726 \n", "1 18121 0 91.0 8.4315 \n", "2 8372 0 -1.0 5.0105 \n", "3 32780 0 133.0 1.4925 \n", "4 3509 0 -1.0 0.7424 \n", "... ... ... ... ... \n", "39138 3193 0 311.0 0.6517 \n", "39139 46717 0 203.0 0.3208 \n", "39140 46379 0 119.0 1.3945 \n", "39141 12670 0 163.0 1.3134 \n", "39142 43570 0 250.0 3.2597 \n", "\n", " night_call_cnt_rate age cust_star opp_belo_cnt rcn_mode \\\n", "0 3.1250 2 4.0 5 4.0 \n", "1 6.9767 1 6.0 3 4.0 \n", "2 7.6923 4 -1.0 3 4.0 \n", "3 3.8462 2 7.0 3 4.0 \n", "4 0.6472 6 -1.0 3 99.0 \n", "... ... ... ... ... ... \n", "39138 2.5510 5 4.0 3 99.0 \n", "39139 0.7299 3 5.0 4 4.0 \n", "39140 1.8519 3 5.0 4 4.0 \n", "39141 0.3226 6 5.0 2 4.0 \n", "39142 7.1429 4 5.0 5 99.0 \n", "\n", " l6m_night_call_cnt_rate night_percent_six brand_id \n", "0 4.6512 5.11 2 \n", "1 1.3298 17.64 2 \n", "2 5.4526 12.70 2 \n", "3 5.6604 2.83 1 \n", "4 0.3784 6.18 1 \n", "... ... ... ... \n", "39138 4.3779 11.52 2 \n", "39139 0.9901 11.19 1 \n", "39140 2.4476 30.93 1 \n", "39141 0.7042 36.48 1 \n", "39142 6.3559 24.18 1 \n", "\n", "[39143 rows x 12 columns]" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#data1=data1.drop(labels=['pretty_num_typ','rcn_chnl_id','rcn_chnl_typ','star_evalu_tm','star_evalu_tm', 'top5_call_dura_rate', 'l6m_once_numbers_rate', 'once_numbers_rate', 'l6m_contact_ratio', 'l3m_top10_call_cnt_rate', 'l3m_top5_call_cnt_rate', 'l6m_top10_call_dura_rate', 'l3m_is_same_imei_msisdn_cnt_gtr2', 'top10_call_dura_rate', 'ocpn_code', 'top5_call_cnt_rate', 'top10_opp_belo_cnt', 'educat_degree_code', 'l6m_top10_opp_belo_cnt', 'l3m_once_numbers_rate', 'l3m_top10_opp_belo_cnt', 'l3m_contact_ratio', 'l6m_top5_call_dura_rate', 'pre3m_top10_diff_num', 'age_lvl', 'top10_diff_num', 'same_idcard_msisdn_cnt', 'pre3m_top5_diff_num', 'l3m_id_cnt', 'l3m_top10_call_dura_rate', 'pre2m_top10_diff_num', 'top10_call_cnt_rate', 'contact_ratio', 'top5_opp_belo_cnt', 'is_pretty_num', 'l3m_top5_opp_belo_cnt', 'pre2m_top5_diff_num', 'l1m_is_same_imei_msisdn_cnt_gtr2', 'sex', 'same_imei_msisdn_hr_cnt', 'l6m_top5_opp_belo_cnt', 'is_fam_v_ntw', 'top5_diff_num', 'is_camp_user', 'idty_typ', 'zuche_six_total_dur', 'vip_lvl'],axis=1)\n", "data1=data1[['row_num','label','user_star_val','night_call_dura_rate', 'night_call_cnt_rate', 'age', 'cust_star', 'opp_belo_cnt', 'rcn_mode', 'l6m_night_call_cnt_rate', 'night_percent_six', 'brand_id']]\n", "#, 'star_evalu_tm', 'l3m_called_cnt_rate', 'night_percent_current', 'l6m_called_cnt_rate', 'l3m_night_call_dura_rate'\n", "data1['age']=data1['age']//10\n", "data1.to_csv(path_or_buf='csvclear/train_a_label.csv', index=None) \n", "\n", "\n", "#data3=data3.drop(labels=['pretty_num_typ','rcn_chnl_id','rcn_chnl_typ','star_evalu_tm', 'top5_call_dura_rate', 'l6m_once_numbers_rate', 'once_numbers_rate', 'l6m_contact_ratio', 'l3m_top10_call_cnt_rate', 'l3m_top5_call_cnt_rate', 'l6m_top10_call_dura_rate', 'l3m_is_same_imei_msisdn_cnt_gtr2', 'top10_call_dura_rate', 'ocpn_code', 'top5_call_cnt_rate', 'top10_opp_belo_cnt', 'educat_degree_code', 'l6m_top10_opp_belo_cnt', 'l3m_once_numbers_rate', 'l3m_top10_opp_belo_cnt', 'l3m_contact_ratio', 'l6m_top5_call_dura_rate', 'pre3m_top10_diff_num', 'age_lvl', 'top10_diff_num', 'same_idcard_msisdn_cnt', 'pre3m_top5_diff_num', 'l3m_id_cnt', 'l3m_top10_call_dura_rate', 'pre2m_top10_diff_num', 'top10_call_cnt_rate', 'contact_ratio', 'top5_opp_belo_cnt', 'is_pretty_num', 'l3m_top5_opp_belo_cnt', 'pre2m_top5_diff_num', 'l1m_is_same_imei_msisdn_cnt_gtr2', 'sex', 'same_imei_msisdn_hr_cnt', 'l6m_top5_opp_belo_cnt', 'is_fam_v_ntw', 'top5_diff_num', 'is_camp_user', 'idty_typ', 'zuche_six_total_dur', 'vip_lvl'],axis=1)\n", "data3=data3[['row_num','user_star_val', 'star_evalu_tm','night_call_dura_rate', 'night_call_cnt_rate', 'age', 'cust_star', 'opp_belo_cnt', 'rcn_mode', 'l6m_night_call_cnt_rate', 'night_percent_six', 'brand_id']]\n", "#data3=data3[['row_num'] + data3.drop(labels=['row_num'],axis=1).columns.tolist() ] \n", "data3['age']=data3['age']//10\n", "\n", "data3.to_csv(path_or_buf='csvclear/test_a.csv', index=None) \n", "data1" ] }, { "cell_type": "code", "execution_count": 4, "id": "supposed-composer", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
row_numlabeluser_star_valnight_call_dura_ratenight_call_cnt_rateagecust_staropp_belo_cntrcn_model6m_night_call_cnt_ratenight_percent_sixbrand_id
0298330198.01.27263.125024.054.04.65125.112
118121091.08.43156.976716.034.01.329817.642
283720-1.05.01057.69234-1.034.05.452612.702
3327800133.01.49253.846227.034.05.66042.831
435090-1.00.74240.64726-1.0399.00.37846.181
.......................................
3913831930311.00.65172.551054.0399.04.377911.522
39139467170203.00.32080.729935.044.00.990111.191
39140463790119.01.39451.851935.044.02.447630.931
39141126700163.01.31340.322665.024.00.704236.481
39142435700250.03.25977.142945.0599.06.355924.181
\n", "

39143 rows × 12 columns

\n", "
" ], "text/plain": [ " row_num label user_star_val night_call_dura_rate \\\n", "0 29833 0 198.0 1.2726 \n", "1 18121 0 91.0 8.4315 \n", "2 8372 0 -1.0 5.0105 \n", "3 32780 0 133.0 1.4925 \n", "4 3509 0 -1.0 0.7424 \n", "... ... ... ... ... \n", "39138 3193 0 311.0 0.6517 \n", "39139 46717 0 203.0 0.3208 \n", "39140 46379 0 119.0 1.3945 \n", "39141 12670 0 163.0 1.3134 \n", "39142 43570 0 250.0 3.2597 \n", "\n", " night_call_cnt_rate age cust_star opp_belo_cnt rcn_mode \\\n", "0 3.1250 2 4.0 5 4.0 \n", "1 6.9767 1 6.0 3 4.0 \n", "2 7.6923 4 -1.0 3 4.0 \n", "3 3.8462 2 7.0 3 4.0 \n", "4 0.6472 6 -1.0 3 99.0 \n", "... ... ... ... ... ... \n", "39138 2.5510 5 4.0 3 99.0 \n", "39139 0.7299 3 5.0 4 4.0 \n", "39140 1.8519 3 5.0 4 4.0 \n", "39141 0.3226 6 5.0 2 4.0 \n", "39142 7.1429 4 5.0 5 99.0 \n", "\n", " l6m_night_call_cnt_rate night_percent_six brand_id \n", "0 4.6512 5.11 2 \n", "1 1.3298 17.64 2 \n", "2 5.4526 12.70 2 \n", "3 5.6604 2.83 1 \n", "4 0.3784 6.18 1 \n", "... ... ... ... \n", "39138 4.3779 11.52 2 \n", "39139 0.9901 11.19 1 \n", "39140 2.4476 30.93 1 \n", "39141 0.7042 36.48 1 \n", "39142 6.3559 24.18 1 \n", "\n", "[39143 rows x 12 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data1" ] }, { "cell_type": "code", "execution_count": 5, "id": "handy-custom", "metadata": {}, "outputs": [], "source": [ "def fun_flux(x):\n", " x=x/1024\n", " if x <= 100:\n", " return 1\n", " if x <= 500:\n", " return 2\n", " if x <= 1024:\n", " return 3\n", " if x <= 2048:\n", " return 4\n", " else:\n", " return 5" ] }, { "cell_type": "code", "execution_count": 6, "id": "linear-divorce", "metadata": {}, "outputs": [], "source": [ "df2 = data2[['row_num','innet_dura','basic_package_prc','package_flux','in_set_voice_minu','pri_package_lvl','cur_eff_sale_cmpn_cnt','mon_stp_cnt','gsm_user_lvl','is_join_busi_typ_contr','user_status']]\n", "#,'become_group_user_memb_tm','term_os','mage_status','user_area_belo','group_indus_typ_code'\n", "#df2 = data2.drop(labels=['belo_camp_id','become_group_user_memb_tm', 'belo_group_cust_id', 'term_brand', 'term_mdl', 'charge_package_unify_code', 'befo_pri_package_code', 'basic_package_id', 'basic_package_eff_date', 'package_stp_date','is_exempt_prest_open_inter_roam ','is_hnet_bind','camp_lvl','cm_nadd_mkcase_cnt','pretty_num_typ_code','term_typ','is_mkcase_user','is_warnt_boot','is_fuse_brd','year_nadd_id','is_group_user','exit_typ','is_main_card_user','is_cm_ord_nolimit_and_eff','is_give_card','this_is_replace_package','is_join_term_contr','memb_typ','is_use_backup_sim_svc','owe_stp_days','become_group_user_memb_tm','mon_stp_cnt','gsm_user_lvl','is_join_busi_typ_contr','user_status','term_os','mage_status','user_area_belo','group_indus_typ_code','nation','ord_4g_package_user_id','stp_dura','last_one_stp_tm','is_ord_nolimit','brd_bdwth','msisdn_owe_stp_freq','innet_dura_lvl_code','is_urgent_boot','is_gsm_user','is_ass_card','in_set_sms_cnt','package_typ','ass_card_cnt','gsm_user_src','unique_flag','is_indv_cust_posb','is_fnet_bind','is_group_v_ntw_bind','is_bind_pay','cancl_date'],axis=1)\n", "#df2['pretty_num_typ_name'] = df2['pretty_num_typ_name'].str.replace('非靓号', '0')\n", "#if df2['pretty_num_typ_name'].str != '0':\n", "# df2['pretty_num_typ_name']='1'\n", " \n", "#df2['pretty_num_typ_name']=df2['pretty_num_typ_name'].astype(int) \n", "#if df2['stp_typ'].str != '9999':\n", "# df2['stp_typ']='0' \n", "#df2['stp_typ']=df2['stp_typ'].astype(int) \n", "#df2['cm_nadd_mkcase_cnt'] = df2['cm_nadd_mkcase_cnt'].str.replace(r'\\\\N','-1')\n", "#df2['cm_nadd_mkcase_cnt']=df2['cm_nadd_mkcase_cnt'].astype(int)\n", "df2['cur_eff_sale_cmpn_cnt'] = df2['cur_eff_sale_cmpn_cnt'].str.replace(r'\\\\N','-1')\n", "df2['cur_eff_sale_cmpn_cnt']=df2['cur_eff_sale_cmpn_cnt'].astype(int) \n", "df2['basic_package_prc'] = df2['basic_package_prc'].str.replace(r'\\\\N','-1')\n", "df2['basic_package_prc']=df2['basic_package_prc'].astype(int)\n", "\n", "#df2['user_status']=df2['user_status']-1000\n", "#df2['package_flux'] = df2['package_flux'].apply(lambda x: fun_flux(x))\n", "\n", "df2.to_csv(path_or_buf='csvclear/train_b.csv', index=None) \n" ] }, { "cell_type": "code", "execution_count": 7, "id": "detected-teddy", "metadata": {}, "outputs": [], "source": [ "df4 = data4[['row_num','innet_dura','basic_package_prc','package_flux','in_set_voice_minu','pri_package_lvl','cur_eff_sale_cmpn_cnt','mon_stp_cnt','gsm_user_lvl','is_join_busi_typ_contr','user_status']]\n", "\n", "#df4 = data4.drop(labels=['belo_camp_id','become_group_user_memb_tm', 'belo_group_cust_id', 'term_brand', 'term_mdl', 'charge_package_unify_code', 'befo_pri_package_code', 'basic_package_id', 'basic_package_eff_date', 'package_stp_date','is_exempt_prest_open_inter_roam ','is_hnet_bind','camp_lvl','cm_nadd_mkcase_cnt','pretty_num_typ_code','term_typ','is_mkcase_user','is_warnt_boot','is_fuse_brd','year_nadd_id','is_group_user','exit_typ','is_main_card_user','is_cm_ord_nolimit_and_eff','is_give_card','this_is_replace_package','is_join_term_contr','memb_typ','is_use_backup_sim_svc','owe_stp_days','become_group_user_memb_tm','mon_stp_cnt','gsm_user_lvl','is_join_busi_typ_contr','user_status','term_os','mage_status','user_area_belo','group_indus_typ_code','nation','ord_4g_package_user_id','stp_dura','last_one_stp_tm','is_ord_nolimit','brd_bdwth','msisdn_owe_stp_freq','innet_dura_lvl_code','is_urgent_boot','is_gsm_user','is_ass_card','in_set_sms_cnt','package_typ','ass_card_cnt','gsm_user_src','unique_flag','is_indv_cust_posb','is_fnet_bind','is_group_v_ntw_bind','is_bind_pay','cancl_date'],axis=1)\n", "#df4['pretty_num_typ_name'] = df4['pretty_num_typ_name'].str.replace('非靓号', '0')\n", "#if df4['pretty_num_typ_name'].str != '0':\n", "# df4['pretty_num_typ_name']='1'\n", " \n", "#df4['pretty_num_typ_name']=df4['pretty_num_typ_name'].astype(int) \n", "#if df4['stp_typ'].str != '9999':\n", "# df4['stp_typ']='0' \n", "#df4['stp_typ']=df2['stp_typ'].astype(int) \n", "#df4['cm_nadd_mkcase_cnt'] = df4['cm_nadd_mkcase_cnt'].str.replace(r'\\\\N','-1')\n", "#df4['cm_nadd_mkcase_cnt']=df4['cm_nadd_mkcase_cnt'].astype(int)\n", "df4['cur_eff_sale_cmpn_cnt'] = df4['cur_eff_sale_cmpn_cnt'].str.replace(r'\\\\N','-1')\n", "df4['cur_eff_sale_cmpn_cnt']=df4['cur_eff_sale_cmpn_cnt'].astype(int) \n", "df4['basic_package_prc'] = df4['basic_package_prc'].str.replace(r'\\\\N','-1')\n", "df4['basic_package_prc']=df4['basic_package_prc'].astype(int)\n", "\n", "#df4['user_status']=df4['user_status']-1000\n", "#df4['package_flux'] = df4['package_flux'].apply(lambda x: fun_flux(x))\n", "\n", "df4.to_csv(path_or_buf='csvclear/test_b.csv', index=None)\n" ] }, { "cell_type": "code", "execution_count": 8, "id": "chronic-cisco", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
row_numinnet_durabasic_package_prcpackage_fluxin_set_voice_minupri_package_lvlcur_eff_sale_cmpn_cntmon_stp_cntgsm_user_lvlis_join_busi_typ_contruser_status
052397-1000.0-10-1.009000
1522053996656013006.0117.001010
23726136128409602000.040-1.001010
33263425798204805000.0-111.001010
4397822150000.02007.011010
....................................
97819304690000.040-1.001010
97823871348128307205000.0116.001010
978341809215285120800.080-1.001010
9784216597810000.0206.001010
9785489292251810241000.0-101.001010
\n", "

9786 rows × 11 columns

\n", "
" ], "text/plain": [ " row_num innet_dura basic_package_prc package_flux in_set_voice_minu \\\n", "0 5239 7 -1 0 0 \n", "1 5220 53 99 66560 1300 \n", "2 37261 36 128 40960 200 \n", "3 32634 257 98 20480 500 \n", "4 39782 215 0 0 0 \n", "... ... ... ... ... ... \n", "9781 9304 69 0 0 0 \n", "9782 38713 48 128 30720 500 \n", "9783 41809 215 28 5120 80 \n", "9784 2165 97 8 100 0 \n", "9785 48929 225 18 1024 100 \n", "\n", " pri_package_lvl cur_eff_sale_cmpn_cnt mon_stp_cnt gsm_user_lvl \\\n", "0 0.0 -1 0 -1.0 \n", "1 6.0 1 1 7.0 \n", "2 0.0 4 0 -1.0 \n", "3 0.0 -1 1 1.0 \n", "4 0.0 20 0 7.0 \n", "... ... ... ... ... \n", "9781 0.0 4 0 -1.0 \n", "9782 0.0 1 1 6.0 \n", "9783 0.0 8 0 -1.0 \n", "9784 0.0 2 0 6.0 \n", "9785 0.0 -1 0 1.0 \n", "\n", " is_join_busi_typ_contr user_status \n", "0 0 9000 \n", "1 0 1010 \n", "2 0 1010 \n", "3 0 1010 \n", "4 1 1010 \n", "... ... ... \n", "9781 0 1010 \n", "9782 0 1010 \n", "9783 0 1010 \n", "9784 0 1010 \n", "9785 0 1010 \n", "\n", "[9786 rows x 11 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df4" ] }, { "cell_type": "code", "execution_count": 9, "id": "invalid-parameter", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "数据清洗完成\n" ] } ], "source": [ "print('数据清洗完成')" ] }, { "cell_type": "code", "execution_count": 10, "id": "timely-judges", "metadata": {}, "outputs": [ { "ename": "SyntaxError", "evalue": "Missing parentheses in call to 'print'. Did you mean print(cccc)? (, line 1)", "output_type": "error", "traceback": [ "\u001b[0;36m File \u001b[0;32m\"\"\u001b[0;36m, line \u001b[0;32m1\u001b[0m\n\u001b[0;31m print cccc\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m Missing parentheses in call to 'print'. Did you mean print(cccc)?\n" ] } ], "source": [ "print cccc" ] }, { "cell_type": "code", "execution_count": null, "id": "broadband-pitch", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 11, "id": "cordless-intelligence", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\r\n", " \"retcode\": 0,\r\n", " \"retmsg\": \"Fate Flow CLI has been initialized successfully.\"\r\n", "}\r\n", "\r\n" ] } ], "source": [ "!flow init --ip 10.43.159.182 --port 9380" ] }, { "cell_type": "code", "execution_count": 12, "id": "dffd4c06", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\r\n", " \"data\": {\r\n", " \"board_url\": \"http://board:8080/index.html#/dashboard?job_id=20230424161428388177448&role=local&party_id=0\",\r\n", " \"job_dsl_path\": \"/data/projects/fate/jobs/20230424161428388177448/job_dsl.json\",\r\n", " \"job_id\": \"20230424161428388177448\",\r\n", " \"job_runtime_conf_on_party_path\": \"/data/projects/fate/jobs/20230424161428388177448/local/job_runtime_on_party_conf.json\",\r\n", " \"job_runtime_conf_path\": \"/data/projects/fate/jobs/20230424161428388177448/job_runtime_conf.json\",\r\n", " \"logs_directory\": \"/data/projects/fate/logs/20230424161428388177448\",\r\n", " \"model_info\": {\r\n", " \"model_id\": \"local-0#model\",\r\n", " \"model_version\": \"20230424161428388177448\"\r\n", " },\r\n", " \"namespace\": \"experiment\",\r\n", " \"pipeline_dsl_path\": \"/data/projects/fate/jobs/20230424161428388177448/pipeline_dsl.json\",\r\n", " \"table_name\": \"train_a_label\",\r\n", " \"train_runtime_conf_path\": \"/data/projects/fate/jobs/20230424161428388177448/train_runtime_conf.json\"\r\n", " },\r\n", " \"jobId\": \"20230424161428388177448\",\r\n", " \"retcode\": 0,\r\n", " \"retmsg\": \"success\"\r\n", "}\r\n", "\r\n" ] } ], "source": [ "!flow data upload -c /Examples/csvclear/upload_conf.json --drop" ] }, { "cell_type": "code", "execution_count": 13, "id": "34470baf", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\r\n", " \"data\": {\r\n", " \"board_url\": \"http://board:8080/index.html#/dashboard?job_id=20230424161429367145449&role=local&party_id=0\",\r\n", " \"job_dsl_path\": \"/data/projects/fate/jobs/20230424161429367145449/job_dsl.json\",\r\n", " \"job_id\": \"20230424161429367145449\",\r\n", " \"job_runtime_conf_on_party_path\": \"/data/projects/fate/jobs/20230424161429367145449/local/job_runtime_on_party_conf.json\",\r\n", " \"job_runtime_conf_path\": \"/data/projects/fate/jobs/20230424161429367145449/job_runtime_conf.json\",\r\n", " \"logs_directory\": \"/data/projects/fate/logs/20230424161429367145449\",\r\n", " \"model_info\": {\r\n", " \"model_id\": \"local-0#model\",\r\n", " \"model_version\": \"20230424161429367145449\"\r\n", " },\r\n", " \"namespace\": \"experiment\",\r\n", " \"pipeline_dsl_path\": \"/data/projects/fate/jobs/20230424161429367145449/pipeline_dsl.json\",\r\n", " \"table_name\": \"train_b\",\r\n", " \"train_runtime_conf_path\": \"/data/projects/fate/jobs/20230424161429367145449/train_runtime_conf.json\"\r\n", " },\r\n", " \"jobId\": \"20230424161429367145449\",\r\n", " \"retcode\": 0,\r\n", " \"retmsg\": \"success\"\r\n", "}\r\n", "\r\n" ] } ], "source": [ "!flow data upload -c /Examples/csvclear/upload_conf_host.json --drop" ] }, { "cell_type": "code", "execution_count": 14, "id": "filled-princess", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\r\n", " \"data\": {\r\n", " \"count\": 39143,\r\n", " \"exist\": 1,\r\n", " \"namespace\": \"experiment\",\r\n", " \"partition\": 4,\r\n", " \"schema\": {\r\n", " \"header\": \"label,user_star_val,night_call_dura_rate,night_call_cnt_rate,age,cust_star,opp_belo_cnt,rcn_mode,l6m_night_call_cnt_rate,night_percent_six,brand_id\",\r\n", " \"sid\": \"row_num\"\r\n", " },\r\n", " \"table_name\": \"train_a_label\"\r\n", " },\r\n", " \"retcode\": 0,\r\n", " \"retmsg\": \"success\"\r\n", "}\r\n", "\r\n" ] } ], "source": [ "#查看表信息\n", "!flow table info -t train_a_label -n experiment\n", "#!flow table info -t train_a_label -n experiment" ] }, { "cell_type": "code", "execution_count": 15, "id": "mighty-health", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\r\n", " \"data\": {\r\n", " \"board_url\": \"http://board:8080/index.html#/dashboard?job_id=20230424161430596799450&role=local&party_id=0\",\r\n", " \"job_dsl_path\": \"/data/projects/fate/jobs/20230424161430596799450/job_dsl.json\",\r\n", " \"job_id\": \"20230424161430596799450\",\r\n", " \"job_runtime_conf_on_party_path\": \"/data/projects/fate/jobs/20230424161430596799450/local/job_runtime_on_party_conf.json\",\r\n", " \"job_runtime_conf_path\": \"/data/projects/fate/jobs/20230424161430596799450/job_runtime_conf.json\",\r\n", " \"logs_directory\": \"/data/projects/fate/logs/20230424161430596799450\",\r\n", " \"model_info\": {\r\n", " \"model_id\": \"local-0#model\",\r\n", " \"model_version\": \"20230424161430596799450\"\r\n", " },\r\n", " \"namespace\": \"experiment\",\r\n", " \"pipeline_dsl_path\": \"/data/projects/fate/jobs/20230424161430596799450/pipeline_dsl.json\",\r\n", " \"table_name\": \"test_a\",\r\n", " \"train_runtime_conf_path\": \"/data/projects/fate/jobs/20230424161430596799450/train_runtime_conf.json\"\r\n", " },\r\n", " \"jobId\": \"20230424161430596799450\",\r\n", " \"retcode\": 0,\r\n", " \"retmsg\": \"success\"\r\n", "}\r\n", "\r\n" ] } ], "source": [ "#上传预测数据\n", "!flow data upload -c /Examples/csvclear/upload_testa_conf.json --drop" ] }, { "cell_type": "code", "execution_count": 16, "id": "similar-teaching", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\r\n", " \"data\": {\r\n", " \"board_url\": \"http://board:8080/index.html#/dashboard?job_id=20230424161431222943451&role=local&party_id=0\",\r\n", " \"job_dsl_path\": \"/data/projects/fate/jobs/20230424161431222943451/job_dsl.json\",\r\n", " \"job_id\": \"20230424161431222943451\",\r\n", " \"job_runtime_conf_on_party_path\": \"/data/projects/fate/jobs/20230424161431222943451/local/job_runtime_on_party_conf.json\",\r\n", " \"job_runtime_conf_path\": \"/data/projects/fate/jobs/20230424161431222943451/job_runtime_conf.json\",\r\n", " \"logs_directory\": \"/data/projects/fate/logs/20230424161431222943451\",\r\n", " \"model_info\": {\r\n", " \"model_id\": \"local-0#model\",\r\n", " \"model_version\": \"20230424161431222943451\"\r\n", " },\r\n", " \"namespace\": \"experiment\",\r\n", " \"pipeline_dsl_path\": \"/data/projects/fate/jobs/20230424161431222943451/pipeline_dsl.json\",\r\n", " \"table_name\": \"test_b\",\r\n", " \"train_runtime_conf_path\": \"/data/projects/fate/jobs/20230424161431222943451/train_runtime_conf.json\"\r\n", " },\r\n", " \"jobId\": \"20230424161431222943451\",\r\n", " \"retcode\": 0,\r\n", " \"retmsg\": \"success\"\r\n", "}\r\n", "\r\n" ] } ], "source": [ "!flow data upload -c /Examples/csvclear/upload_testb_conf.json --drop" ] }, { "cell_type": "code", "execution_count": 17, "id": "yellow-luxury", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\r\n", " \"data\": {\r\n", " \"count\": 9786,\r\n", " \"exist\": 1,\r\n", " \"namespace\": \"experiment\",\r\n", " \"partition\": 4,\r\n", " \"schema\": {\r\n", " \"header\": \"user_star_val,star_evalu_tm,night_call_dura_rate,night_call_cnt_rate,age,cust_star,opp_belo_cnt,rcn_mode,l6m_night_call_cnt_rate,night_percent_six,brand_id\",\r\n", " \"sid\": \"row_num\"\r\n", " },\r\n", " \"table_name\": \"test_a\"\r\n", " },\r\n", " \"retcode\": 0,\r\n", " \"retmsg\": \"success\"\r\n", "}\r\n", "\r\n" ] } ], "source": [ "#查看表信息\n", "!flow table info -t test_a -n experiment\n", "#!flow table info -t train_a_label -n experiment" ] }, { "cell_type": "code", "execution_count": 18, "id": "artistic-drilling", "metadata": {}, "outputs": [], "source": [ "!" ] }, { "cell_type": "code", "execution_count": 29, "id": "hungry-eagle", "metadata": {}, "outputs": [], "source": [ "train_conf = {\n", " \"dsl_version\": 2,\n", " \"initiator\": {\n", " \"role\": \"guest\",\n", " \"party_id\": 9999\n", " },\n", " \"job_parameters\": {\n", " \"common\": {\n", " \"work_mode\": 0 \n", " }\n", "},\n", " \"role\": {\n", " \"host\": [10000],\n", " \"guest\": [9999]\n", " },\n", " \"component_parameters\": {\n", " \"common\": {\n", " \"hetero_secure_boost_0\": {\n", " \"task_type\": \"classification\",\n", " \"objective_param\": {\n", " \"objective\": \"cross_entropy\"\n", " },\n", " \"num_trees\": 1,\n", " \"validation_freqs\": 1,\n", " \"encrypt_param\": {\n", " \"method\": \"Paillier\"\n", " },\n", " \"tree_param\": {\n", " \"max_depth\": 8\n", " },\n", " \"use_missing\": True\n", " },\n", " \"evaluation_0\": {\n", " \"eval_type\": \"binary\"\n", " }\n", " },\n", " \"role\": {\n", " \"guest\": {\n", " \"0\": {\n", " \n", " \"data_transform_0\": {\n", " \"with_label\": True,\n", " \"label_name\": \"label\",\n", " \"label_type\": \"int\",\n", " \"output_format\": \"dense\"\n", " },\n", " \"reader_0\": {\n", " \"table\": {\n", " \"name\": \"train_a_label\",\n", " \"namespace\": \"experiment\"\n", " }\n", " }\n", " }\n", " },\n", " \"host\": {\n", " \"0\": {\n", " \"data_transform_0\": {\n", " \"with_label\": False\n", " },\n", " \"reader_0\": {\n", " \"table\": {\n", " \"name\": \"train_b\",\n", " \"namespace\": \"experiment\"\n", " }\n", " }\n", " }\n", " }\n", " }\n", " }\n", "}" ] }, { "cell_type": "code", "execution_count": 30, "id": "loaded-ferry", "metadata": {}, "outputs": [], "source": [ "train_dsl = {\n", " \"components\": {\n", " \"reader_0\": {\n", " \"module\": \"Reader\",\n", " \"output\": {\n", " \"data\": [\"data\"]\n", " }\n", " },\n", " \"data_transform_0\": {\n", " \"module\": \"DataTransform\",\n", " \"input\": {\n", " \"data\": {\n", " \"data\": [\"reader_0.data\"]\n", " }\n", " },\n", " \"output\": {\n", " \"data\": [\"data\"],\n", " \"model\": [\"model\"]\n", " }\n", " },\n", " \"intersection_0\": {\n", " \"module\": \"Intersection\",\n", " \"input\": {\n", " \"data\": {\n", " \"data\": [\"data_transform_0.data\"]\n", " }\n", " },\n", " \"output\": {\n", " \"data\": [\"data\"]\n", " }\n", " }, \n", " \"hetero_secure_boost_0\": {\n", " \"module\": \"HeteroSecureBoost\",\n", " \"input\": {\n", " \"data\": {\n", " \"train_data\": [\"intersection_0.data\"]\n", " }\n", " },\n", " \"output\": {\n", " \"data\": [\"data\"],\n", " \"model\": [\"model\"]\n", " }\n", " },\n", " \"evaluation_0\": {\n", " \"module\": \"Evaluation\",\n", " \"input\": {\n", " \"data\": {\n", " \"data\": [\"hetero_secure_boost_0.data\"]\n", " }\n", " },\n", " \"output\": {\n", " \"data\": [\"data\"]\n", " }\n", " }\n", " }\n", "}" ] }, { "cell_type": "code", "execution_count": 31, "id": "blind-bachelor", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'data': {'board_url': 'http://board:8080/index.html#/dashboard?job_id=20230424164733674031455&role=guest&party_id=9999', 'job_dsl_path': '/data/projects/fate/jobs/20230424164733674031455/job_dsl.json', 'job_id': '20230424164733674031455', 'job_runtime_conf_on_party_path': '/data/projects/fate/jobs/20230424164733674031455/guest/job_runtime_on_party_conf.json', 'job_runtime_conf_path': '/data/projects/fate/jobs/20230424164733674031455/job_runtime_conf.json', 'logs_directory': '/data/projects/fate/logs/20230424164733674031455', 'model_info': {'model_id': 'guest-9999#host-10000#model', 'model_version': '20230424164733674031455'}, 'pipeline_dsl_path': '/data/projects/fate/jobs/20230424164733674031455/pipeline_dsl.json', 'train_runtime_conf_path': '/data/projects/fate/jobs/20230424164733674031455/train_runtime_conf.json'}, 'jobId': '20230424164733674031455', 'retcode': 0, 'retmsg': 'success'}\n" ] } ], "source": [ "#开始训练\n", "import requests\n", "post_data = {'job_dsl': train_dsl, 'job_runtime_conf': train_conf}\n", "response = requests.post(\"http://10.43.159.182:9380/v1/job/submit\", json=post_data)\n", "print(response.json())" ] }, { "cell_type": "code", "execution_count": null, "id": "apparent-treasure", "metadata": {}, "outputs": [], "source": [ "#登录board_url查看模型训练结果" ] }, { "cell_type": "code", "execution_count": null, "id": "divine-smith", "metadata": {}, "outputs": [], "source": [ "#模型部署\n", "import requests\n", "config_data = {\n", " \"job_parameters\": {\n", " \"model_id\": \"guest-9999#host-10000#model\",\n", " \"model_version\": \"20230424085041481989420\"\n", " }\n", " }\n", "response = requests.post(\"http://10.43.159.182:9380/v1/model/deploy\", json=config_data)\n", "\n", "print(response.json())\n" ] }, { "cell_type": "code", "execution_count": null, "id": "global-navigation", "metadata": {}, "outputs": [], "source": [ "predict_conf = {\n", " \"dsl_version\": 2,\n", " \"initiator\": {\n", " \"role\": \"guest\",\n", " \"party_id\": 9999\n", " },\n", " \"role\": {\n", " \"host\": [10000],\n", " \"guest\": [9999]\n", " },\n", " \"job_parameters\": {\n", " \"common\": {\n", " \"work_mode\": 0, \n", " \"job_type\": \"predict\",\n", " \"model_id\": \"guest-9999#host-10000#model\",\n", " \"model_version\": \"20230424085832841569421\"\n", " }\n", " },\n", " \"component_parameters\": {\n", " \"role\": {\n", " \"guest\": {\n", " \"0\": {\n", " \"reader_0\": {\n", " \"table\": {\n", " \"name\": \"test_a\",\n", " \"namespace\": \"experiment\"\n", " }\n", " }\n", " }\n", " },\n", " \"host\": {\n", " \"0\": {\n", " \"reader_0\": {\n", " \"table\": {\n", " \"name\": \"test_b\",\n", " \"namespace\": \"experiment\"\n", " }\n", " }\n", " }\n", " }\n", " }\n", " }\n", "}" ] }, { "cell_type": "code", "execution_count": null, "id": "affecting-accordance", "metadata": {}, "outputs": [], "source": [ "#预测数据\n", "post_data = {'job_runtime_conf': predict_conf}\n", "response = requests.post(\"http://10.43.159.182:9380/v1/job/submit\", json=post_data)\n", "print(response.json())" ] }, { "cell_type": "code", "execution_count": null, "id": "thermal-guatemala", "metadata": {}, "outputs": [], "source": [ "#登录board_url查看模型预测结果" ] }, { "cell_type": "code", "execution_count": null, "id": "fatal-palestine", "metadata": {}, "outputs": [], "source": [ "!flow component output-data -j 20230424085846677853422 -r guest -p 9999 -cpn hetero_secure_boost_0 --output-path ./" ] }, { "cell_type": "code", "execution_count": null, "id": "dental-million", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "detected-adventure", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.10" } }, "nbformat": 4, "nbformat_minor": 5 }