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


Python Classifier.predict_late_fusion_testing_data方法代码示例

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


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

示例1: __init__

# 需要导入模块: from classifier import Classifier [as 别名]
# 或者: from classifier.Classifier import predict_late_fusion_testing_data [as 别名]
class InterestAnalyzer:

    def __init__(self):
        self.feature_builder = FeatureBuilder()

    def rebuild_features(self):
        print 'Parsing Facebook...'
        fbparser.parse({'in': TRAINING_DIRECTORIES['fb'], 'out': TRAINING_FILES['fb']})
        print 'Parsing Twitter...'
        tweetparser.parse({'in': TRAINING_DIRECTORIES['tweets'], 'out': TRAINING_FILES['tweets']})
        print 'Parsing LinkedIn...'
        linkedinparser.parse({'in': TRAINING_DIRECTORIES['linkedin'], 'out': TRAINING_FILES['linkedin']})
        
        print 'Building features...'
        # build features for training data
        self.feature_builder.create_feature_vectors(TRAINING_FILES['linkedin'], TRAINING_FEATURE_FILES['linkedin'], 'linkedin')
        self.feature_builder.create_feature_vectors(TRAINING_FILES['tweets'], TRAINING_FEATURE_FILES['tweets'], 'tweets')
        self.feature_builder.create_feature_vectors(TRAINING_FILES['fb'], TRAINING_FEATURE_FILES['fb'], 'fb')

    def retrain_classifier(self):
        print 'Training classifier...'
        self.classifier = Classifier()

    def save_classifier(self):
        pickle.dump(self.classifier, open(CLASSIFIER_FILE, 'wb'))

    def load_classifier(self):
        self.classifier = pickle.load(open(CLASSIFIER_FILE, 'rb'))

    def classifier_predict(self):
        print 'Parsing Facebook...'
        fbparser.parse({'in': TESTING_DIRECTORIES['fb'], 'out': TESTING_FILES['fb']})
        print 'Parsing Twitter...'
        tweetparser.parse({'in': TESTING_DIRECTORIES['tweets'], 'out': TESTING_FILES['tweets']})
        print 'Parsing LinkedIn...'
        linkedinparser.parse({'in': TESTING_DIRECTORIES['linkedin'], 'out': TESTING_FILES['linkedin']})
        
        print 'Building features...'
        self.feature_builder.create_feature_vectors(TESTING_FILES['linkedin'], TESTING_FEATURE_FILES['linkedin'], 'linkedin')
        self.feature_builder.create_feature_vectors(TESTING_FILES['tweets'], TESTING_FEATURE_FILES['tweets'], 'tweets')
        self.feature_builder.create_feature_vectors(TESTING_FILES['fb'], TESTING_FEATURE_FILES['fb'], 'fb')

        linkedin_testing_features = np.loadtxt(TESTING_FEATURE_FILES['linkedin'], delimiter=',')
        tweets_testing_features = np.loadtxt(TESTING_FEATURE_FILES['tweets'], delimiter=',')
        fb_testing_features = np.loadtxt(TESTING_FEATURE_FILES['fb'], delimiter=',')

        print 'Predicting labels...'
        print 'LinkedIn classifier:'
        print self.classifier.predict_testing_data('linkedin', linkedin_testing_features, TESTING_LABELS_FILE, 'results_l.txt')
        print 'Twitter classifier:'
        print self.classifier.predict_testing_data('tweets', tweets_testing_features, TESTING_LABELS_FILE, 'results_t.txt')
        
        tweets_result_labels = np.loadtxt('results_t.txt', delimiter=',')
        linkedin_result_labels = np.loadtxt('results_l.txt', delimiter=',')

        print 'Late fusion classifier:'
        print self.classifier.predict_late_fusion_testing_data([tweets_result_labels, linkedin_result_labels], TESTING_LABELS_FILE, 'result.txt')
开发者ID:yj-soh,项目名称:interest-inference-social-network,代码行数:59,代码来源:interestanalyzer.py


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