【问题标题】:KeyError Training ValuesKeyError 训练值
【发布时间】:2019-11-12 00:21:55
【问题描述】:

当运行下面的代码 sn-p 时,我收到一个错误,在我未经训练的眼睛看来一切都是正确的。我试图找出错误在哪里无济于事。

Training Model KeyError

# Specify arrays with input feature values
trainX = train[list(train)[1:]].values # numpy array with training inputs
testX = test[list(train)[1:]].values # numpy array with test inputs

# Specify arrays with output value labels
trainY = train.label.values #output labels for training examples
testY = test.label.values # output labels for test examples

# Show dimensions for arrays
print('Train on %d labeled observations with %d input features.' 
%trainX.shape)
print('Test on %d labeled observations with %d input features' 
%testX.shape)`

错误:

    KeyError                                  Traceback (most recent call 
last)
<ipython-input-66-0e3d6e12b557> in <module>()
 1 trainX = train[list(train)[1:]].values # numpy array with training 
inputs
----> 2 testX = test[list(train)[1:]].values # numpy array with test 
inputs
  3 
  4 # Specify arrays with output value labels
  5 trainY = train.label.values #output labels for training examples

【问题讨论】:

    标签: python arrays pandas numpy keyerror


    【解决方案1】:

    输入文件和变量不正确

    【讨论】:

      猜你喜欢
      • 2019-11-12
      • 2022-06-14
      • 1970-01-01
      • 2018-01-10
      • 1970-01-01
      • 2020-04-05
      • 1970-01-01
      • 2019-09-05
      • 1970-01-01
      相关资源
      最近更新 更多