crf.fit(X_train, y_train) does not run and shows the aforementioned error. Further, when I run labels2 = list(crf.classes_) I get NoneType object is not iterable. I have not used crfsuite before and could not find satisfactory information online.
Couple of things to note: the csv file has NO None type and is a simple dataset which consists of numbers alone (including the labels), the last column being a label. Using CRF since it is a multi-label sequential problem.
data = np.genfromtxt("training.csv", delimiter = ',', skip_header = 1)
data = data.astype(int, order='K', casting='unsafe', subok=True,
copy=True)
labels = data[:,6]
features = data[:,0:6]
X_train,X_test,y_train,y_test =
train_test_split(features,labels,test_size=0.3,random_state=1)
features = np.asmatrix(features)
X_train = [features[i] for i in X_train]
y_train = [labels[i] for i in y_train]
X_test = [X_test[i] for i in X_test]
y_test = [y_test[i] for i in y_test]
crf = sklearn_crfsuite.CRF(algorithm='lbfgs',c1=0.1,c2=0.1,max_iterations=100,all_possible_transitions=True)
crf.fit(X_train, y_train)
labels2 = list(crf.classes_)
y_pred = crf.predict(X_test)
metrics.flat_f1_score(y_test, y_pred,average='weighted', labels=labels2)
I expect the final code to give me the F1 score but I cannot get past training :/