ML之NB:(NLP)基于sklearn库利用不同语种数据集训练NB(朴素贝叶斯)算法,对新语种进行语种检测
ML之NB:(NLP)基于sklearn库利用不同语种数据集训练NB(朴素贝叶斯)算法,对新语种进行语种检测
输出结果
测试01:I love you
测试02:Ich liebe dich
训练数据集
数据集下载:不同语种训练数据集Language_data
设计思路
核心代码
x_train, x_test, y_train, y_test = train_test_split(x, y, random_state=1)
language_detector = LanguageDetector()
language_detector.fit(x_train, y_train)
test_language='Ich liebe dich'
print(language_detector.predict(test_language))
print(language_detector.score(x_test, y_test))
赞 (0)