IS9*_*S92 4 python scikit-learn keras
我正在尝试使用sklearn LabelEncoder,但它说它没有属性classes_,但它存在,我不知道是什么问题。这是我的代码片段
from sklearn.preprocessing import LabelEncoder
encoder = LabelEncoder()
def classes_():
#Return the classes which are classified by this model
return encoder.classes_
def num_of_classes():
"""
Return the number of ouput classes
"""
return len(classes_())
X=TimeDistributed(Dense(output_dim = num_of_classes(),293,activation = "softmax")
Run Code Online (Sandbox Code Playgroud)
但是,我收到此错误 AttributeError: 'LabelEncoder' object has no attribute 'classes_'
在尝试访问之前,您需要调用fit(...)或fit_transform(...)on your ,否则您将收到此错误。该属性是通过拟合创建的。LabelEncoderclasses_
| 归档时间: |
|
| 查看次数: |
4535 次 |
| 最近记录: |