請教各位大神 這樣的報錯如何操作?
使用map函式進行的操作...
TypeError: unorderable types: Interval() > int()
data[var].head()
0 (300, 750]
1 (300, 750]
2 (-1, 300]
3 (300, 750]
4 (750, 2000]
Name: 每月還款金額組別, dtype: category
Categories (3, interval[int64]): [(-1, 300] < (300, 750] < (750, 2000]
WOE_dict[var]
{Interval(-1, 300, closed='right'): 0.23770096910687502,
Interval(300, 750, closed='right'): -0.04409423969778843,
Interval(750, 2000, closed='right'): -0.36681586177339626}
uj5u.com熱心網友回復:
添點代碼啊,看不出你map打算怎么用,感覺你在使用時將interval轉成int了uj5u.com熱心網友回復:
恩恩好的 代碼如下short_list = high_IV.keys()
short_list_2 = []
for var in short_list:
newVar = var + '_WOE'
data[newVar] = data[var].map(WOE_dict[var])
short_list_2.append(newVar)
uj5u.com熱心網友回復:
求大神指路,謝謝。在用imblearn做先采樣的時候出現如下錯誤:(Python版本3.7)
type object 'sklearn.manifold._barnes_hut_tsne.array' has no attribute '__reduce_cython__'
在線求解 代碼如下:
allFeatures = list(data.columns)
allFeatures.remove('Class')
X = data[allFeatures]
y = data['Class']
n_pos_sample = y[y==0].shape[0]
n_neg_sample = y[y==1].shape[0]
import sklearn
from imblearn.under_sampling import ClusterCentroids
rus = ClusterCentroids(ratio = {0:4*n_pos_sample,1:n_neg_sample},random_state=1)
X,y = rus.fit_sample(X,y)
data_X = pd.DataFrame(X,columns=[allFeatures])
data_y = pd.DataFrame(y,columns=['target'])
data = pd.concat([data_X,data_y],axis=1)
uj5u.com熱心網友回復:
我也遇到這個問題了,求問樓主解決了嘛?轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/117985.html
