Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build WASM wheel
uses: pypa/[email protected].0
uses: pypa/[email protected].1
env:
CIBW_PLATFORM: pyodide
- name: Upload package
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected].10
- uses: prefix-dev/[email protected].11
with:
environments: static
cache: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected].10
- uses: prefix-dev/[email protected].11
with:
environments: >-
dev
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: prefix-dev/[email protected].10
- uses: prefix-dev/[email protected].11
with:
environments: dev
cache: true
Expand All @@ -33,7 +33,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build wheels
uses: pypa/[email protected].0
uses: pypa/[email protected].1
env:
CIBW_SKIP: "*_i686 *_ppc64le *_s390x *_universal2 *-musllinux_*"
CIBW_PROJECT_REQUIRES_PYTHON: ">=3.10"
Expand Down
7 changes: 7 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ build:
os: ubuntu-22.04
tools:
python: "3.13"
apt_packages:
- default-jre # for plantuml
- graphviz # for plantuml
jobs:
pre_install:
- bash scripts/rtd_pre_install.sh

sphinx:
configuration: doc/conf.py
fail_on_warning: true

python:
install:
Expand Down
18 changes: 9 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FastCan: A Fast Canonical-Correlation-Based Greedy Search Algorithm
fastcan: A fast canonical-correlation-based greedy search algorithm
===================================================================
|conda| |Codecov| |CI| |Doc| |PythonVersion| |PyPi| |ruff| |pixi|

Expand Down Expand Up @@ -26,7 +26,7 @@ FastCan: A Fast Canonical-Correlation-Based Greedy Search Algorithm
.. |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

FastCan is a greedy search algorithm that supports:
fastcan is a greedy search algorithm that supports:

#. Feature selection

Expand Down Expand Up @@ -54,7 +54,7 @@ Check `Home Page <https://fastcan.readthedocs.io/en/latest/>`_ for more informat
Installation
------------

Install **FastCan** via PyPi:
Install **fastcan** via PyPi:

* Run ``pip install fastcan``

Expand Down Expand Up @@ -90,35 +90,35 @@ array([0.34617598, 0.95815008])

NARX Time Series Modelling
--------------------------
FastCan can be used for system identification.
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 our `Home Page <https://fastcan.readthedocs.io/en/latest/>`_.


Support Free-Threaded Wheels
----------------------------
FastCan has support for free-threaded (also known as nogil) CPython 3.13.
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>`_, and they are available on the assets of GitHub releases.
fastcan is compiled to WebAssembly (WASM) wheels using `pyodide <https://github.com/pyodide/pyodide>`_, and they are available on the assets of GitHub releases.
You can try it in a `REPL <https://pyodide.org/en/stable/console.html>`_ directly in a browser.
The WASM wheels of FastCan can be installed by
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/>`_.
📝 **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.
fastcan is a Python implementation of the following papers.

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

Expand Down
4 changes: 3 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@
# Link to other project's documentation (see mapping below)
"sphinx.ext.intersphinx",
"sphinx_gallery.gen_gallery",
# for dropdown directive
# For dropdown directive
"sphinx_design",
# For PlantUML diagrams
"sphinxcontrib.plantuml",
]

# List of patterns, relative to source directory, that match files and
Expand Down
73 changes: 73 additions & 0 deletions doc/diagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
@startuml fastcan
skinparam backgroundColor transparent
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Component.puml
!include <logos/numpy>
!include <logos/python>
!include <logos/c>


AddContainerTag("module", $legendText="module")
AddContainerTag("db", $legendText="input/output", $sprite="numpy", $bgColor="gray", $fontColor="white", $borderColor="gray")
AddComponentTag("python", $legendText="Python code", $sprite="python")
AddComponentTag("cython", $legendText="Cython code", $sprite="c", $bgColor="gold", $fontColor="brown", $borderColor="gold")
UpdateContainerBoundaryStyle($type="module", $legendText="module boundary")


Container_Boundary(fastcan, "fastcan", $descr="A library for fast feature engineering and data preprocessing"){
Component(cancorr_fast, "cancorr_fast", $tags="cython", $descr="Fast canonical correlation based forward search")
Component(FastCan, "FastCan", $tags="python", $descr="Feature selector")
Component(minibatch, "minibatch", $tags="python", $descr="Prunes samples in batch-wise")
Component(refine, "refine", $tags="python", $descr="Refines selection of FastCan")


Rel(FastCan, cancorr_fast, "Sends features to", "arrays")
Rel(minibatch, cancorr_fast, "Sends samples to", "arrays")
Rel(FastCan, refine, "Sends selected features to", "arrays")
Rel(refine, cancorr_fast, "Sends features to", "arrays")
}

Container_Boundary(narx, "narx", $descr="A submodule for NARX modelling"){
Component(make_narx, "make_narx", $tags="python", $descr="Builder for NARX model instances")
Component(narx_fast, "narx_fast", $tags="cython", $descr="Fast computation of gradient and prediction for NARX models")
Component(NARX, "NARX", $tags="python", $descr="NARX model")
Component(time_shift, "time_shift", $tags="python", $descr="Transforming time-series to time-shifted features")
Component(poly, "poly", $tags="python", $descr="Nonlinearises features with polynomial basis functions")
' Component(tp2fd, "tp2fd", $tags="python", $descr="Converts time_shift ids and poly ids to feat ids and delay ids")
Component(print_narx, "print_narx", $tags="python", $descr="Prints NARX model summary")

Rel(NARX, print_narx, "Sends NARX model to", "NARX model")
' Rel(make_narx, poly, "Makes polynomial features using", "unique id numbers")
Rel(make_narx, time_shift, "Sends time series to", "arrays")
' Rel(make_narx, tp2fd, "Sends time_shift ids and poly ids to", "unique id numbers")
Rel(time_shift, poly, "Sends time-shifted features to", "arrays")
Rel(poly, FastCan, "Sends polynomial features to", "arrays")
' Rel(tp2fd, NARX, "Sends feat ids and delay ids to", "unique id numbers")
Rel(NARX, narx_fast, "Sends initial conditions of inputs, prediction and gradients to", "fit, predict")

}

Person(person, "User", $descr="A data scientist or developer using NumPy, SciPy, and scikit-learn")
ContainerDb(output, "fastcan output", $tags="db", $techn="indices", $descr="Selected indices of features or samples")
ContainerDb(input, "fastcan input", $tags="db", $techn="arrays, allow multi-output", $descr="Input data")
ContainerDb(narx_output, "narx output", $tags="db", $techn="arrays", $descr="Prediction and gradients of NARX model")
ContainerDb(narx_input, "narx input", $tags="db", $techn="arrays, allow nan, allow multi-output", $descr="Time-series data")

Rel(input, FastCan, "Sends features to", "arrays")
Rel(input, minibatch, "Sends samples to", "arrays")
Rel(narx_input, make_narx, "Sends time series to", "arrays")
Rel(narx_input, NARX, "Sends time series to", "arrays")

Rel(cancorr_fast, output, "Sends selected indices to", "indices")
Rel(output, refine, "Sends selected indices to", "indices")
Rel(narx_fast, narx_output, "Sends prediction and gradients to", "arrays")
Rel(output, NARX, "Sends selected polynomial features to", "indices")

Rel(person, input, "Processes arrays using", "NumPy, scikit-learn pipeline")
Rel(person, narx_input, "Processes time series using", "NumPy, scikit-learn pipeline")

Container(optimizer, "SciPy Optimiser", "module", $tags="module", $descr="Minimises objective functions using prediction errors and gradients")
Rel(narx_output, optimizer, "Sends prediction and gradients to", "arrays")
Rel(optimizer, NARX, "Updates coefficients for", "arrays")

SHOW_LEGEND()
@enduml
6 changes: 5 additions & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@

.. include:: ../README.rst

Architecture Diagram
--------------------

.. uml:: diagram.puml
:align: center

API Reference
-------------
Expand Down Expand Up @@ -49,7 +53,7 @@ Useful Links
API Compatibility
-----------------

The API of this package is align with scikit-learn.
The API of this library is align with scikit-learn.

.. |sklearn| image:: images/scikit-learn-logo-notext.png
:width: 100pt
Expand Down
17 changes: 16 additions & 1 deletion pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ download = "https://pypi.org/project/fastcan/#files"
tracker = "https://github.com/scikit-learn-contrib/fastcan/issues"

[project.optional-dependencies]
docs = ["furo", "matplotlib", "sphinx_gallery", "sphinx-design"]
docs = ["furo", "matplotlib", "sphinx_gallery", "sphinx-design", "sphinxcontrib-plantuml"]

[build-system]
requires = ["meson-python>=0.18.0", "Cython>=3.1.0", "scikit-learn>=1.7.0"]
Expand Down
18 changes: 18 additions & 0 deletions scripts/rtd_pre_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Stop and exit on error
set -euox pipefail

# Check for required tools
java -version
dot -V

# This folder is on PATH and does not require sudo
# Download latest plantuml.jar from github
curl -o ${READTHEDOCS_VIRTUALENV_PATH}/bin/plantuml.jar -L https://github.com/plantuml/plantuml/releases/latest/download/plantuml.jar
# Create an executable script for plantuml
printf '#!/bin/bash\nexec java -Djava.awt.headless=true -jar ${READTHEDOCS_VIRTUALENV_PATH}/bin/plantuml.jar "$@"' > ${READTHEDOCS_VIRTUALENV_PATH}/bin/plantuml
chmod +x ${READTHEDOCS_VIRTUALENV_PATH}/bin/plantuml

# Check plantuml version
plantuml -version
2 changes: 1 addition & 1 deletion tests/test_narx.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,4 +614,4 @@ def test_auto_reg():
)
model.fit(X, y)
y_pred = model.predict(X, y_init=y[: model.max_delay_])
assert r2_score(y, model.predict(X, y_init=y)) > 0.5
assert r2_score(y, y_pred) > 0.5
Loading