我正在尝试在Python中创建Naive Bayes分类器。为了找到分类器的准确性,我拥有明确可用的训练和测试数据,并且我想使用train.csv训练我的模型,然后在test.csv上对其进行测试。
除了scikit test_train_split之外,是否有其他功能可以帮助我做到这一点?
答案 0 :(得分:0)
根据上面的评论:
import numpy as np
import pandas as pd
from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import mean_squared_error
# Create an instance
nv_clf = GaussianNB()
# Fit on training set
nv_clf.fit(X_train, y_train)
# Pedict on X_test
y_pred = nv_clif.predict(X_test)
# Calcuate error/accuracy on y_test
nv_mse = mean_squared_error(y_test, y_pred)
# or
nv_rmse = np.sqrt(nv_mse) # root mean squared error