Metadata-Version: 2.1
Name: fastcan
Version: 0.5.0
Summary: A fast canonical-correlation-based search algorithm
Author-Email: Matthew Sikai Zhang <matthew.szhang91@gmail.com>
License: MIT License
         
         Copyright (c) 2024-2025 The fastcan developers.
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
         
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: Implementation :: CPython
Project-URL: homepage, https://fastcan.readthedocs.io/en/latest/
Project-URL: source, https://github.com/scikit-learn-contrib/fastcan
Project-URL: download, https://pypi.org/project/fastcan/#files
Project-URL: tracker, https://github.com/scikit-learn-contrib/fastcan/issues
Requires-Python: >=3.9
Requires-Dist: scikit-learn>=1.6.0
Description-Content-Type: text/x-rst

fastcan: A fast canonical-correlation-based search algorithm
============================================================
|conda| |Codecov| |CI| |Doc| |PythonVersion| |PyPi| |ruff| |pixi| |asv|

.. |conda| image:: https://img.shields.io/conda/vn/conda-forge/fastcan.svg
   :target: https://anaconda.org/conda-forge/fastcan

.. |Codecov| image:: https://codecov.io/gh/scikit-learn-contrib/fastcan/branch/main/graph/badge.svg
   :target: https://codecov.io/gh/scikit-learn-contrib/fastcan

.. |CI| image:: https://github.com/scikit-learn-contrib/fastcan/actions/workflows/ci.yml/badge.svg
   :target: https://github.com/scikit-learn-contrib/fastcan/actions

.. |Doc| image:: https://readthedocs.org/projects/fastcan/badge/?version=latest
   :target: https://fastcan.readthedocs.io/en/latest/?badge=latest

.. |PythonVersion| image:: https://img.shields.io/pypi/pyversions/fastcan.svg
   :target: https://pypi.org/project/fastcan/

.. |PyPi| image:: https://img.shields.io/pypi/v/fastcan
   :target: https://pypi.org/project/fastcan

.. |ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json
   :target: https://github.com/astral-sh/ruff

.. |pixi| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/prefix-dev/pixi/main/assets/badge/v0.json&style=flat-square
   :target: https://pixi.sh

.. |asv| image:: https://img.shields.io/badge/benchmarked%20by-asv-blue.svg?style=flat
   :target: https://contrib.scikit-learn.org/fastcan/

fastcan is a search algorithm that supports:

#. Feature selection

   * Supervised

   * Unsupervised

   * Multioutput

#. Term selection for time series regressors (e.g., NARX models)

#. Data pruning (i.e., sample selection)


Key advantages:

#. **Extremely fast** -- Designed for high performance, even with large datasets

#. **Redundancy-aware** -- Effectively handles feature or sample redundancy to select the most informative subset

#. **Multioutput** -- Natively supports matrix-valued targets for multioutput tasks

Check `Home Page <https://fastcan.readthedocs.io/en/latest/>`_ for more information.

Installation
------------

Install **fastcan** via PyPi:

* Run ``pip install fastcan``

Or via conda-forge:

* Run ``conda install -c conda-forge fastcan``

Getting Started
---------------
>>> from fastcan import FastCan
>>> X = [[ 0.87, -1.34,  0.31 ],
...     [-2.79, -0.02, -0.85 ],
...     [-1.34, -0.48, -2.55 ],
...     [ 1.92,  1.48,  0.65 ]]
>>> # Multioutput feature selection
>>> y = [[0, 0], [1, 1], [0, 0], [1, 0]]
>>> selector = FastCan(
...     n_features_to_select=2, verbose=0
... ).fit(X, y)
>>> selector.get_support()
array([ True,  True, False])
>>> # Sorted indices
>>> selector.get_support(indices=True)
array([0, 1])
>>> # Indices in selection order
>>> selector.indices_
array([1, 0], dtype=int32)
>>> # Scores for selected features in selection order
>>> selector.scores_
array([0.91162413, 0.71089547])
>>> # Here Feature 2 must be included
>>> selector = FastCan(
...     n_features_to_select=2, indices_include=[2], verbose=0
... ).fit(X, y)
>>> # The feature which is useful when working with Feature 2
>>> selector.indices_
array([2, 0], dtype=int32)
>>> selector.scores_
array([0.34617598, 0.95815008])


NARX Time Series Modelling
--------------------------
fastcan can be used for system identification.
In particular, we provide a submodule `fastcan.narx` to build Nonlinear AutoRegressive eXogenous (NARX) models.
For more information, check this `NARX model example <https://fastcan.readthedocs.io/en/latest/auto_examples/plot_narx.html>`_.


Support Free-Threaded Wheels
----------------------------
fastcan has support for free-threaded (also known as nogil) CPython 3.13.
For more information about free-threaded CPython, check `how to install a free-threaded CPython <https://py-free-threading.github.io/installing_cpython/>`_.

Support WASM Wheels
-------------------
fastcan is compiled to WebAssembly (WASM) wheels using `pyodide <https://github.com/pyodide/pyodide>`_.
You can try it in a `REPL <https://pyodide.org/en/stable/console.html>`_ directly in a browser, without installation.
However, the version of fastcan may be delayed in pyodide. If the latest fastcan WASM wheels are required, you can find them
on the assets of GitHub releases, and the installation is required.
The WASM wheels of fastcan can be installed by

>>> import micropip # doctest: +SKIP
>>> await micropip.install('URL of the wasm wheel (end with _wasm32.whl)') # doctest: +SKIP

📝 **Note:** Due to the Cross-Origin Resource Sharing (CORS) block in web browsers,
you may need `Allow CORS: Access-Control-Allow-Origin Chrome extension <https://chrome.google.com/webstore/detail/allow-cors-access-control/lhobafahddgcelffkeicbaginigeejlf>`_.

📝 **Note:** The nightly wasm wheel of fastcan's dependency (i.e. scikit-learn) can be found in `Scientific Python Nightly Wheels <https://pypi.anaconda.org/scientific-python-nightly-wheels/simple/>`_.


Citation
--------

fastcan is a Python implementation of the following papers.

If you use the `h-correlation` method in your work please cite the following reference:

.. code:: bibtex

   @article{ZHANG2022108419,
      title = {Orthogonal least squares based fast feature selection for linear classification},
      journal = {Pattern Recognition},
      volume = {123},
      pages = {108419},
      year = {2022},
      issn = {0031-3203},
      doi = {https://doi.org/10.1016/j.patcog.2021.108419},
      url = {https://www.sciencedirect.com/science/article/pii/S0031320321005951},
      author = {Sikai Zhang and Zi-Qiang Lang},
      keywords = {Feature selection, Orthogonal least squares, Canonical correlation analysis, Linear discriminant analysis, Multi-label, Multivariate time series, Feature interaction},
      }

If you use the `eta-cosine` method in your work please cite the following reference:

.. code:: bibtex

   @article{ZHANG2025111895,
      title = {Canonical-correlation-based fast feature selection for structural health monitoring},
      journal = {Mechanical Systems and Signal Processing},
      volume = {223},
      pages = {111895},
      year = {2025},
      issn = {0888-3270},
      doi = {https://doi.org/10.1016/j.ymssp.2024.111895},
      url = {https://www.sciencedirect.com/science/article/pii/S0888327024007933},
      author = {Sikai Zhang and Tingna Wang and Keith Worden and Limin Sun and Elizabeth J. Cross},
      keywords = {Multivariate feature selection, Filter method, Canonical correlation analysis, Feature interaction, Feature redundancy, Structural health monitoring},
      }
