[EDIT 3] I don't kow if I am doing it correctly but to see if the dataset is balanced or not, I looked how many times in a dataset I have optimization high (H) and optimizaion low (L), which is also what I would like to predict for new samples.
Sorry if I am not really precise but I just started with machine learning.
What I did is the following:
Y = list(data['opt'])
MlistY = Y
MlistY.count('L')
which returns : 17924
MlistY.count('H')
which returns: 12076
Moreover I have also tried to use TfidfVectorizer and what I did is:
from sklearn.feature_extraction.text import TfidfVectorizer
vectorizer = TfidfVectorizer(smooth_idf=False, sublinear_tf=False,norm=None,
analyzer='word')
x = vectorizer.fit_transform(opcodes)
a = vectorizer.vocabulary_
X = list(a.values())
X_all = np.array(X).reshape(-1,1)
Y = list(data['opt'])[:395]
MlistY = Y
y_all = np.array(MlistY)
X_train, X_test, y_train, y_test = train_test_split(X_all, y_all,
test_size=0.3, random_state=15)
from sklearn.svm import SVC
model = SVC(kernel = 'linear',C= 1)
model.fit(X_train,y_train)
y_pred = model.predict(X_test)
print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))
model.score(X_test,y_test)
and in this case the accuracy is : 0.5294117647058824
Moreover, if I print the classification report I find this:
in particular this is for the case of TfidfVectorizer.