本文整理汇总了Python中sklearn.linear_model.ridge.RidgeClassifierCV类的典型用法代码示例。如果您正苦于以下问题:Python RidgeClassifierCV类的具体用法?Python RidgeClassifierCV怎么用?Python RidgeClassifierCV使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RidgeClassifierCV类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _test_ridge_classifiers
def _test_ridge_classifiers(filter_):
n_classes = np.unique(y_iris).shape[0]
n_features = X_iris.shape[1]
for reg in (RidgeClassifier(), RidgeClassifierCV()):
reg.fit(filter_(X_iris), y_iris)
assert_equal(reg.coef_.shape, (n_classes, n_features))
y_pred = reg.predict(filter_(X_iris))
assert_greater(np.mean(y_iris == y_pred), .79)
cv = KFold(5)
reg = RidgeClassifierCV(cv=cv)
reg.fit(filter_(X_iris), y_iris)
y_pred = reg.predict(filter_(X_iris))
assert_true(np.mean(y_iris == y_pred) >= 0.8)
开发者ID:Moler1995,项目名称:scikit-learn,代码行数:14,代码来源:test_ridge.py
示例2: _test_ridge_classifiers
def _test_ridge_classifiers(filter_):
n_classes = np.unique(y_iris).shape[0]
n_features = X_iris.shape[1]
for clf in (RidgeClassifier(), RidgeClassifierCV()):
clf.fit(filter_(X_iris), y_iris)
assert_equal(clf.coef_.shape, (n_classes, n_features))
y_pred = clf.predict(filter_(X_iris))
assert_greater(np.mean(y_iris == y_pred), .79)
n_samples = X_iris.shape[0]
cv = KFold(n_samples, 5)
clf = RidgeClassifierCV(cv=cv)
clf.fit(filter_(X_iris), y_iris)
y_pred = clf.predict(filter_(X_iris))
assert_true(np.mean(y_iris == y_pred) >= 0.8)
开发者ID:BobChew,项目名称:scikit-learn,代码行数:15,代码来源:test_ridge.py
示例3: test_ridge_classifier_cv_store_cv_values
def test_ridge_classifier_cv_store_cv_values():
x = np.array([[-1.0, -1.0], [-1.0, 0], [-.8, -1.0],
[1.0, 1.0], [1.0, 0.0]])
y = np.array([1, 1, 1, -1, -1])
n_samples = x.shape[0]
alphas = [1e-1, 1e0, 1e1]
n_alphas = len(alphas)
r = RidgeClassifierCV(alphas=alphas, cv=None, store_cv_values=True)
# with len(y.shape) == 1
n_targets = 1
r.fit(x, y)
assert r.cv_values_.shape == (n_samples, n_targets, n_alphas)
# with len(y.shape) == 2
y = np.array([[1, 1, 1, -1, -1],
[1, -1, 1, -1, 1],
[-1, -1, 1, -1, -1]]).transpose()
n_targets = y.shape[1]
r.fit(x, y)
assert r.cv_values_.shape == (n_samples, n_targets, n_alphas)
开发者ID:manhhomienbienthuy,项目名称:scikit-learn,代码行数:23,代码来源:test_ridge.py
示例4: test_class_weights_cv
def test_class_weights_cv():
# Test class weights for cross validated ridge classifier.
X = np.array([[-1.0, -1.0], [-1.0, 0], [-0.8, -1.0], [1.0, 1.0], [1.0, 0.0]])
y = [1, 1, 1, -1, -1]
clf = RidgeClassifierCV(class_weight=None, alphas=[0.01, 0.1, 1])
clf.fit(X, y)
# we give a small weights to class 1
clf = RidgeClassifierCV(class_weight={1: 0.001}, alphas=[0.01, 0.1, 1, 10])
clf.fit(X, y)
assert_array_equal(clf.predict([[-0.2, 2]]), np.array([-1]))
开发者ID:honorLX,项目名称:scikit-learn,代码行数:13,代码来源:test_ridge.py
注:本文中的sklearn.linear_model.ridge.RidgeClassifierCV类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论