diff --git a/MANIFEST.in b/MANIFEST.in index d2580a4b..d9087bf1 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -16,6 +16,19 @@ include setup.cfg include watex/utils/epsg.npy include .coveragerc +# Include specific files from the 'watex' package +include watex/utils/_openmp_helpers.pxd +include watex/utils/espg.npy +recursive-include watex/etc *.* +include watex/wlog.yml +recursive-include watex/wlogfiles *.txt + +# Include .pxd files located in the watex root and subdirectories +global-include watex/*.pxd + +# Include 'examples' directory Python scripts and text files +recursive-include examples *.py *.txt + # exclude from sdist recursive-exclude asv_benchmarks * recursive-exclude examples *.png diff --git a/docs/conf.py b/docs/conf.py index 75c45483..a09cb3bf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -17,7 +17,7 @@ import re import time -import sphinx_gallery +import sphinx_gallery # noqa from sphinx_gallery.sorting import ExampleTitleSortKey @@ -46,8 +46,10 @@ copyright = f"2022-{time.strftime('%Y')}" author = 'K. Laurent Kouadio' # The full version, including alpha/beta/rc tags -try : version = release = watex._version.version -except : version = release = watex.__version__ +try : + version = release = watex._version.version +except : + version = release = watex.__version__ # -- General configuration --------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml index 6e4c35d9..d9a881cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,29 +1,85 @@ [build-system] -requires = ["setuptools >= 61.0.0", - "wheel", - "setuptools_scm>=6.2", - "Cython>=0.29.33", - ] +requires = ["setuptools>=61.0.0", "wheel", "setuptools_scm>=6.2", "Cython>=0.29.33"] build-backend = "setuptools.build_meta" [project] name = "watex" -version="0.3.0" +version = "0.3.1" +description = "Machine learning research in water exploration" +readme = "README.md" +authors = [{name = "Laurent Kouadio", email = "etanoyau@gmail.com"}] +license = {file = "LICENSE"} +keywords = ["exploration", "groundwater", "machine learning", "water", "hydro-geophysics"] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Science/Research", + "Intended Audience :: Developers", + "Topic :: Software Development", + "Topic :: Scientific/Engineering", + "Programming Language :: C", + "Programming Language :: Python", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Operating System :: OS Independent", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", +] +dependencies = [ + "seaborn>=0.12.0", + "pandas>=1.4.0", + "Cython>=0.29.33", + "PyYAML>=5.0.0", + "openpyxl>=3.0.3", + "pyproj>=3.3.0", + "pycsamt>=1.1.2", + "tqdm>=4.64.1", + "tables>=3.6.0", + "scikit-learn==1.2.1", + "joblib>=1.2.0", + "threadpoolctl>=3.1.0", + "matplotlib==3.5.3", + "statsmodels>=0.13.1", + "numpy>=1.23.0", + "scipy>=1.9.0", + "h5py>=3.2.0", + "pytest" +] + +requires-python = ">=3.9" [project.optional-dependencies] -dev = ["click", - "missingno>=0.4.2", - "yellowbrick>=1.5.0", - "pyjanitor>=0.1.7", - "mlxtend>=0.21" - ] +dev = [ + "click", + "missingno>=0.4.2", + "yellowbrick>=1.5.0", + "pyjanitor>=0.1.7", + "mlxtend>=0.21", + "xgboost>=1.7.0", +] + +[project.urls] +"Home" = "https://watex.readthedocs.io" +"Documentation" = "https://watex.readthedocs.io/en/latest/api_references.html" +"Bugs Tracker" = "https://github.com/WEgeophysics/watex/issues" +"Installation Guide" = "https://watex.readthedocs.io/en/latest/installation.html" +"User Guide" = "https://watex.readthedocs.io/en/latest/user_guide.html" +"Source" = "https://github.com/WEgeophysics/watex" +"Download" = "https://pypi.org/project/watex/#files" -[tool.setuptools.dynamic] -version = {attr = "watex._version.version"} [tool.setuptools_scm] write_to = "watex/_version.py" +[project.scripts] +wx = "watex.cli:cli" +version = "watex.cli:version" + +[tool.setuptools.dynamic] +version = {attr = "watex._version.version"} + [tool.pytest.ini_options] minversion = "6.0" doctest_optionflags = "NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL" @@ -40,4 +96,4 @@ exclude = ''' | docs/_build | docs/glr_examples )/ -''' \ No newline at end of file +''' diff --git a/setup.cfg b/setup.cfg index 5b197895..724ca83a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -69,3 +69,7 @@ ignore = [codespell] skip = ./.git,./.mypy_cache,./docs/_build,./docs/glr_examples,./docs/modules/generated ignore-words = build_tools/codespell_ignore_words.txt + +[options.package_data] +watex = utils/_openmp_helpers.pxd, utils/espg.npy, etc/*, wlog.yml, wlogfiles/*.txt +* = *.pxd, data/*, examples/*.py, examples/*.txt diff --git a/setup.py b/setup.py index 0033766c..b96e3cf8 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ # We can actually import watex version from # in editable mode :$ python -m pip install -e . try: - import watex # noqa + import watex VERSION = watex.__version__ except: VERSION ='0.3.1' # set global variables diff --git a/watex/_version.py b/watex/_version.py index bc02bc27..747927e0 100644 --- a/watex/_version.py +++ b/watex/_version.py @@ -1,4 +1,4 @@ # file generated by setuptools_scm # don't change, don't track in version control -__version__ = version = '0.3.0.dev1+g10707dc.d20230709' -__version_tuple__ = version_tuple = (0, 3, 0, 'dev1', 'g10707dc.d20230709') +__version__ = version = '0.3.1.dev1+g10707dc.d20230709' +__version_tuple__ = version_tuple = (0, 3, 2, 'dev1', 'g10707dc.d20230709') diff --git a/watex/cases/modeling.py b/watex/cases/modeling.py index 559de8bf..d10e1ff2 100644 --- a/watex/cases/modeling.py +++ b/watex/cases/modeling.py @@ -46,7 +46,6 @@ # import watex.exceptions as Wex # import watex.decorators as deco - _logger =watexlog().get_watex_logger(__name__) __all__=["BaseModel"] diff --git a/watex/etc/__memory.pkl b/watex/etc/__memory.pkl index a02b2c0d..24c3c33b 100644 Binary files a/watex/etc/__memory.pkl and b/watex/etc/__memory.pkl differ diff --git a/watex/exlib/__init__.py b/watex/exlib/__init__.py index 1b07bce6..5e6631cb 100644 --- a/watex/exlib/__init__.py +++ b/watex/exlib/__init__.py @@ -1,162 +1,114 @@ -""" -'Exlib' sub-package is composed of best :term:`Machine Learning` libraries called for -:mod:`~watex.models` prediction with common datasets. -`scikit-learn `__ and -`gradient boosting machine `__ (GBM) -especially (XGBoost) are build as top module for general prediction purpose. - """ -from .sklearn import ( - BaseEstimator, - TransformerMixin, - ClassifierMixin, - clone, - KMeans, - make_column_transformer, - make_column_selector , - ColumnTransformer, - ShrunkCovariance, - LedoitWolf, - FactorAnalysis, - PCA , - IncrementalPCA, - KernelPCA, - DummyClassifier, - SelectKBest, - f_classif, - SelectFromModel, - SimpleImputer, - permutation_importance, - LogisticRegression, - SGDClassifier, - confusion_matrix, - classification_report , - mean_squared_error, - f1_score, - accuracy_score, - precision_recall_curve, - precision_score, - recall_score, - roc_auc_score, - roc_curve, - silhouette_samples, - make_scorer, - matthews_corrcoef, - train_test_split , - validation_curve, - StratifiedShuffleSplit , - RandomizedSearchCV, - GridSearchCV, - learning_curve , - cross_val_score, - cross_val_predict, - KNeighborsClassifier, - Pipeline, - make_pipeline , - FeatureUnion, - _name_estimators, - OneHotEncoder, - PolynomialFeatures, - RobustScaler , - OrdinalEncoder, - StandardScaler, - MinMaxScaler, - LabelBinarizer, - Normalizer, - LabelEncoder, - SVC, - LinearSVC, - LinearSVR, - DecisionTreeClassifier, - RandomForestClassifier, - AdaBoostClassifier, - VotingClassifier, - BaggingClassifier, - StackingClassifier , - ExtraTreesClassifier, - skl_ensemble_, - sklearndoc, - _HAS_ENSEMBLE_ - ) +The 'Exlib' sub-package aggregates prominent Machine Learning libraries for use in +prediction tasks with common datasets within the `watex.models` framework, notably +including `scikit-learn `__. +""" + +import importlib + +def __getattr__(name): + """ + Dynamically imports scikit-learn components upon access through the + watex.exlib.sklearn namespace, facilitating seamless integration of scikit-learn + objects into watex workflows. + + Parameters: + - name (str): The name of the scikit-learn component (module, class, or function) + being accessed. + + Returns: + - The dynamically imported scikit-learn component. + + Raises: + - AttributeError: If the specified scikit-learn component cannot be found or + does not exist within the scikit-learn library. + + This method leverages a predefined mapping (`sklearn_component_mapping`) that + associates simplified attribute names with their corresponding modules in + scikit-learn, enabling both explicit and implicit module path resolution. + """ + sklearn_component_mapping = { + 'BaseEstimator': 'sklearn.base', + 'TransformerMixin': 'sklearn.base', + 'ClassifierMixin': 'sklearn.base', + 'clone': 'sklearn.base', + 'KMeans': 'sklearn.cluster', + 'make_column_transformer': 'sklearn.compose', + 'make_column_selector': 'sklearn.compose', + 'ColumnTransformer': 'sklearn.compose', + 'ShrunkCovariance': 'sklearn.covariance', + 'LedoitWolf': 'sklearn.covariance', + 'FactorAnalysis': 'sklearn.decomposition', + 'PCA': 'sklearn.decomposition', + 'IncrementalPCA': 'sklearn.decomposition', + 'KernelPCA': 'sklearn.decomposition', + 'DummyClassifier': 'sklearn.dummy', + 'SelectKBest': 'sklearn.feature_selection', + 'f_classif': 'sklearn.feature_selection', + 'SelectFromModel': 'sklearn.feature_selection', + 'SimpleImputer': 'sklearn.impute', + 'permutation_importance': 'sklearn.inspection', + 'LogisticRegression': 'sklearn.linear_model', + 'SGDClassifier': 'sklearn.linear_model', + 'confusion_matrix': 'sklearn.metrics', + 'classification_report': 'sklearn.metrics', + 'mean_squared_error': 'sklearn.metrics', + 'f1_score': 'sklearn.metrics', + 'accuracy_score': 'sklearn.metrics', + 'precision_recall_curve': 'sklearn.metrics', + 'precision_score': 'sklearn.metrics', + 'recall_score': 'sklearn.metrics', + 'roc_auc_score': 'sklearn.metrics', + 'roc_curve': 'sklearn.metrics', + 'silhouette_samples': 'sklearn.metrics', + 'make_scorer': 'sklearn.metrics', + 'matthews_corrcoef': 'sklearn.metrics', + 'train_test_split': 'sklearn.model_selection', + 'validation_curve': 'sklearn.model_selection', + 'StratifiedShuffleSplit': 'sklearn.model_selection', + 'RandomizedSearchCV': 'sklearn.model_selection', + 'GridSearchCV': 'sklearn.model_selection', + 'learning_curve': 'sklearn.model_selection', + 'cross_val_score': 'sklearn.model_selection', + 'cross_val_predict': 'sklearn.model_selection', + 'KNeighborsClassifier': 'sklearn.neighbors', + 'Pipeline': 'sklearn.pipeline', + 'make_pipeline': 'sklearn.pipeline', + 'FeatureUnion': 'sklearn.pipeline', + '_name_estimators': 'sklearn.utils', + 'OneHotEncoder': 'sklearn.preprocessing', + 'PolynomialFeatures': 'sklearn.preprocessing', + 'RobustScaler': 'sklearn.preprocessing', + 'OrdinalEncoder': 'sklearn.preprocessing', + 'StandardScaler': 'sklearn.preprocessing', + 'MinMaxScaler': 'sklearn.preprocessing', + 'LabelBinarizer': 'sklearn.preprocessing', + 'Normalizer': 'sklearn.preprocessing', + 'LabelEncoder': 'sklearn.preprocessing', + 'SVC': 'sklearn.svm', + 'LinearSVC': 'sklearn.svm', + 'LinearSVR': 'sklearn.svm', + 'DecisionTreeClassifier': 'sklearn.tree', + 'RandomForestClassifier': 'sklearn.ensemble', + 'AdaBoostClassifier': 'sklearn.ensemble', + 'VotingClassifier': 'sklearn.ensemble', + 'BaggingClassifier': 'sklearn.ensemble', + 'StackingClassifier': 'sklearn.ensemble', + 'ExtraTreesClassifier': 'sklearn.ensemble', + } + # Check if the component is in the predefined mapping + if name in sklearn_component_mapping: + full_module_path = sklearn_component_mapping[name] + module = importlib.import_module(full_module_path) + return getattr(module, name) + + # Default import behavior for unmapped names + try: + module = importlib.import_module(f"sklearn.{name.lower()}") + return module + except ImportError as e: + raise AttributeError(f"scikit-learn component '{name}' not found") from e + + -from .gbm import ( - xgboost, - xgboostdoc, - XGBClassifier - ) -__all__=[ - "BaseEstimator", - "TransformerMixin", - "ClassifierMixin", - "clone", - "KMeans", - "make_column_transformer", - 'make_column_selector' , - 'ColumnTransformer', - 'ShrunkCovariance', - 'LedoitWolf', - 'FactorAnalysis', - 'PCA' , - 'IncrementalPCA', - 'KernelPCA', - 'DummyClassifier', - 'SelectKBest', - 'f_classif', - 'SelectFromModel', - 'SimpleImputer', - 'permutation_importance', - 'LogisticRegression', - 'SGDClassifier', - 'confusion_matrix', - 'classification_report' , - 'mean_squared_error', - 'f1_score', - 'accuracy_score', - 'precision_recall_curve', - 'precision_score', - 'recall_score', - 'roc_auc_score', - 'roc_curve', - 'silhouette_samples', - 'make_scorer', - 'matthews_corrcoef', - 'train_test_split' , - 'validation_curve', - 'StratifiedShuffleSplit' , - 'RandomizedSearchCV', - 'GridSearchCV', - 'learning_curve' , - 'cross_val_score', - 'cross_val_predict', - 'KNeighborsClassifier', - 'Pipeline', - 'make_pipeline' , - 'FeatureUnion', - '_name_estimators', - 'OneHotEncoder', - 'PolynomialFeatures', - 'RobustScaler' , - 'OrdinalEncoder', - 'StandardScaler', - 'MinMaxScaler', - 'LabelBinarizer', - 'Normalizer', - 'LabelEncoder', - 'SVC', - 'LinearSVC', - 'LinearSVR', - 'DecisionTreeClassifier', - 'RandomForestClassifier', - 'AdaBoostClassifier', - 'VotingClassifier', - 'BaggingClassifier', - 'StackingClassifier' , - 'ExtraTreesClassifier', - 'skl_ensemble_', - 'sklearndoc', - '_HAS_ENSEMBLE_', - 'xgboost', - 'xgboostdoc', - 'XGBClassifier' - ] \ No newline at end of file diff --git a/watex/exlib/sklearn.py b/watex/exlib/sklearn.py index 617cf61e..5d0d65b9 100644 --- a/watex/exlib/sklearn.py +++ b/watex/exlib/sklearn.py @@ -86,6 +86,79 @@ else : _HAS_ENSEMBLE_=True +__all__=[ + "BaseEstimator", + "TransformerMixin", + "ClassifierMixin", + "clone", + "KMeans", + "make_column_transformer", + 'make_column_selector' , + 'ColumnTransformer', + 'ShrunkCovariance', + 'LedoitWolf', + 'FactorAnalysis', + 'PCA' , + 'IncrementalPCA', + 'KernelPCA', + 'DummyClassifier', + 'SelectKBest', + 'f_classif', + 'SelectFromModel', + 'SimpleImputer', + 'permutation_importance', + 'LogisticRegression', + 'SGDClassifier', + 'confusion_matrix', + 'classification_report' , + 'mean_squared_error', + 'f1_score', + 'accuracy_score', + 'precision_recall_curve', + 'precision_score', + 'recall_score', + 'roc_auc_score', + 'roc_curve', + 'silhouette_samples', + 'make_scorer', + 'matthews_corrcoef', + 'train_test_split' , + 'validation_curve', + 'StratifiedShuffleSplit' , + 'RandomizedSearchCV', + 'GridSearchCV', + 'learning_curve' , + 'cross_val_score', + 'cross_val_predict', + 'KNeighborsClassifier', + 'Pipeline', + 'make_pipeline' , + 'FeatureUnion', + '_name_estimators', + 'OneHotEncoder', + 'PolynomialFeatures', + 'RobustScaler' , + 'OrdinalEncoder', + 'StandardScaler', + 'MinMaxScaler', + 'LabelBinarizer', + 'Normalizer', + 'LabelEncoder', + 'SVC', + 'LinearSVC', + 'LinearSVR', + 'DecisionTreeClassifier', + 'RandomForestClassifier', + 'AdaBoostClassifier', + 'VotingClassifier', + 'BaggingClassifier', + 'StackingClassifier' , + 'ExtraTreesClassifier', + 'skl_ensemble_', + 'sklearndoc', + '_HAS_ENSEMBLE_' + ] + from sklearn.ensemble import ( AdaBoostClassifier, VotingClassifier, @@ -109,6 +182,7 @@ ClassifierMixin, clone ) + from sklearn.cluster import KMeans from sklearn.compose import ( make_column_transformer, @@ -188,77 +262,3 @@ from sklearn.tree import DecisionTreeClassifier -__all__=[ - "BaseEstimator", - "TransformerMixin", - "ClassifierMixin", - "clone", - "KMeans", - "make_column_transformer", - 'make_column_selector' , - 'ColumnTransformer', - 'ShrunkCovariance', - 'LedoitWolf', - 'FactorAnalysis', - 'PCA' , - 'IncrementalPCA', - 'KernelPCA', - 'DummyClassifier', - 'SelectKBest', - 'f_classif', - 'SelectFromModel', - 'SimpleImputer', - 'permutation_importance', - 'LogisticRegression', - 'SGDClassifier', - 'confusion_matrix', - 'classification_report' , - 'mean_squared_error', - 'f1_score', - 'accuracy_score', - 'precision_recall_curve', - 'precision_score', - 'recall_score', - 'roc_auc_score', - 'roc_curve', - 'silhouette_samples', - 'make_scorer', - 'matthews_corrcoef', - 'train_test_split' , - 'validation_curve', - 'StratifiedShuffleSplit' , - 'RandomizedSearchCV', - 'GridSearchCV', - 'learning_curve' , - 'cross_val_score', - 'cross_val_predict', - 'KNeighborsClassifier', - 'Pipeline', - 'make_pipeline' , - 'FeatureUnion', - '_name_estimators', - 'OneHotEncoder', - 'PolynomialFeatures', - 'RobustScaler' , - 'OrdinalEncoder', - 'StandardScaler', - 'MinMaxScaler', - 'LabelBinarizer', - 'Normalizer', - 'LabelEncoder', - 'SVC', - 'LinearSVC', - 'LinearSVR', - 'DecisionTreeClassifier', - 'RandomForestClassifier', - 'AdaBoostClassifier', - 'VotingClassifier', - 'BaggingClassifier', - 'StackingClassifier' , - 'ExtraTreesClassifier', - 'skl_ensemble_', - 'sklearndoc', - '_HAS_ENSEMBLE_' - ] - -