Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

autogluon_test.py 1.3 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  1. import random
  2. import numpy as np
  3. from imodels import FIGSClassifier, BoostedRulesClassifier, GreedyTreeClassifier, RuleFitClassifier, HSTreeClassifierCV
  4. class TestAutogluon:
  5. '''Tests simple classification for different models. Note: still doesn't test all the models!
  6. '''
  7. def setup_method(self):
  8. np.random.seed(13)
  9. random.seed(13)
  10. self.n = 40
  11. self.p = 2
  12. self.X_classification_binary = (
  13. np.random.randn(self.n, self.p) > 0).astype(int)
  14. # y = x0 > 0
  15. self.y_classification_binary = (
  16. self.X_classification_binary[:, 0] > 0).astype(int)
  17. # flip labels for last few
  18. self.y_classification_binary[-2:] = 1 - \
  19. self.y_classification_binary[-2:]
  20. def test_printing_autogluon_models(self):
  21. '''Test imodels on basic binary classification task
  22. '''
  23. for model_type in [
  24. FIGSClassifier, BoostedRulesClassifier, GreedyTreeClassifier, RuleFitClassifier, HSTreeClassifierCV
  25. ]:
  26. init_kwargs = {}
  27. m = model_type(**init_kwargs)
  28. X = self.X_classification_binary
  29. m.fit(X, self.y_classification_binary)
  30. print(m)
  31. if __name__ == '__main__':
  32. t = TestAutogluon()
  33. t.setup()
  34. t.test_printing_autogluon_models()
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...