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


Python Classifier.classification方法代码示例

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


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

示例1: writeResult

# 需要导入模块: from classifier import Classifier [as 别名]
# 或者: from classifier.Classifier import classification [as 别名]
def writeResult(writeFile, trainMatrix, trainLables, testMatrix, testLables, type):
    result = open(writeFile, "a+")
    result.write("-------Method\tPrecision-Recall-F1(1100 original text and gbdt)-------\n")
    if type == 0:
        trainMatrix, testMatrix = featureSelection(trainMatrix, trainLables, testMatrix)
    classifierInstance = Classifier(trainMatrix, trainLables, testMatrix, testLables)
    
    methods = ["tree", "knn", "svm", "essemble", "gbdt"]
    for i in range(len(methods)):
        key = methods[i]
        classifierInstance.classification(key)
        print key + "classification() done!"
        dict = classifierInstance.evaluate()
        for metric in dict:
            result.write(key + "\t" + metric + "\t" + dict[metric] + "\n")
    result.close()
开发者ID:yaolili,项目名称:restaurantClassification,代码行数:18,代码来源:main.py

示例2: eval_classifier

# 需要导入模块: from classifier import Classifier [as 别名]
# 或者: from classifier.Classifier import classification [as 别名]
def eval_classifier(classifierToUse, featuresToUse, testOrTrain="train"):

    print("Chosen feature: {0}".format(featuresToUse) )
    print("Chosen classifier: {0}".format(classifierToUse))

    fe = FeatureExtractor(featuresToUse)
    dataset = DataSet(fe)
    classifier = Classifier()
    evaluate = Evaluation()

    print "test or Train %s" % testOrTrain
    for feature_class, files in getTestData(testOrTrain).items():
        print "%s" % testOrTrain
        for f in files:
            dataset.addFile(feature_class, f)

    print "Dataset initialized"
    print_class_stats(dataset.classes)

    print "Test set created."
    a_train, a_test, c_train, c_test = train_test_split(dataset.featureVector, dataset.classes, test_size=0.9)
    
    c_pred = classifier.classification(a_train,a_test,c_train,c_test,classifierToUse)
    
    evaluate.evaluate(c_pred,c_test,featuresToUse,classifierToUse)
开发者ID:xiao-shen,项目名称:keystroke,代码行数:27,代码来源:runit.py


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