什么“指数参数已被弃用并将被删除(假定为真)0.17”是什么意思?

时间:2015-07-25 13:14:12

标签: python python-2.7 machine-learning kaggle

如果这是一个非常基本的问题/错误,我只是开始学习python并道歉。

我正在做Kaggle生物反应教程。我收到此错误

  

C:\阿纳康达\ lib中\站点包\ sklearn \ cross_validation.py:65:   DeprecationWarning:不推荐使用indices参数   删除(假设为True)在0.17 stacklevel = 1)结果:0.458614231133

任何人都知道这意味着什么?我把它谷歌死了,找不到答案。

我正在运行的脚本是:

from sklearn.ensemble import RandomForestClassifier
from sklearn import cross_validation
import logloss
import numpy as np

def main():
    #read in  data, parse into training and target sets
    dataset = np.genfromtxt(open('train.csv','r'), delimiter=',', dtype='f8')[1:]
    target = np.array([x[0] for x in dataset])
    train = np.array([x[1:] for x in dataset])

    #In this case we'll use a random forest, but this could be any classifier
    cfr = RandomForestClassifier(n_estimators=100)

    #Simple K-Fold cross validation. 5 folds.
    #(Note: in older scikit-learn versions the "n_folds" argument is named "k".)
    cv = cross_validation.KFold(len(train), n_folds=5, indices=False)

    #iterate through the training and test cross validation segments and
    #run the classifier on each one, aggregating the results into a list
    results = []
    for traincv, testcv in cv:
        probas = cfr.fit(train[traincv], target[traincv]).predict_proba(train[testcv])
        results.append( logloss.llfun(target[testcv], [x[1] for x in probas]) )

    #print out the mean of the cross-validated results
    print "Results: " + str( np.array(results).mean() )
if __name__=="__main__":
    main()

我相信这是在说:

__author__ = 'nickd'
import scipy as sp
def llfun(act, pred):
    epsilon = 1e-15
    pred = sp.maximum(epsilon, pred)
    pred = sp.minimum(1-epsilon, pred)
    ll = sum(act*sp.log(pred) + sp.subtract(1,act)*sp.log(sp.subtract(1,pred)))
    ll = ll * -1.0/len(act)
    return ll

再一次,如果这是基本的东西真的很抱歉。我以前从未这样做过。

2 个答案:

答案 0 :(得分:5)

这意味着您使用indices关键字参数调用cross_validation.KFold,以后的版本将不支持它:

cv = cross_validation.KFold(len(train), n_folds=5, indices=False)

根据错误消息,indices=True的效果为0.17。该消息表明他们将删除关键字参数,可能他们不会忽略未使用的关键字参数,因此,如果您继续尝试传入索引,可能会在0.17中获得TypeError异常。

答案 1 :(得分:1)

这意味着indices参数不再使用,可能会在sklearn的未来版本中删除。警告是为了让您有机会调整代码(即,不要通过indices参数),这样您的代码在将来的更新中删除后就不会中断。