当前位置: 首页>>代码示例>>Python>>正文


Python EllipticEnvelope.score_samples方法代码示例

本文整理汇总了Python中sklearn.covariance.EllipticEnvelope.score_samples方法的典型用法代码示例。如果您正苦于以下问题:Python EllipticEnvelope.score_samples方法的具体用法?Python EllipticEnvelope.score_samples怎么用?Python EllipticEnvelope.score_samples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sklearn.covariance.EllipticEnvelope的用法示例。


在下文中一共展示了EllipticEnvelope.score_samples方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_score_samples

# 需要导入模块: from sklearn.covariance import EllipticEnvelope [as 别名]
# 或者: from sklearn.covariance.EllipticEnvelope import score_samples [as 别名]
def test_score_samples():
    X_train = [[1, 1], [1, 2], [2, 1]]
    clf1 = EllipticEnvelope(contamination=0.2).fit(X_train)
    clf2 = EllipticEnvelope().fit(X_train)
    assert_array_equal(clf1.score_samples([[2., 2.]]),
                       clf1.decision_function([[2., 2.]]) + clf1.offset_)
    assert_array_equal(clf2.score_samples([[2., 2.]]),
                       clf2.decision_function([[2., 2.]]) + clf2.offset_)
    assert_array_equal(clf1.score_samples([[2., 2.]]),
                       clf2.score_samples([[2., 2.]]))
开发者ID:AlexisMignon,项目名称:scikit-learn,代码行数:12,代码来源:test_elliptic_envelope.py

示例2: test_elliptic_envelope

# 需要导入模块: from sklearn.covariance import EllipticEnvelope [as 别名]
# 或者: from sklearn.covariance.EllipticEnvelope import score_samples [as 别名]
def test_elliptic_envelope():
    rnd = np.random.RandomState(0)
    X = rnd.randn(100, 10)
    clf = EllipticEnvelope(contamination=0.1)
    assert_raises(NotFittedError, clf.predict, X)
    assert_raises(NotFittedError, clf.decision_function, X)
    clf.fit(X)
    y_pred = clf.predict(X)
    scores = clf.score_samples(X)
    decisions = clf.decision_function(X)

    assert_array_almost_equal(
        scores, -clf.mahalanobis(X))
    assert_array_almost_equal(clf.mahalanobis(X), clf.dist_)
    assert_almost_equal(clf.score(X, np.ones(100)),
                        (100 - y_pred[y_pred == -1].size) / 100.)
    assert(sum(y_pred == -1) == sum(decisions < 0))
开发者ID:AlexisMignon,项目名称:scikit-learn,代码行数:19,代码来源:test_elliptic_envelope.py


注:本文中的sklearn.covariance.EllipticEnvelope.score_samples方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。