我试图编辑 sklearn,我需要为其中一个类添加一个属性。我确信添加self.attribute
将是答案,但我不断收到此属性不可用的错误。我尝试添加这个属性,用我的更改安装新包,一切都很好,直到我运行它
cdef class ClassificationCriterion(Criterion):
"""Abstract criterion for classification."""
def __cinit__(self, SIZE_t n_outputs,
np.ndarray[SIZE_t, ndim=1] n_classes, int test = 1):
"""Initialize attributes for this criterion.
Parameters
----------
n_outputs : SIZE_t
The number of targets, the dimensionality of the prediction
n_classes : numpy.ndarray, dtype=SIZE_t
The number of unique classes in each target
"""
self.test = test
我运行的代码:
clf = sklearn.tree.DecisionTreeClassifier(criterion='entropy',random_state=0,max_depth=2 )
clf2=clf.fit(x,y)
AttributeError: sklearn.tree._criterion.Entropy 对象没有属性测试