I have an array which contains feature values as floats and I have an array of labels, which are integers - 1 and 0.
Example: feature values:
[[ 17.99 10.38 122.8 ..., 0.147 0.242 0.079]
[ 20.57 17.77 132.9 ..., 0.07 0.181 0.057]]
When I append labels to the array of feature values, the labels become floats. Example - feature_values with appended 0:
[[ 17.99 10.38 122.8 ..., 0.242 0.079 0. ]]
When I run the following code:
training_set = data_features[:,0:9]
test_set = data_features[:,9]
seed = 7
num_trees = 100
max_features = 3
kfold = model_selection.KFold(n_splits=10, random_state=seed)
model = RandomForestClassifier(n_estimators=num_trees, max_features=max_features)
results = model_selection.cross_val_score(model, training_set, test_set, cv=kfold)
print(results.mean())
I get an error :
raise ValueError("Unknown label type: %r" % y_type)
ValueError: Unknown label type: 'continuous'
From what I've read, I see that this is happening because the labels are floats.
If I change the dtype of feature values to "int", the code does work, but I need to preserve the floats.
Is there any way to have labels as integers and feature values as floats so that the code works?
test_set = data_features[:,9].astype(int)this should do the trick.