Categories
Development

KeyError Training Values

When running the below code snippet I receive an error, everything looks correct to my untrained eye. Ive tried to figure out where the error is to no avail.

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)`

Error:

    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

Leave a Reply

Your email address will not be published. Required fields are marked *