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

estimator_checks_test.py 1.7 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
  1. import unittest
  2. from sklearn.utils.estimator_checks import check_estimator, parametrize_with_checks
  3. from inspect import signature
  4. import imodels
  5. class TestCheckEstimators(unittest.TestCase):
  6. """Checks that estimators conform to sklearn checks
  7. """
  8. def test_check_classifier_compatibility(self):
  9. """Test classifiers are properly sklearn-compatible
  10. """
  11. for classifier in [imodels.SLIMClassifier]: # BoostedRulesClassifier (multi-class not supported)
  12. check_estimator(classifier())
  13. assert 'passed check_estimator for ' + str(classifier)
  14. def test_check_regressor_compatibility(self):
  15. """Test regressors are properly sklearn-compatible
  16. """
  17. for regr in []: # SLIMRegressor fails acc screening for boston dset
  18. check_estimator(regr())
  19. assert 'passed check_estimator for ' + str(regr)
  20. def test_method_signatures_basic(self):
  21. for estimator in imodels.ESTIMATORS:
  22. assert hasattr(estimator, 'fit')
  23. assert 'X' in signature(estimator.fit).parameters, str(estimator) + ' failed fit parameters'
  24. assert 'y' in signature(estimator.fit).parameters, str(estimator) + ' failed fit parameters'
  25. assert hasattr(estimator, 'predict')
  26. assert 'X' in signature(estimator.predict).parameters, str(estimator) + ' failed predict parameters'
  27. for estimator in imodels.CLASSIFIERS:
  28. assert hasattr(estimator, 'predict_proba')
  29. assert 'X' in signature(estimator.predict_proba).parameters, str(
  30. estimator) + ' failed predict_proba parameters'
  31. if __name__ == '__main__':
  32. check_estimator(imodels.FIGSRegressor())
Tip!

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

Comments

Loading...