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


Python Classifier.predictForTag方法代码示例

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


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

示例1: run

# 需要导入模块: from Classifier import Classifier [as 别名]
# 或者: from Classifier.Classifier import predictForTag [as 别名]
def run(procId, procCount):
    connection = PgSQL.connect(user = "postgres", database = DatabaseName);
    memDb = redis.Redis( host='localhost', port=6379 );
    TrainDbConfig = DbBuildConfig['train'];
    TestDbConfig = DbBuildConfig['test'];
    trainDocDb = DocumentsDatabase(connection, 
                                   TrainDbConfig['DocTagsTable'], 
                                   TrainDbConfig['RawDocTable'], 
                                   TrainDbConfig['TagsTable'], 
                                   TrainDbConfig['DocumentsTable'] );
    testDocDb = DocumentsDatabase(connection, 
                                  TestDbConfig['DocTagsTable'], 
                                  TestDbConfig['RawDocTable'], 
                                  TestDbConfig['TagsTable'], 
                                  TestDbConfig['DocumentsTable'] );
    trainFeatureDb = FeatureDatabase(connection, 
                                     memDb, 
                                     trainDocDb, 
                                     TrainDbConfig['FeaturesTable'], 
                                     TrainDbConfig['DocFeaturesTable'],
                                     TrainDbConfig['TagSpecificFeatureTable']);
    testFeatureDb = FeatureDatabase(connection, 
                                    memDb, 
                                    testDocDb, 
                                    TestDbConfig['FeaturesTable'], 
                                    TestDbConfig['DocFeaturesTable'],
                                    TestDbConfig['TagSpecificFeatureTable']);

    classifier = Classifier(connection, trainFeatureDb, testFeatureDb, 
                   ClassifierTableConfig['predictedTrain'],
                   ClassifierTableConfig['predictedTest'], trainDocDb);

#    if procId == 0:
 #       classifier.createTables();
  #      classifier.createTagPredictTables();
   #     classifier.cleanClassificationTables();

    tags = trainDocDb.getTagsList();
    count = 0;
    for tag in tags:
        count = count + 1;
        if count % procCount != procId:
            continue;
        if count < 9000:
            continue;
        print "Processing ", tag, " ", count;
        c1 = trainDocDb.getTagCount(tag);
        if c1 <= 23:
            continue;
        classifier.predictForTag( tag );
开发者ID:eshavlyugin,项目名称:Facebook-Hacker-Cup-III,代码行数:52,代码来源:ParallelClassifier.py

示例2: run

# 需要导入模块: from Classifier import Classifier [as 别名]
# 或者: from Classifier.Classifier import predictForTag [as 别名]
def run():
    connection = PgSQL.connect(user = "postgres", database = DatabaseName);
    memDb = redis.Redis( host='localhost', port=6379 );
    TrainDbConfig = DbBuildConfig['train'];
    TestDbConfig = DbBuildConfig['test'];
    trainDocDb = DocumentsDatabase(connection, 
                                   TrainDbConfig['DocTagsTable'], 
                                   TrainDbConfig['RawDocTable'], 
                                   TrainDbConfig['TagsTable'], 
                                   TrainDbConfig['DocumentsTable'] );
    trainFeatureDb = FeatureDatabase(connection, 
                                     memDb, 
                                     trainDocDb, 
                                     TrainDbConfig['FeaturesTable'], 
                                     TrainDbConfig['DocFeaturesTable'],
                                     TrainDbConfig['TagSpecificFeatureTable']);
    testFeatureDb = FeatureDatabase(connection, 
                                    memDb, 
                                    None, 
                                    TestDbConfig['FeaturesTable'], 
                                    TestDbConfig['DocFeaturesTable'],
                                    TestDbConfig['TagSpecificFeatureTable']);

    classifier = Classifier(connection, trainFeatureDb, testFeatureDb, 
                   ClassifierTableConfig['predictedTrain'],
                   ClassifierTableConfig['predictedTest'], trainDocDb);

#    classifier.createTables();
    classifier.createTagPredictTables();
    classifier.cleanClassificationTables();
    tags = trainDocDb.getTagsList();
    s1 = 0;
    s2 = 0;
    for tag in tags:
        features = trainFeatureDb.getTagSpecificFeatures( tag );
        testTag = tag;
        hashes = trainFeatureDb.getTagSpecificFeatures(testTag);
        if not hashes:
            continue;
        c1 = trainDocDb.getTagCount(testTag);
        if c1 <= 25:
            continue;
        s1 += c1;
        print classifier.predictForTag( tag );
    classifier.saveClassificationResults();
开发者ID:eshavlyugin,项目名称:Facebook-Hacker-Cup-III,代码行数:47,代码来源:ClassifierTest.py


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