當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。