2014-01-29 59 views
0

我使用GridSearchCV從scikit學習0.14,但總能得到以下警告:scikit學習GridSearchCV棄用警告

/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2。 7/site-packages/sklearn/grid_search.py​​:706:DeprecationWarning:GridSearchCV的其他參數將被忽略!參數論證將在0.15中刪除。 DeprecationWarning)

有誰知道到底哪些參數被忽略?

的代碼(x和y從文件中讀取):

def balanced_accuracy (ground_truth, predictions): 
    f00 = 1. * ((ground_truth == 1) & (predictions == 1)).sum()/(ground_truth == 1).sum() 
    f11 = 1. * ((ground_truth == 2) & (predictions == 2)).sum()/(ground_truth == 2).sum() 
    return 0.5* (f00 + f11) 

bc_score = make_scorer(balanced_accuracy, greater_is_better=True) 

C_range = 10. ** np.arange(-3, 3) 
gamma_range = 10. ** np.arange(-3, 3) 
r_range = np.concatenate((np.array([0]), 10.0 ** np.arange(-1, 3))) 
kernel = "poly" 
deg = 2 
cw = "auto" 

param_grid = dict(C=C_range, coef0 = r_range, gamma=gamma_range) 
ss = ShuffleSplit(len(y), 10, test_size = 1000, train_size = 1000) 

grid = GridSearchCV(svm.SVC(kernel = kernel, max_iter = 1000000, degree = deg, class_weight = cw), param_grid=param_grid, cv=ss, scoring = bc_score) 
grid.fit (x, y, sample_weight = sw) 

提前感謝!

回答

2

grid.fitsample_weight參數已被棄用。這在文檔中以及通過查看0.14.X release branch of scikit-learn's source都是明顯的。

在這種情況下,0.14 releasee中也忽略了sample_weight,所以grid.fit(x, y sample_weight=sw)等同於grid.fit(x, y)

作爲一個附註,根據pep-8寫一個好主意。