I have trained an SVM using the NSL-KDD dataset but when I try to make a prediction on it, it comes up with the error "negative dimensions are not allowed".
Below is my code:
`#Indexing of features and labels
features = dataset[:,:-2]
labels = dataset[:,-2]
#split data
train_features, test_features, train_labels, test_labels = train_test_split(features, labels, test_size=0.2)
#train model
model = SVC(C=1.0, kernel='rbf')
#create classifier
classifier = SklearnClassifier(model=model)
#Train classifier
model.fit(train_features, train_labels)
predictions = classifier.predict(test_features)`
full error with traceback:
`File ~\OneDrive\Documents\ids\fgsm.py:50 in <module>
predictions = classifier.predict(test_features)
File ~\AppData\Roaming\Python\Python39\site-packages\art\estimators\classification\classifier.py:73 in replacement_function
return fdict[func_name](self, *args, **kwargs)
File ~\AppData\Roaming\Python\Python39\site-packages\art\estimators\classification\scikitlearn.py:1418 in predict
one_hot_targets = np.eye(self.nb_classes)[targets]
File C:\ProgramData\Anaconda3\lib\site-packages\numpy\lib\twodim_base.py:214 in eye
m = zeros((N, M), dtype=dtype, order=order)
ValueError: negative dimensions are not allowed`
This is the line where the error took place:
`predictions = classifier.predict(test_features)`
I thought that maybe there would be a data mismatch but when I run the following code, I get this:
`print(np.shape(test_features))
(5039, 38)
print(np.shape(test_labels))
(5039,) `
The main reason why im not using model.predict is because im using the classifier estimator from the Adversarial Robustness Toolbox. But i get a negative dimension when i run this code:
`In [4]: classifier.nb_classes
Out[4]: -1`