Examples of scikit-learn documentation

Posted 冯煜博

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Examples of scikit-learn documentation相关的知识,希望对你有一定的参考价值。

scikit-learn

Examples of scikit-learn documentation.

KFold K-折交叉验证

>>> import numpy as np
>>> from sklearn.model_selection import KFold

>>> X = ["a", "b", "c", "d"]
>>> kf = KFold(n_splits=2)
>>> for train, test in kf.split(X):
...     print("%s %s" % (train, test))
[2 3] [0 1]
[0 1] [2 3]

Reference : http://scikit-learn.org/stable/modules/cross_validation.html#k-fold

Decision Trees Classification 决策树分类

>>> from sklearn import tree
>>> X = [[0, 0], [1, 1]]
>>> Y = [0, 1]
>>> clf = tree.DecisionTreeClassifier()
>>> clf = clf.fit(X, Y)
>>> clf.predict([[2., 2.]])
array([1])

Reference : http://scikit-learn.org/stable/modules/tree.html#classification

Leave One Out 留一法

>>> from sklearn.model_selection import LeaveOneOut

>>> X = [1, 2, 3, 4]
>>> loo = LeaveOneOut()
>>> for train, test in loo.split(X):
...     print("%s %s" % (train, test))
[1 2 3] [0]
[0 2 3] [1]
[0 1 3] [2]
[0 1 2] [3]

Reference : http://scikit-learn.org/stable/modules/cross_validation.html#leave-one-out-loo

以上是关于Examples of scikit-learn documentation的主要内容,如果未能解决你的问题,请参考以下文章

Scikit-learn 随机森林 out of bag 样本

MichaelBoselowitz/pygit2-examples: Examples of some "porcelain" git commands implemented with python

Examples of complexity pattern

Examples of MIB Variables - SNMP Tutorial

scikit-learn:3.3. Model evaluation: quantifying the quality of predictions

Basics of Algorithmic Trading: Concepts and Examples