test_gridsearch_optimizer.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:OptML 作者: johannespetrat 项目源码 文件源码
def test_objective_function(self):
        np.random.seed(4)
        data, target = make_classification(n_samples=100,
                                   n_features=10,
                                   n_informative=10,
                                   n_redundant=0,
                                   class_sep=100,
                                   n_clusters_per_class=1,
                                   flip_y=0.0)
        model = RandomForestClassifier(max_depth=5)
        model.fit(data, target)
        fun = partial(objective, model, 
                                 'sklearn', 
                                 clf_score,
                                 data, target, data, target)
        # model should fit the data perfectly
        final_score = fun(model.get_params())[0]
        self.assertEqual(final_score,1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号