# -*- coding: utf-8 -*-
from setuptools import setup

packages = \
['niaaml',
 'niaaml.classifiers',
 'niaaml.data',
 'niaaml.fitness',
 'niaaml.preprocessing',
 'niaaml.preprocessing.feature_selection',
 'niaaml.preprocessing.feature_transform']

package_data = \
{'': ['*']}

install_requires = \
['NiaPy>=2.0.0rc11,<3.0.0',
 'numpy>=1.19.1,<2.0.0',
 'scikit-learn>=0.23.2,<0.24.0',
 'sphinx-rtd-theme>=0.5.0,<0.6.0',
 'sphinx>=3.3.1,<4.0.0']

setup_kwargs = {
    'name': 'niaaml',
    'version': '0.1.1',
    'description': 'Python automated machine learning framework.',
    'long_description': '# NiaAML\n\nNiaAML is an automated machine learning Python framework based on nature-inspired algorithms for optimization. The name comes from the automated machine learning method of the same name [[1]](#1). Its goal is to efficiently compose the best possible classification pipeline for the given task using components on the input. The components are divided into three groups: feature seletion algorithms, feature transformation algorithms and classifiers. The framework uses nature-inspired algorithms for optimization to choose the best set of components for the classification pipeline on the output and optimize their parameters. We use <a href="https://github.com/NiaOrg/NiaPy">NiaPy framework</a> for the optimization process which is a popular Python collection of nature-inspired algorithms. The NiaAML framework is easy to use and customize or expand to suit your needs.\n\n## Installation\n\nInstall NiaAML with pip:\n\n```sh\npip install niaaml\n```\n\n## Components\n\nIn the following sections you can see a list of currently implemented components divided into groups: classifiers, feature selection algorithms and feature transformation algorithms. At the end you can also see a list of currently implemented fitness functions for the optimization process. All of the components are passed into the optimization process using their class names. Let\'s say we want to choose between Adaptive Boosting, Bagging and Multi Layer Perceptron classifiers, Select K Best and Select Percentile feature selection algorithms and Normalizer as the feature transformation algorithm (may not be selected during the optimization process).\n\n```python\nPipelineOptimizer(\n    data=...,\n    classifiers=[\'AdaBoost\', \'Bagging\', \'MultiLayerPerceptron\'],\n    feature_selection_algorithms=[\'SelectKBest\', \'SelectPercentile\'],\n    feature_transform_algorithms=[\'Normalizer\']\n)\n```\n\nFor a full example see the [Examples section](#examples).\n\n### Classifiers\n\n* Adaptive Boosting (AdaBoost),\n* Bagging (Bagging),\n* Extremely Randomized Trees (ExtremelyRandomizedTrees),\n* Linear SVC (LinearSVC),\n* Multi Layer Perceptron (MultiLayerPerceptron),\n* Random Forest Classifier (RandomForestClassifier).\n\n### Feature Selection Algorithms\n\n* Select K Best (SelectKBest),\n* Select Percentile (SelectPercentile),\n* Variance Threshold (VarianceThreshold).\n\n#### Nature-Inspired\n\n* Bat Algorithm (BatAlgorithm),\n* Differential Evolution (DifferentialEvolution),\n* Self-Adaptive Differential Evolution (jDEFSTH),\n* Grey Wolf Optimizer (GreyWolfOptimizer),\n* Particle Swarm Optimization (ParticleSwarmOptimization).\n\n### Feature Transformation Algorithms\n\n* Normalizer (Normalizer),\n* Standard Scaler (StandardScaler).\n\n### Fitness Functions\n\n* Accuracy (Accuracy),\n* Cohen\'s kappa (CohenKappa),\n* F1-Score (F1),\n* Precision (Precision).\n\n## Optimization Process And Parameter Tuning\n\nIn NiaAML there are two types of optimization. Goal of the first type is to find an optimal set of components (feature selection algorithm, feature transformation algorithm and classifier). The next step is to find optimal parameters for the selected set of components and that is the goal of the second type of optimization. Each component has an attribute `_params`, which is a dictionary of parameters and their possible values.\n\n```python\nself._params = dict(\n    n_estimators = ParameterDefinition(MinMax(min=10, max=111), np.uint),\n    algorithm = ParameterDefinition([\'SAMME\', \'SAMME.R\'])\n)\n```\n\nAn individual in the second type of optimization is a real-valued vector that has a size equal to the sum of number of keys in all three dictionaries (classifier\'s _params, feature transformation algorithm\'s _params and feature selection algorithm\'s _params) and a value of each dimension is in range [0.0, 1.0]. The second type of optimization maps real values from the individual\'s vector to those parameter definitions in the dictionaries. Each parameter\'s value can be defined as a range or array of values. In the first case, a value from vector is mapped from one iterval to another and in the second case, a value from vector falls into one of the bins that represent an index of the array that holds possible parameter\'s values.\n\nLet\'s say we have a classifier with 3 parameters, feature selection algorithm with 2 parameters and feature transformation algorithm with 4 parameters. Size of an individual in the second type of optimization is 9. Size of an individual in the first type of optimization is always 3 (1 classifier, 1 feature selection algorithm and 1 feature transform algorithm).\n\nIn some cases we may want to tune a parameter that needs additional information for setting its range of values, so we cannot set the range in the initialization method. In that case we should set its value in the dictionary to None and define it later in the process. The parameter will be a part of parameter tuning process as soon as we define its possible values. For example, see [Select K Best Feature Selection](niaaml/preprocessing/feature_selection/select_k_best.py) and its parameter `k`.\n\n## Examples\n\nNiaAML framework currently supports only numeric features on the input. **However, we are planning to add support for categorical features too.**\n\n### Example of Usage\n\nLoad data and try to find the optimal pipeline for the given components. The example below uses the Particle Swarm Algorithm as the optimization algorithm. You can find a list of all available algorithms in the <a href="https://niapy.readthedocs.io/en/stable/">NiaPy\'s documentation</a>.\n\n```python\nfrom niaaml import PipelineOptimizer, Pipeline\nfrom niaaml.data import BasicDataReader\nimport numpy\n\n# dummy random data\ndata_reader = BasicDataReader(\n    x=numpy.random.uniform(low=0.0, high=15.0, size=(50, 3)),\n    y=numpy.random.choice([\'Class 1\', \'Class 2\'], size=50)\n)\n\npipeline_optimizer = PipelineOptimizer(\n    data=data_reader,\n    classifiers=[\'AdaBoost\', \'Bagging\', \'MultiLayerPerceptron\', \'RandomForest\', \'ExtremelyRandomizedTrees\', \'LinearSVC\'],\n    feature_selection_algorithms=[\'SelectKBest\', \'SelectPercentile\', \'ParticleSwarmOptimization\', \'VarianceThreshold\'],\n    feature_transform_algorithms=[\'Normalizer\', \'StandardScaler\']\n)\npipeline = pipeline_optimizer.run(\'Accuracy\', 20, 20, 400, 400, \'ParticleSwarmAlgorithm\', \'ParticleSwarmAlgorithm\')\n```\n\nYou can save a result of the optimization process as an object to a file for later use.\n\n```python\npipeline.export(\'pipeline.ppln\')\n```\n\nAnd also load it from a file and use the pipeline.\n\n```python\nloaded_pipeline = Pipeline.load(\'pipeline.ppln\')\n\n# some features (can be loaded using DataReader object instances)\nx = numpy.array([[0.35, 0.46, 5.32], [0.16, 0.55, 12.5]], dtype=float)\ny = loaded_pipeline.run(x)\n```\n\nYou can also save a user-friendly representation of a pipeline to a text file.\n\n```python\nfinal_pipeline.export_text(\'pipeline.txt\')\n```\n\nThis is a very simple example with dummy data. It is only intended to give you a basic idea on how to use the framework.\n\n### Example of a Pipeline Component Implementation\n\nNiaAML framework is easily expandable as you can implement components by overriding the base classes\' methods. To implement a classifier you should inherit from the [Classifier](niaaml/classifiers/classifier.py) class and you can do the same with [FeatureSelectionAlgorithm](niaaml/preprocessing/feature_selection/feature_selection_algorithm.py) and [FeatureTransformAlgorithm](niaaml/preprocessing/feature_transform/feature_transform_algorithm.py) classes. All of the mentioned classes inherit from the [PipelineComponent](niaaml/pipeline_component.py) class.\n\nTake a look at the [Classifier](niaaml/classifiers/classifier.py) class and the implementation of the [AdaBoost](niaaml/classifiers/ada_boost.py) classifier that inherits from it.\n\n### Fitness Functions\n\nNiaAML framework also allows you to implement your own fitness function. All you need to do is implement the [FitnessFunction](niaaml/fitness/fitness_function.py) class.\n\nTake a look at the [Accuracy](niaaml/fitness/accuracy.py) implementation.\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tr>\n    <td align="center"><a href="https://github.com/lukapecnik"><img src="https://avatars0.githubusercontent.com/u/23029992?s=460&u=d1c802fd8c82af0a020b1e21af80a34d6e28fb10&v=4?s=100" width="100px;" alt=""/><br /><sub><b>Luka Pečnik</b></sub></a><br /><a href="https://github.com/lukapecnik/NiaAML/commits?author=lukapecnik" title="Code">💻</a> <a href="https://github.com/lukapecnik/NiaAML/commits?author=lukapecnik" title="Documentation">📖</a> <a href="https://github.com/lukapecnik/NiaAML/pulls?q=is%3Apr+reviewed-by%3Alukapecnik" title="Reviewed Pull Requests">👀</a> <a href="https://github.com/lukapecnik/NiaAML/issues?q=author%3Alukapecnik" title="Bug reports">🐛</a> <a href="#example-lukapecnik" title="Examples">💡</a></td>\n    <td align="center"><a href="https://github.com/firefly-cpp"><img src="https://avatars2.githubusercontent.com/u/1633361?v=4?s=100" width="100px;" alt=""/><br /><sub><b>firefly-cpp</b></sub></a><br /><a href="https://github.com/lukapecnik/NiaAML/commits?author=firefly-cpp" title="Code">💻</a> <a href="https://github.com/lukapecnik/NiaAML/issues?q=author%3Afirefly-cpp" title="Bug reports">🐛</a></td>\n  </tr>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!\n\n## Licence\n\nThis package is distributed under the MIT License. This license can be found online at <http://www.opensource.org/licenses/MIT>.\n\n## Disclaimer\n\nThis framework is provided as-is, and there are no guarantees that it fits your purposes or that it is bug-free. Use it at your own risk!\n\n## References\n\n<a id="1">[1]</a> Iztok Fister Jr., Milan Zorman, Dušan Fister, Iztok Fister. <a href="https://link.springer.com/chapter/10.1007%2F978-981-15-2133-1_13">Continuous optimizers for automatic design and evaluation of classification pipelines</a>. In: Frontier applications of nature inspired computation. Springer tracts in nature-inspired computing, pp.281-301, 2020.',
    'author': 'Luka Pečnik',
    'author_email': 'lukapecnik96@gmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/lukapecnik/NiaAML',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
