MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / main

Function main

nlp_class2/ner_baseline.py:108–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106
107
108def main():
109 Xtrain, Ytrain, Xtest, Ytest, word2idx, tag2idx = get_data()
110
111 V = len(word2idx)
112 print("vocabulary size:", V)
113 K = len(tag2idx)
114
115 # train and score
116 model = LogisticRegression()
117 model.fit(Xtrain, Ytrain, V=V, K=K, epochs=5)
118 print("training complete")
119 print("train score:", model.score(Xtrain, Ytrain))
120 print("train f1 score:", model.f1_score(Xtrain, Ytrain))
121 print("test score:", model.score(Xtest, Ytest))
122 print("test f1 score:", model.f1_score(Xtest, Ytest))
123
124if __name__ == '__main__':
125 main()

Callers 1

ner_baseline.pyFile · 0.70

Calls 5

fitMethod · 0.95
scoreMethod · 0.95
f1_scoreMethod · 0.95
LogisticRegressionClass · 0.90
get_dataFunction · 0.70

Tested by

no test coverage detected