企业非法集资风险预测_2020CCF--企业非法集资风险预测83.35baseline
生活随笔
收集整理的這篇文章主要介紹了
企业非法集资风险预测_2020CCF--企业非法集资风险预测83.35baseline
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
企業非法集資風險預測 競賽 - DataFountain?www.datafountain.cn代碼地址?github.com缺失值填補(一半缺失的列刪除,對于類別特征:NaN當作單獨一個類別進行數值編碼) object類型數值編碼 交叉特征和分桶特征,對于幾個重要的特征(企業類別,細分類這種做交叉特征是很有意義的) merge每一個表格的數據(基本信息表,納稅表,年度報表,變動表,輿論表,其余) 選出category特征給catboost單獨指定 暴力搜索參數 隨機森林單模五折交叉驗證:線下:832,線上:829 catboost單模五折交叉驗證:線下:841,線上:828 隨機森林+catboost融合(取前20重要的特征:線上834) 特征篩選十分重要,避免過度擬合到線下的驗證數據
歡迎大家開源關注我的github倉庫以及該知乎專欄,該倉庫用于記錄和定期提供各大數據科學競賽的賽事消息和原創baseline,思路分享以及博主的一些競賽心得和學習資料等. 主要涵蓋:kaggle, 阿里天池,華為云大賽校園賽,百度aistudio,和鯨社區,datafountain等。目前已經總結了多個比賽的獲獎方案和baseline
賽題描述:
背景:非法集資嚴重干擾了正常的經濟、金融秩序,使參與者遭受經濟損失,甚至生活陷入困境,極易引發社會不穩定和大量社會治安問題,甚至引發局部地區的社會動蕩。如何根據大量的企業信息建立預測模型并判斷企業是否存在非法集資風險,對監管部門、企業合作伙伴、投資者都具有一定的價值。任務:利用機器學習、深度學習等方法訓練一個預測模型,該模型可學習企業的相關信息,以預測企業是否存在非法集資風險。賽題的難點在于數據集包括大量的企業相關信息,如何從中提取有效的特征并進行風險預測成為本賽題的關鍵問題解決思路:
目前只提交了9次,后續有時間會繼續做,所以還會繼續更新效果更好的代碼!目前的特征基本沒有怎么做,所以改進空間還有很大。目測好好做數據和特征篩選會取得很好的成績,但是最穩的還是有一個穩定的線下驗證,如果有一個和線上同升/降的驗證集,比賽基本拿下一半了- 缺失值填補(一半缺失的列刪除,對于類別特征:NaN當作單獨一個類別進行數值編碼)
- object類型數值編碼
- 交叉特征和分桶特征,對于幾個重要的特征(企業類別,細分類這種做交叉特征是很有意義的)
- merge每一個表格的數據(基本信息表,納稅表,年度報表,變動表,輿論表,其余)
- 選出category特征給catboost單獨指定
- 暴力搜索參數
- 隨機森林單模五折交叉驗證:線下:832,線上:829
- catboost單模五折交叉驗證:線下:841,線上:828
- 隨機森林+catboost融合(取前20重要的特征:線上834)
- 特征篩選十分重要,避免過度擬合到線下的驗證數據
數據分析:
本賽題數據缺失值較多,除了企業的基本信息較為齊全外,其余各表信息均有缺失。很多企業id空缺 訓練集總共14865條樣本,其中正例:13884,負例981.約為14:1.
下面是對數據的初步分析:
base_info=pd.read_csv('train/base_info.csv')#企業的基本信息 annual_report_info=pd.read_csv('train/annual_report_info.csv')#企業的年報基本信息 tax_info=pd.read_csv('train/tax_info.csv')#企業的納稅信息 change_info=pd.read_csv('train/tax_info.csv')#變更信息 news_info=pd.read_csv('train/news_info.csv')#輿情信息 other_info=pd.read_csv('train/other_info.csv')#其它信息 entprise_info=pd.read_csv('train/entprise_info.csv')#企業標注信息{0: 13884, 1: 981} entprise_evaluate=pd.read_csv('entprise_evaluate.csv')#未標注信息print('base_info shape:',base_info.shape,'id unique:',len(base_info['id'].unique())) print('annual_report_info shape:',annual_report_info.shape,'id unique:',len(annual_report_info['id'].unique())) print('tax_info shape:',tax_info.shape,'id unique:',len(tax_info['id'].unique())) print('change_info shape:',change_info.shape,'id unique:',len(change_info['id'].unique())) print('news_info shape:',news_info.shape,'id unique:',len(news_info['id'].unique())) print('other_info shape:',other_info.shape,'id unique:',len(other_info['id'].unique())) print('entprise_info shape:',entprise_info.shape,'id unique:',len(entprise_info['id'].unique())) print('entprise_evaluate shape:',entprise_evaluate.shape,'id unique:',len(entprise_evaluate['id'].unique()))處理base_info數據:主要是對數據object列進行數值編碼
# #處理base_info數據 base_info_clean=base_info.drop(['opscope','opfrom','opto'],axis=1)#............................對object類型進行編碼............................... base_info_clean['industryphy']=base_info_clean['industryphy'].fillna("無") base_info_clean['dom']=base_info_clean['dom'].fillna("無") base_info_clean['opform']=base_info_clean['opform'].fillna("無") base_info_clean['oploc']=base_info_clean['oploc'].fillna("無") # dic={} cate=base_info_clean.industryphy.unique() for i in range(len(cate)):dic[cate[i]]=ibuf = pd.DataFrame() buf_group = base_info_clean.groupby('industryphy',sort=False) for name,group in buf_group:group['industryphy'] = dic[name]buf = pd.concat([buf,group],ignore_index=True) print('finished 1....') # dic={} cate=buf.dom.unique() for i in range(len(cate)):dic[cate[i]]=ibuf_group = buf.groupby('dom',sort=False) buf = pd.DataFrame() for name,group in buf_group:group['dom'] = dic[name]buf = pd.concat([buf,group],ignore_index=True) print('finished 2....') # dic={} cate=buf.opform.unique() for i in range(len(cate)):dic[cate[i]]=ibuf_group = buf.groupby('opform',sort=False) buf = pd.DataFrame() for name,group in buf_group:group['opform'] = dic[name]buf = pd.concat([buf,group],ignore_index=True) print('finished 3....') # dic={} cate=buf.oploc.unique() for i in range(len(cate)):dic[cate[i]]=ibuf_group = buf.groupby('oploc',sort=False) buf = pd.DataFrame() for name,group in buf_group:group['oploc'] = dic[name]buf = pd.concat([buf,group],ignore_index=True) print('finished 4....') # buf=buf.fillna(-1) # buf_group = buf.groupby('id',sort=False).agg('mean') base_info_clean=pd.DataFrame(buf_group).reset_index() # print('編碼完畢.................')對一些重要的特征進行交叉組合和分桶構造新特征
#........................分桶................................. def bucket(name,bucket_len):gap_list=[base_info_clean[name].quantile(i/bucket_len) for i in range(bucket_len+1)]len_data=len(base_info_clean[name])new_col=[]for i in base_info_clean[name].values:for j in range(len(gap_list)):if gap_list[j]>=i:encode=jbreaknew_col.append(encode)return new_col #注冊資本_實繳資本 base_info_clean['regcap_reccap']=base_info_clean['regcap']-base_info_clean['reccap'] #注冊資本分桶 base_info_clean['regcap']=base_info_clean['regcap'].fillna(base_info_clean['regcap'].median()) base_info_clean['bucket_regcap']=bucket('regcap',5) #實繳資本分桶 base_info_clean['reccap']=base_info_clean['reccap'].fillna(base_info_clean['reccap'].median()) base_info_clean['bucket_reccap']=bucket('reccap',5) #注冊資本_實繳資本分桶 base_info_clean['regcap_reccap']=base_info_clean['regcap_reccap'].fillna(base_info_clean['regcap_reccap'].median()) base_info_clean['bucket_regcap_reccap']=bucket('regcap_reccap',5) print('分桶完畢.................') #.............................交叉......................... #作兩個特征的交叉 def cross_two(name_1,name_2):new_col=[]encode=0dic={}val_1=base_info[name_1]val_2=base_info[name_2]for i in tqdm(range(len(val_1))):tmp=str(val_1[i])+'_'+str(val_2[i])if tmp in dic:new_col.append(dic[tmp])else:dic[tmp]=encodenew_col.append(encode)encode+=1return new_col #作企業類型-小類的交叉特征 base_info_clean['enttypegb']=base_info_clean['enttypegb'].fillna("無") base_info_clean['enttypeitem']=base_info_clean['enttypeitem'].fillna("無") new_col=cross_two('enttypegb','enttypeitem')#作企業類型-小類的交叉特征 base_info_clean['enttypegb_enttypeitem']=new_col # #行業類別-細類的交叉特征 base_info_clean['industryphy']=base_info_clean['industryphy'].fillna("無") base_info_clean['industryco']=base_info_clean['industryco'].fillna("無") new_col=cross_two('industryphy','industryco')#作企業類型-小類的交叉特征 base_info_clean['industryphy_industryco']=new_col print('交叉特征完畢.................')處理其它幾個表格的方式相同,完整代碼見文章開頭的github地址!
目前沒有幾個手工特征,之前試過一個特征不做,就用原始數據也能到82.5+的成績。所以模型的改進空間還有很大,預祝大家取得好成績!
總結
以上是生活随笔為你收集整理的企业非法集资风险预测_2020CCF--企业非法集资风险预测83.35baseline的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java编程思想学习(一) 一切都是对象
- 下一篇: 学习资料:8大行业,30个大数据实践案例