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

packages = \
['rfcorr']

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

install_requires = \
['numpy>=1.22.2,<2.0.0', 'scikit-learn>=1.0.2,<2.0.0']

setup_kwargs = {
    'name': 'rfcorr',
    'version': '0.1.0',
    'description': 'Random Forest-inspired correlation/dependence methods',
    'long_description': '<div id="top"></div>\n<!--\n*** Thanks for checking out the Best-README-Template. If you have a suggestion\n*** that would make this better, please fork the repo and create a pull request\n*** or simply open an issue with the tag "enhancement".\n*** Don\'t forget to give the project a star!\n*** Thanks again! Now go create something AMAZING! :D\n-->\n\n<!-- PROJECT SHIELDS -->\n<!--\n*** I\'m using markdown "reference style" links for readability.\n*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).\n*** See the bottom of this document for the declaration of the reference variables\n*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.\n*** https://www.markdownguide.org/basic-syntax/#reference-style-links\n-->\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n\n<div align="center">\n<h3 align="center">rfcorr - Random Forest-based "Correlation" measures</h3>\n  <p align="center">\n    This library records an open research agenda related to alternative conceptions of correlation based on tree-based ensembles, i.e., "random forests."     \n    <br />\n    <br />\n    <strong>Author:</strong> <a href="https://www.linkedin.com/in/bommarito/">Michael Bommarito</a>\n    <br />\n    <strong>Project Homepage:</strong> <a href="https://github.com/mjbommar/rfcorr">GitHub</a>\n    <br />\n    <strong><a href="https://www.linkedin.com/posts/bommarito_github-mjbommarrfcorr-random-forest-based-activity-6899361292889460736-HhKp">Original Announcement</a></strong>\n  </p>\n</div>\n\n## WHY?\nCountless tasks rely on conceptions and formalizations of "correlation."  But in two decades of working in areas that utilize correlation\nas key to their everyday operation, e.g., finance, I have found that few are measuring what their words reveal is their intuition.\n\nWhile others have offered alternative measures of correlation or dependence generally, this is my contribution - an approach based on tree-based ensembles that natively supports lagged correlation.  \nTree-based ensembles have a number of highly-favorable properties:\n\n * Support for categorical features or mixed feature sets\n * Intrinsic uncertainty estimation and intervals through ensemble construction\n * Support for overfitting protection\n * High degree of flexibility\n * Estimation produces inferential models that can be used to make predictions\n\nAdditionally, this library supports lagging inputs against targets in the supervised training process, enabling asymmetric correlation estimates \nfrom the same data.\n\nThere are, however, downsides:\n\n * Slower estimation than other correlation methods\n * Stochastic estimates (though this library supports fixing RNG)\n * Question around interpretation of signedness or directionality\n * More complex interpretation than linear correlation measures\n * Scaling permutation-based estimates\n * Estimating covariance in asymmetric contexts \n\n## FUNCTIONALITY\n\n * Random Forest (`rfcorr.random_forest`)\n   - `get_corr_classification`: Correlation from classification task\n   - `get_corr_regression`: Correlation from regression task\n   - `get_corr`: Convenience handler including lag support for (x, y)\n   - `get_pairwise_corr`: Convenience handler including lag support for full matrix X\n   - Support for impurity-based or permutation-based importances (`use_permutation=True`)\n * Extra Trees (`rfcorr.extra_trees`)\n   - `get_corr_classification`: Correlation from classification task\n   - `get_corr_regression`: Correlation from regression task\n   - `get_corr`: Convenience handler including lag support for (x, y)\n   - `get_pairwise_corr`: Convenience handler including lag support for full matrix X\n   - Support for impurity-based or permutation-based importances (`use_permutation=True`)\n * TODO: Histogram-based Gradient Boosting Trees\n * TODO: Gradient-Boosting Trees\n * TODO: xgboost support\n * TODO: Support exposing intervals (std, range) from permutation-based estimates\n  \n## EXAMPLE USE\n\nThere are sample notebooks in the `notebooks/` directory, including:\n* `notebooks/test_sector_etf.ipynb`: "Correlation" and eigenvalue/spectral representations for SPDR Sector ETFs and SPY \n* `notebooks/test_sector_etf_ts.ipynb`: Rolling "Correlation" time series for SPDR Sector ETFs and SPY\n* `notebooks/test_periodic_pathological.ipynb`: Test of periodic (`sin(x)`) data with pathological results for Pearson/Spearman\n\nSample usage looks like this:\n```python\nimport numpy\nimport pandas\nimport rfcorr.random_forest\n\n# create sample data\nx = numpy.arange(0, 8*numpy.pi, 0.1)\ny1 = numpy.sqrt(x)\ny2 = numpy.sin(x)\n\n# fix random state/RNG\nrs = numpy.random.RandomState(42)\npandas.DataFrame(rfcorr.random_forest.get_pairwise_corr(df.values, \n                                                      num_trees=1000,\n                                                      lag=0,\n                                                      method="regression", \n                                                      use_permutation=True,\n                                                      random_state=rs),\n                 columns=["x", "y1", "y2"],\n                 index=["x", "y1", "y2"])\n"""\nx\ty1\ty2\nx\t1.000000\t1.919737\t0.001276\ny1\t1.965436\t1.000000\t0.003697\ny2\t0.649579\t0.628396\t1.000000\n"""\n#NB: ~0 correlation for x~y2 and y1~y2\n\n# compare with pearson\ndf = pandas.DataFrame(zip(x, y1, y2), columns=["x", "y1", "y2"])\ndf.corr(method="pearson")\n\n"""\n\tx\ty1\ty2\nx\t1.000000\t0.978639\t-0.194091\ny1\t0.978639\t1.000000\t-0.206973\ny2\t-0.194091\t-0.206973\t1.000000\n"""\n\n# compare with spearman\ndf.corr(method="spearman")\n"""\nx\ty1\ty2\nx\t1.000000\t1.000000\t-0.186751\ny1\t1.000000\t1.000000\t-0.186751\ny2\t-0.186751\t-0.186751\t1.000000\n"""\n\n\n```\n\n## LICENSE\nApache 2.0\n\n## COLLABORATION\n\nI\'m currently working on a brief research note that should be on arxiv by March 2022.  I\'d love to collaborate with anyone interested on the topic,\nespecially to bring broader perspective to backtesting, portfolio construction, and regime detection/timing applications.\n\n<p align="right">(<a href="#top">back to top</a>)</p>\n\n<!-- MARKDOWN LINKS & IMAGES -->\n<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->\n\n[contributors-shield]: https://img.shields.io/github/contributors/licensio/responsible-data-use-policy.svg?style=for-the-badge\n\n[contributors-url]: https://github.com/licensio/responsible-data-use-policy/graphs/contributors\n\n[forks-shield]: https://img.shields.io/github/forks/licensio/responsible-data-use-policy.svg?style=for-the-badge\n\n[forks-url]: https://github.com/licensio/responsible-data-use-policy/network/members\n\n[stars-shield]: https://img.shields.io/github/stars/licensio/responsible-data-use-policy.svg?style=for-the-badge\n\n[stars-url]: https://github.com/licensio/responsible-data-use-policy/stargazers\n\n[issues-shield]: https://img.shields.io/github/issues/licensio/responsible-data-use-policy.svg?style=for-the-badge\n\n[issues-url]: https://github.com/licensio/responsible-data-use-policy/issues\n\n[license-shield]: https://img.shields.io/github/license/licensio/responsible-data-use-policy.svg?style=for-the-badge\n\n[license-url]: https://github.com/licensio/responsible-data-use-policy/blob/master/LICENSE.txt\n\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555\n\n[linkedin-url]: https://linkedin.com/in/linkedin_username\n\n[product-screenshot]: images/screenshot.png',
    'author': 'Michael Bommarito',
    'author_email': 'michael@bommaritollc.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/mjbommar/rfcorr',
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.8,<4.0',
}


setup(**setup_kwargs)
