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)
评论列表
文章目录