金融資料2

2021-09-11 19:53:28 字數 3159 閱讀 6349

從這裡可以發現每個特徵彼此之間的相關性。

這裡我選取了與『status』最相關的10個特徵

這裡一共篩選出49個特徵

def woe(x, y, event=1):

res_woe =

iv_dict = {}

for feature in x.columns:

x = x[feature].values

# 1) 連續特徵離散化

if type_of_target(x) == 'continuous':

x = discrete(x)

# 2) 計算該特徵的woe和iv

# woe_dict, iv = woe_single_x(x, y, feature, event)

woe_dict, iv = woe_single_x(x, y, feature, event)

iv_dict[feature] = iv

return iv_dict

def discrete(x):

# 使用5等分離散化特徵

res = np.zeros(x.shape)

for i in range(5):

point1 = stats.scoreatpercentile(x, i * 20)

point2 = stats.scoreatpercentile(x, (i + 1) * 20)

x1 = x[np.where((x >= point1) & (x <= point2))]

mask = np.in1d(x, x1)

res[mask] = i + 1 # 將[i, i+1]塊內的值標記成i+1

return res

def woe_single_x(x, y, feature, event=1):

# event代表**正例的標籤

event_total = sum(y == event)

non_event_total = y.shape[-1] - event_total

iv = 0

woe_dict = {}

for x1 in set(x): # 遍歷各個塊

金融資料採集

陽光金融p2c 陽光網際網路金融服務平台 p2c,p2p 眾籌平台,信用評估模型,金融資料採集,分析,網際網路金融,資訊化,定製開發,專注北京,天津,河北,山東區域,面向金融企業,金融機構。p2p 金融資料採集,網際網路金融,網貸平台,金融管理系統,金融資訊化,信用評估模型 資訊管理 陽光網路致力於...

金融資料3

from sklearn.linear model import logisticregression from sklearn.svm import svc from sklearn.tree import decisiontreeclassifier from sklearn.ensemble ...

金融資料4

from sklearn.metrics import accuracy score,recall score,f1 score,roc auc score,roc curve,precision score from matplotlib import pyplot as plt 定義評估函式 d...