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


Python Cache.save_file方法代码示例

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


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

示例1: load_feature_ids

# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import save_file [as 别名]
    def load_feature_ids(self):
        if os.path.exists(self.DEV_IDS_PATH) and os.path.exists(self.TEST_IDS_PATH):
            movie_ids = (
                Cache.load_file(self.DEV_IDS_PATH) +
                Cache.load_file(self.TEST_IDS_PATH)
            )
        else:
            movie_ids = [id[0] for id in self.fetch_distinct_ids()]
            test_sample_size = int(math.floor(self.TEST_PROB * len(movie_ids)))
            test_ids = random.sample(movie_ids, test_sample_size)
            dev_ids = list(set(movie_ids) - set(test_ids))

            Cache.save_file(self.DEV_IDS_PATH, dev_ids)
            Cache.save_file(self.TEST_IDS_PATH, test_ids)

        logging.info("Loaded %s Movie IDs" % (len(movie_ids)))

        return movie_ids
开发者ID:beets,项目名称:cs221-project,代码行数:20,代码来源:movie_filter.py

示例2: save_kmeans_features

# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import save_file [as 别名]
    def save_kmeans_features(self, model, model_name):
        logging.info("Preparing to save kmeans features...")
        logging.info("Reloading features.")
        features = json.load(open('data/features.json'))
        logging.info("Generating clusters for data")
        training_predictions = model.predict(self.training_feature_matrix)
        test_predictions = model.predict(self.predict_feature_matrix)
        logging.info("Finished Generating Clusters for data")

        movie_id_clusters = [[self.dev_movie_ids, training_predictions], [self.test_movie_ids, test_predictions]]

        for movie_ids, clusters in movie_id_clusters:
            if len(movie_ids) != len(clusters):
                raise ValueError('Movie ids don\'t match clusters')
            for movie_id, cluster in itertools.izip(movie_ids, clusters):
                features[str(movie_id)]['features']['cluster_%s' % cluster] = 1

        logging.info("Saving cluster features")

        Cache.save_file(os.path.join('data', 'features_%s.json' % model_name), features)
开发者ID:jcnnghm,项目名称:cs221-project,代码行数:22,代码来源:scikit_kmeans_runner.py

示例3: save_features

# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import save_file [as 别名]
 def save_features(self):
     Cache.save_file(self.FEATURES_PATH, self.features)
开发者ID:beets,项目名称:cs221-project,代码行数:4,代码来源:feature_creator.py

示例4: save_weights

# 需要导入模块: from cache import Cache [as 别名]
# 或者: from cache.Cache import save_file [as 别名]
 def save_weights(self, weights):
     WEIGHTS_PATH = os.path.join('data', 'weights.json')
     Cache.save_file(WEIGHTS_PATH, weights)
开发者ID:beets,项目名称:cs221-project,代码行数:5,代码来源:sgd_runner.py


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