コード例 #1
0
    def _config(self, top_k, seed):
        model = rs.RandomChoosingCombinedModel()
        updater = rs.RandomChoosingCombinedModelExpertUpdater(
            **self.parameter_defaults(
                eta=0.1,
                top_k=top_k,
                loss_type="abs",
            ))
        updater.set_model(model)
        pop_model = rs.PopularityModel()
        model.add_model(pop_model)
        pop_updater = rs.PopularityModelUpdater()
        pop_updater.set_model(pop_model)

        pop_model2 = rs.PopularityModel(
        )  #not updated popularity model, predicts 0 for all items and users
        model.add_model(pop_model2)
        pop_model3 = rs.PopularityModel(
        )  #not updated popularity model, predicts 0 for all items and users
        model.add_model(pop_model3)

        factor_model = rs.FactorModel(**self.parameter_defaults(
            begin_min=-0.01,
            begin_max=0.01,
            dimension=10,
            initialize_all=False,
        ))
        model.add_model(factor_model)

        factor_updater = rs.FactorModelGradientUpdater(
            **self.parameter_defaults(learning_rate=0.05,
                                      regularization_rate=0.0))
        factor_updater.set_model(factor_model)

        objective = rs.ObjectiveMSE()
        gradient_computer = rs.GradientComputerPointWise()
        gradient_computer.set_objective(objective)
        gradient_computer.set_model(factor_model)
        gradient_computer.add_gradient_updater(factor_updater)

        negative_sample_generator = rs.UniformNegativeSampleGenerator(
            **self.parameter_defaults(
                negative_rate=10,
                initialize_all=False,
                seed=67439852,
                filter_repeats=False,
            ))
        negative_sample_generator.add_updater(gradient_computer)

        return (model, [updater, pop_updater,
                        negative_sample_generator], [], [])
コード例 #2
0
    def config(self, elems):
        config = self.parameter_defaults(
            top_k=100,
            min_time=0,
            seed=0,
            out_file=None,
            filters=[],
            loggers=[],
        )

        model = rs.PopularityModel()
        updater = rs.PopularityTimeFrameModelUpdater(**self.parameter_defaults(
          tau=86400
        ))
        updater.set_model(model)
        learner = rs.SimpleLearner()
        learner.add_simple_updater(updater)
        learner.set_model(model)

        model = model
        learner = learner

        return {
            'config': config,
            'model': model,
            'learner': learner
        }
コード例 #3
0
    def config(self, elems):
        config = self.parameter_defaults(
            top_k=100,
            min_time=0,
            seed=0,
            out_file=None,
            filters=[],
            loggers=[],
        )

        model = rs.PopularityModel()
        updater = rs.PopularityModelUpdater()
        updater.set_model(model)

        simple_learner = rs.SimpleLearner()
        simple_learner.add_simple_updater(updater)
        simple_learner.set_model(model)

        learner = rs.LearnerPeriodicDelayedWrapper(**self.parameter_defaults(
            period=86400,
            delay=86400
        ))
        learner.set_wrapped_learner(simple_learner)

        model = model
        learner = learner

        return {
            'config': config,
            'model': model,
            'learner': learner
        }
コード例 #4
0
    def _config(self, top_k, seed):
        model = rs.PopularityModel()
        updater = rs.PopularityTimeFrameModelUpdater(**self.parameter_defaults(
          tau=86400
        ))
        updater.set_model(model)

        return (model, updater, [], [])
コード例 #5
0
ファイル: test_LabelFilter.py プロジェクト: kiminh/Alpenglow
    def _config(self, top_k, seed):
        model = ag.PopularityModel()
        updater = ag.PopularityModelUpdater()
        updater.set_model(model)
        label_filter = ag.LabelFilter(**self.parameter_defaults(
            label_file_name=""))
        adapter = ag.WhitelistFilter2ModelAdapter()
        adapter.set_model(model)
        adapter.set_whitelist_filter(label_filter)

        return (adapter, [updater, label_filter], []
                )  #note: do not forget to add filter as an updater
コード例 #6
0
    def _fit(self, recommender_data, users, items, matrix):
        model = rs.PopularityModel()

        updater = rs.PopularityModelUpdater()
        updater.set_model(model)

        learner = rs.OfflineIteratingLearner(
            **self.parameter_defaults(seed=67439852, ))
        learner.set_model(model)
        learner.add_simple_updater(updater)
        learner.set_recommender_data(recommender_data)

        return (model, learner)
コード例 #7
0
ファイル: PopularityModel.py プロジェクト: kiminh/Alpenglow
    def _fit(self, recommender_data, users, items, matrix):
        model = rs.PopularityModel()

        updater = rs.PopularityModelUpdater()
        updater.set_model(model)

        learner = rs.OfflineIteratingOnlineLearnerWrapper(
            seed=0,
            number_of_iterations=0,
            shuffle=False,
        )
        learner.add_updater(updater)

        return (model, learner)
コード例 #8
0
    def _config(self, top_k, seed):
        model = rs.CombinedModel(**self.parameter_defaults(
            los_file_name="my_log_file",
            log_frequency=100000,
            use_user_weights=False,
        ))
        pop_model = rs.PopularityModel()
        model.add_model(pop_model)
        pop_updater = rs.PopularityModelUpdater()
        pop_updater.set_model(pop_model)

        factor_model = rs.FactorModel(**self.parameter_defaults(
            begin_min=-0.01,
            begin_max=0.01,
            dimension=10,
            initialize_all=False,
        ))
        model.add_model(factor_model)

        factor_updater = rs.FactorModelGradientUpdater(
            **self.parameter_defaults(learning_rate=0.05,
                                      regularization_rate=0.0))
        factor_updater.set_model(factor_model)

        objective = rs.ObjectiveMSE()
        gradient_computer = rs.GradientComputerPointWise()
        gradient_computer.set_objective(objective)
        gradient_computer.set_model(factor_model)
        gradient_computer.add_gradient_updater(factor_updater)

        negative_sample_generator = rs.UniformNegativeSampleGenerator(
            **self.parameter_defaults(
                negative_rate=10,
                initialize_all=False,
                seed=67439852,
                filter_repeats=False,
            ))
        negative_sample_generator.add_updater(gradient_computer)

        return (model, [pop_updater, negative_sample_generator], [], [])
コード例 #9
0
    def _config(self, top_k, seed):
        model = rs.PopularityModel()
        updater = rs.PopularityModelUpdater()
        updater.set_model(model)

        return (model, updater, [], [])