當前位置: 首頁>>代碼示例>>Python>>正文


Python SelectFdr.transfrom方法代碼示例

本文整理匯總了Python中sklearn.feature_selection.SelectFdr.transfrom方法的典型用法代碼示例。如果您正苦於以下問題:Python SelectFdr.transfrom方法的具體用法?Python SelectFdr.transfrom怎麽用?Python SelectFdr.transfrom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sklearn.feature_selection.SelectFdr的用法示例。


在下文中一共展示了SelectFdr.transfrom方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: svm_cv

# 需要導入模塊: from sklearn.feature_selection import SelectFdr [as 別名]
# 或者: from sklearn.feature_selection.SelectFdr import transfrom [as 別名]
def svm_cv(data, data_target):
    X_train, X_test, y_train, y_test = cross_validation.train_test_split(data, data_target)
    print "*" * 79
    print "Training..."
    # selector = SelectFdr(chi2)
    selector = SelectFdr(f_classif)
    selector.fit(X_train, y_train)
    clf = svm.SVC(kernel='linear', probability=True)
    clf.fit(selector.transform(X_train), y_train)
    print "Testing..."
    pred = clf.predict(selector.transform(X_test))
    probs = pred.predict_proba(selector.transfrom(X_test))
    accuracy_score = metrics.accuracy_score(y_test, pred)
    classification_report = metrics.classification_report(y_test, pred)
    support = selector.get_support()
    print support
    print accuracy_score
    print classification_report
    precision, recall, thresholds = precision_recall_curve(y_test, probs[:, 1])
開發者ID:jfortuna,項目名稱:cs224u-project,代碼行數:21,代碼來源:househearing.py


注:本文中的sklearn.feature_selection.SelectFdr.transfrom方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。