Ejemplo n.º 1
0
 def test_get_nb_skl_base_estimators(self):
     X, y = random_binary_classification(40, 4)
     rf = RandomForestClassifier(max_depth=2, n_estimators=4)
     rf.fit(X, y)
     n1 = get_nb_skl_base_estimators(rf, fitted=False)
     n2 = get_nb_skl_base_estimators(rf, fitted=True)
     self.assertEqual(n1, 2)
     self.assertEqual(n2, 5)
Ejemplo n.º 2
0
 def __init__(self, dim=None, **opts):
     # Models are fitted here. Every not measured
     # should take place here.
     assert dim is not None
     BenchPerfTest.__init__(self, **opts)
     self.model1 = SGDClassifier()
     self.model2 = make_pipeline(PolynomialFeatures(), SGDClassifier())
     self.model3 = make_pipeline(
         ExtendedFeatures(kind='poly'), SGDClassifier())
     self.model4 = make_pipeline(ExtendedFeatures(
         kind='poly-slow'), SGDClassifier())
     X, y = random_binary_classification(10000, dim)
     self.model1.fit(PolynomialFeatures().fit_transform(X), y)
     self.model2.fit(X, y)
     self.model3.fit(X, y)
     self.model4.fit(X, y)
Ejemplo n.º 3
0
 def data(self, N=None, dim=None, **opts):
     # The benchmark requires a new datasets each time.
     assert N is not None
     assert dim is not None
     return random_binary_classification(N, dim)
Ejemplo n.º 4
0
 def test_random_binary_classification(self):
     X, y = random_binary_classification(40, 4)
     self.assertEqual(X.shape, (40, 4))
     self.assertEqual(y.shape, (40, ))
     self.assertEqual(len(set(y)), 2)
     self.assertIn(y.dtype, (numpy.int32, numpy.int64))