I have four .csv files containing the training data (data points and their classes) plus test data (data points and their classes) that has been stored into X_train, y_train, X_test and y_test variables respectively.
I need to train a CSV model and test it with the test data and as sklearn.svm.SVC gets numpy arrays as input I tried converting pandas data frames to numoy arrays as follows:
X_train_gene = pd.read_csv("Khan_xtrain.csv").drop('Unnamed: 0', axis=1).values.ravel()
y_train_gene = pd.read_csv("Khan_ytrain.csv").drop('Unnamed: 0', axis=1).values.ravel()
X_test_gene = pd.read_csv("Khan_xtest.csv").drop('Unnamed: 0', axis=1).values.ravel()
y_test_gene = pd.read_csv("Khan_ytest.csv").drop('Unnamed: 0', axis=1).values.ravel()
How can I fix this issue?
What I have tried:
Then I tried the following lines of code to train my model:
from sklearn.svm import SVC
svm_gene = SVC(C=10, kernel='linear')
svm_gene.fit(X_train_gene, y_train_gene)
But I get a value error:
ValueError: Expected 2D array, got 1D array instead: array=[ 0.7733437 -2.438405 -0.4825622 ... -1.115962 -0.7837286 -1.339411 ]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample.