本文整理汇总了Python中sklearn.discriminant_analysis.QuadraticDiscriminantAnalysis.predict_log_proba方法的典型用法代码示例。如果您正苦于以下问题:Python QuadraticDiscriminantAnalysis.predict_log_proba方法的具体用法?Python QuadraticDiscriminantAnalysis.predict_log_proba怎么用?Python QuadraticDiscriminantAnalysis.predict_log_proba使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.discriminant_analysis.QuadraticDiscriminantAnalysis
的用法示例。
在下文中一共展示了QuadraticDiscriminantAnalysis.predict_log_proba方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_qda
# 需要导入模块: from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis [as 别名]
# 或者: from sklearn.discriminant_analysis.QuadraticDiscriminantAnalysis import predict_log_proba [as 别名]
def test_qda():
# QDA classification.
# This checks that QDA implements fit and predict and returns
# correct values for a simple toy dataset.
clf = QuadraticDiscriminantAnalysis()
y_pred = clf.fit(X6, y6).predict(X6)
assert_array_equal(y_pred, y6)
# Assure that it works with 1D data
y_pred1 = clf.fit(X7, y6).predict(X7)
assert_array_equal(y_pred1, y6)
# Test probas estimates
y_proba_pred1 = clf.predict_proba(X7)
assert_array_equal((y_proba_pred1[:, 1] > 0.5) + 1, y6)
y_log_proba_pred1 = clf.predict_log_proba(X7)
assert_array_almost_equal(np.exp(y_log_proba_pred1), y_proba_pred1, 8)
y_pred3 = clf.fit(X6, y7).predict(X6)
# QDA shouldn't be able to separate those
assert np.any(y_pred3 != y7)
# Classes should have at least 2 elements
assert_raises(ValueError, clf.fit, X6, y4)