I am working on a Data Science project which requires implementation of a neural network. The dataset I am providing for training is not sequential and has class labels. But I don't know why it is treating it as sequence of events.
I am using the following code for the model:
model = keras.Sequential([
layers.Dense(100, activation='relu'),
layers.Dropout(0.4),
layers.Dense(100, activation='relu'),
layers.Dropout(0.4),
layers.Dense(100, activation='relu'),
layers.Dropout(0.4),
layers.Dense(100, activation='relu'),
layers.Dense(6, activation='softmax')
])
model.compile(
optimizer="adam",
loss="sparse_categorical_crossentropy",
metrics=['accuracy']
)
model.fit(X_train, y_train,epochs=100,batch_size=2100)
y_pred=model.predict(X_test)
print(accuracy_score(y_test,y_pred))
The accuracy_score
function is giving this error
Classification metrics can't handle a mix of multiclass and continuous-multioutput targets
This error messages shows when the algorithm is performing the regression. How can I solve this issue?
Edit 1
As suggested by Michael Hodel I have applied the OneHotEncoder
instead of using LabelEncoder
.
data['label']= ohc.fit_transform(data[['label']])
It is giving me error
sparse matrix length is ambiguous; use getnnz() or shape[0]
Edit 2
I used pd.get_dummies()
instead of 'OneHotEncoder`
y_test