py-automl-lib 2.2__tar.gz → 2.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/PKG-INFO +3 -1
  2. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/README.md +2 -0
  3. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/pyproject.toml +1 -1
  4. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/src/automl/automl.py +43 -9
  5. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/src/automl/scalers_transformers.py +1 -1
  6. py_automl_lib-2.2.2/src/automl/utils/__init__.py +0 -0
  7. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/src/py_automl_lib.egg-info/PKG-INFO +3 -1
  8. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/src/py_automl_lib.egg-info/SOURCES.txt +4 -3
  9. py_automl_lib-2.2.2/src/py_automl_lib.egg-info/top_level.txt +2 -0
  10. py-automl-lib-2.2/src/py_automl_lib.egg-info/top_level.txt +0 -2
  11. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/LICENSE +0 -0
  12. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/setup.cfg +0 -0
  13. {py-automl-lib-2.2/src/misc → py_automl_lib-2.2.2/src}/__init__.py +0 -0
  14. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/src/automl/__init__.py +0 -0
  15. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/src/automl/auto_classification.py +0 -0
  16. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/src/automl/auto_regression.py +0 -0
  17. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/src/automl/classifiers.py +0 -0
  18. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/src/automl/regressors.py +0 -0
  19. {py-automl-lib-2.2/src/misc → py_automl_lib-2.2.2/src/automl/utils}/function_helper.py +0 -0
  20. {py-automl-lib-2.2/src/misc → py_automl_lib-2.2.2/src/automl/utils}/misc.py +0 -0
  21. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/src/py_automl_lib.egg-info/dependency_links.txt +0 -0
  22. {py-automl-lib-2.2 → py_automl_lib-2.2.2}/src/py_automl_lib.egg-info/requires.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py-automl-lib
3
- Version: 2.2
3
+ Version: 2.2.2
4
4
  Summary: Python package for automated hyperparameter-optimization of common machine-learning algorithms
5
5
  Author: Owen O'D
6
6
  Project-URL: Homepage, https://github.com/owenodriscoll/AutoML
@@ -21,6 +21,8 @@ Requires-Dist: SQLAlchemy
21
21
  Provides-Extra: shap
22
22
  Requires-Dist: shap; extra == "shap"
23
23
 
24
+ [![PyPI version](https://img.shields.io/pypi/v/py-automl-lib.svg?color=4c1)](https://pypi.org/project/py-automl-lib/)
25
+
24
26
  # automl: Automated Machine Learning
25
27
  ## Intro
26
28
  automl is a python project focussed on automating much of the machine learning efforts encountered in zero-dimensional regression and classification (and thus not multidimensional data such as for a CNN). It relies on existing Python packages Sci-Kit Learn, Optuna and model specific packages LightGBM, CatBoost and XGBoost.
@@ -1,3 +1,5 @@
1
+ [![PyPI version](https://img.shields.io/pypi/v/py-automl-lib.svg?color=4c1)](https://pypi.org/project/py-automl-lib/)
2
+
1
3
  # automl: Automated Machine Learning
2
4
  ## Intro
3
5
  automl is a python project focussed on automating much of the machine learning efforts encountered in zero-dimensional regression and classification (and thus not multidimensional data such as for a CNN). It relies on existing Python packages Sci-Kit Learn, Optuna and model specific packages LightGBM, CatBoost and XGBoost.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "py-automl-lib"
3
- version = "2.2"
3
+ version = "2.2.2"
4
4
  authors = [
5
5
  { name="Owen O'D"},
6
6
  ]
@@ -22,7 +22,7 @@ from sklearn.model_selection import train_test_split
22
22
 
23
23
  from .scalers_transformers import PcaChooser, PolyChooser, SplineChooser, ScalerChooser, \
24
24
  TransformerChooser, CategoricalChooser#, FourrierExpansion
25
- from misc.function_helper import FuncHelper
25
+ from .utils.function_helper import FuncHelper
26
26
 
27
27
  # --------------- TODO LIST ---------------
28
28
  # FIXME add encoding for clustering of feature importance
@@ -559,7 +559,7 @@ class AutomatedML:
559
559
 
560
560
  return
561
561
 
562
- def model_select_best(self, random_state_model_selection=None) -> AutomatedML:
562
+ def model_select_best(self, random_state_model_selection: int = None, performance_sign_positive: bool = True) -> AutomatedML:
563
563
  """
564
564
  This method is used to create estimator pipelines for all the models specified in models_to_assess
565
565
  attribute and store them in the estimators attribute of the class instance.
@@ -570,6 +570,13 @@ class AutomatedML:
570
570
  pipeline using the Pipeline class from scikit-learn library. Each pipeline per model is added to a list of
571
571
  pipelines, which is then assigned to the estimators attribute of the class instance.
572
572
 
573
+ Parameters
574
+ ----------
575
+ random_state_model_selection: int, None
576
+ integer used to set the random state for random weak model selection
577
+ performance_sign_positive: bool, True
578
+ boolean used to indicate whether performance values should be positive or negative only
579
+
573
580
  Returns
574
581
  -------
575
582
  class instance.
@@ -580,9 +587,10 @@ class AutomatedML:
580
587
  for model_name in list(self._models_assess.keys()):
581
588
 
582
589
  # -- set randomness parameters for randomly selecting models (if self.n_weak_models > 0)
583
- if type(random_state_model_selection) == type(None):
584
- random_state_model_selection = self.random_state
585
- random.seed(random_state_model_selection)
590
+ if random_state_model_selection == None:
591
+ random.seed(self.random_state)
592
+ else:
593
+ random.seed(random_state_model_selection)
586
594
 
587
595
  # -- reload relevant study. Sampler not reloaded here as no additional studies are performed
588
596
  study = optuna.create_study(
@@ -599,7 +607,17 @@ class AutomatedML:
599
607
 
600
608
  # -- select all trials associated with model
601
609
  df_trials = study.trials_dataframe()
602
- df_trials_non_pruned = df_trials[df_trials.state == 'COMPLETE']
610
+
611
+ # -- remove trials returning NaN's or undesired_sign
612
+ if performance_sign_positive:
613
+ error_sign_condition = (df_trials.value >= 0)
614
+ else:
615
+ error_sign_condition = (df_trials.value <= 0)
616
+
617
+ df_trials_non_pruned = df_trials[((df_trials.state == 'COMPLETE') |
618
+ (df_trials.state == 'PRUNED')) &
619
+ (np.isfinite(df_trials.value)) &
620
+ (error_sign_condition) ]
603
621
 
604
622
  # -- ensure that selected number of weak models does not exceed `total completed trials` - `best trial`
605
623
  n_weak_models = self.n_weak_models
@@ -623,6 +641,10 @@ class AutomatedML:
623
641
  idx_remaining.remove(idx_best)
624
642
  idx_models = [idx_best] + random.sample(idx_remaining, n_weak_models)
625
643
 
644
+ # -- reset random state to pre-sampling state
645
+ if random_state_model_selection == None:
646
+ random.seed(self.random_state)
647
+
626
648
  # -- name best and weaker models
627
649
  selected_models = [model_name+'_best'] + [model_name+'_'+str(i) for i in idx_models[1:]]
628
650
 
@@ -783,6 +805,18 @@ class AutomatedML:
783
805
 
784
806
 
785
807
  def apply(self):
808
+ """
809
+ Summary method that runs in sequence the following methods:
810
+
811
+ ```python
812
+ self.model_hyperoptimise()
813
+ self.model_select_best()
814
+ self.model_evaluate()
815
+ ```
816
+
817
+ These can also be called manually, for instance to skip an already performed hyperopimisation
818
+ """
819
+
786
820
  self.model_hyperoptimise()
787
821
  self.model_select_best()
788
822
  self.model_evaluate()
@@ -792,9 +826,9 @@ class AutomatedML:
792
826
 
793
827
  def model_feature_importance(self, n_train_points = 200, n_test_points = 200, cluster = True):
794
828
  """
795
- NOTE DOES NOT WORK WITH NON-NUMERIC DATA
796
- NOTE requires installation of the shap package
797
- python3 -m pip install pyautoml[shap]
829
+ NOTE DOES NOT WORK WITH NON-NUMERIC DATA \n
830
+ NOTE requires installation of the shap package \n
831
+ `python3 -m pip install py-automl-lib[shap]`
798
832
 
799
833
  Evaluates feature importance using shapely values. The SHAP kernel explainer is trained on
800
834
  the training data (or on the cluster thereof). Then the explainer calculates for the test
@@ -20,7 +20,7 @@ import numpy as np
20
20
  import pandas as pd
21
21
 
22
22
  from typing import Union
23
- from misc.function_helper import FuncHelper
23
+ from .utils.function_helper import FuncHelper
24
24
 
25
25
 
26
26
  def decorator_report(variable, to_return_self: bool = False):
File without changes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py-automl-lib
3
- Version: 2.2
3
+ Version: 2.2.2
4
4
  Summary: Python package for automated hyperparameter-optimization of common machine-learning algorithms
5
5
  Author: Owen O'D
6
6
  Project-URL: Homepage, https://github.com/owenodriscoll/AutoML
@@ -21,6 +21,8 @@ Requires-Dist: SQLAlchemy
21
21
  Provides-Extra: shap
22
22
  Requires-Dist: shap; extra == "shap"
23
23
 
24
+ [![PyPI version](https://img.shields.io/pypi/v/py-automl-lib.svg?color=4c1)](https://pypi.org/project/py-automl-lib/)
25
+
24
26
  # automl: Automated Machine Learning
25
27
  ## Intro
26
28
  automl is a python project focussed on automating much of the machine learning efforts encountered in zero-dimensional regression and classification (and thus not multidimensional data such as for a CNN). It relies on existing Python packages Sci-Kit Learn, Optuna and model specific packages LightGBM, CatBoost and XGBoost.
@@ -1,6 +1,7 @@
1
1
  LICENSE
2
2
  README.md
3
3
  pyproject.toml
4
+ src/__init__.py
4
5
  src/automl/__init__.py
5
6
  src/automl/auto_classification.py
6
7
  src/automl/auto_regression.py
@@ -8,9 +9,9 @@ src/automl/automl.py
8
9
  src/automl/classifiers.py
9
10
  src/automl/regressors.py
10
11
  src/automl/scalers_transformers.py
11
- src/misc/__init__.py
12
- src/misc/function_helper.py
13
- src/misc/misc.py
12
+ src/automl/utils/__init__.py
13
+ src/automl/utils/function_helper.py
14
+ src/automl/utils/misc.py
14
15
  src/py_automl_lib.egg-info/PKG-INFO
15
16
  src/py_automl_lib.egg-info/SOURCES.txt
16
17
  src/py_automl_lib.egg-info/dependency_links.txt
@@ -0,0 +1,2 @@
1
+ __init__
2
+ automl
@@ -1,2 +0,0 @@
1
- automl
2
- misc
File without changes
File without changes