我试图从头开始编写SVM算法而不使用sklearn包,现在我想测试我的X_test和Y_predict的准确度分数 . sklearn已经为此发挥作用:
clf.score(X_test,Y_predict)
现在,我跟踪了sklearn包中的代码,我无法找到“得分”函数如何从头开始编码 .
以及如何从sklearn SVC生成模型:
SVM classifier :: SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, decision_function_shape='ovr', degree=3, gamma=2, kernel='poly', max_iter=-1, probability=False, random_state=None, shrinking=True, tol=0.001, verbose=False)
在我安装并训练了数据集后,我希望生成模型,以便我可以使用Pickle保存和加载它 .
1 回答
如果使用IPython,通常可以通过在函数中附加
??
来找出定义函数的位置 . 例如:在这种情况下,它来自
ClassifierMixin
所以这个代码可以用于所有分类器 .https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/base.py#L310
https://ipython.readthedocs.io/en/stable/interactive/python-ipython-diff.html#accessing-help