-
-
Save funktor/5ca2d673d67bf9099a06d5a88c01a97f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def train_crf_model(train_sentences, train_labels, model_file='age_range.crfsuite'): | |
train_features = [sent2features(sent) for sent in train_sentences] | |
model = pycrfsuite.Trainer(verbose=True) | |
for xseq, yseq in zip(train_features, train_labels): | |
model.append(xseq, yseq) | |
model.set_params({ | |
'c1': 1.0, | |
'c2': 0.01, | |
'max_iterations': 200, | |
'feature.possible_transitions': True | |
}) | |
model.train(model_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment