Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
YuhanLiin authored Aug 7, 2022
2 parents 47aae58 + 870107f commit a11b682
Show file tree
Hide file tree
Showing 173 changed files with 4,687 additions and 2,044 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/benching.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ jobs:
testing:
name: benching
runs-on: ubuntu-18.04
if: github.event.pull_request.draft == false
container:
image: rustmath/mkl-rust:1.43.0
options: --security-opt seccomp=unconfined

steps:
- name: Checkout sources
Expand All @@ -26,4 +22,4 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: bench
args: iai --all --features intel-mkl-system
args: iai --all
34 changes: 21 additions & 13 deletions .github/workflows/checking.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ name: Check For Build Errors

jobs:
check:
name: check
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
name: check-${{ matrix.toolchain }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
toolchain:
- 1.54.0
toolchain:
- 1.57.0
- stable
experimental: [false]
include:
- toolchain: nightly
experimental: true
continue-on-error: ${{ matrix.experimental }}
- nightly
os:
- ubuntu-latest
- windows-latest

continue-on-error: ${{ matrix.toolchain == 'nightly' }}

steps:
- name: Checkout sources
Expand All @@ -30,15 +30,23 @@ jobs:
toolchain: ${{ matrix.toolchain }}
override: true

- name: Log active toolchain
run: rustup show

# Check if linfa compiles by itself without uniting dependency features with other crates
- name: Run cargo check on linfa
uses: actions-rs/cargo@v1
with:
command: check

- name: Run cargo check (no features)
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace
args: --workspace --all-targets

- name: Run cargo check (with serde)
if: ${{ matrix.toolchain != '1.54.0' }} # The following args don't work on older versions of Cargo
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --features "linfa-clustering/serde linfa-ica/serde linfa-kernel/serde linfa-reduction/serde linfa-svm/serde linfa-elasticnet/serde linfa-pls/serde linfa-trees/serde linfa-nn/serde"
args: --workspace --all-targets --features "linfa-clustering/serde linfa-ica/serde linfa-kernel/serde linfa-reduction/serde linfa-svm/serde linfa-elasticnet/serde linfa-pls/serde linfa-trees/serde linfa-nn/serde"
8 changes: 2 additions & 6 deletions .github/workflows/codequality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ jobs:
codequality:
name: codequality
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
strategy:
matrix:
toolchain:
- 1.54.0
- 1.57.0
- stable

steps:
Expand Down Expand Up @@ -42,9 +41,6 @@ jobs:
name: coverage
runs-on: ubuntu-18.04
if: github.event.pull_request.draft == false
container:
image: rustmath/mkl-rust:1.43.0
options: --security-opt seccomp=unconfined

steps:
- name: Checkout sources
Expand Down Expand Up @@ -74,7 +70,7 @@ jobs:

- name: Generate code coverage
run: |
cargo tarpaulin --verbose --features intel-mkl-system --timeout 120 --out Xml --all --release
cargo tarpaulin --verbose --timeout 120 --out Xml --all --release
- name: Upload to codecov.io
uses: codecov/codecov-action@v1
with:
Expand Down
47 changes: 38 additions & 9 deletions .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ name: Run Tests

jobs:
testing:
name: testing
runs-on: ubuntu-18.04
if: github.event.pull_request.draft == false
container:
image: rustmath/mkl-rust:1.43.0
options: --security-opt seccomp=unconfined
name: testing-${{ matrix.toolchain }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
toolchain:
- 1.54.0
- 1.57.0
- stable
os:
- ubuntu-18.04
- windows-2019

steps:
- name: Checkout sources
Expand All @@ -28,8 +27,38 @@ jobs:
toolchain: ${{ matrix.toolchain }}
override: true

- name: Run cargo test in release mode
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --all --release --features intel-mkl-system
args: --release --workspace

testing-blas:
name: testing-with-BLAS-${{ matrix.toolchain }}-${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
toolchain:
- 1.57.0
- stable
os:
- ubuntu-18.04
- windows-2019

steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true

- name: Run cargo test with BLAS enabled
uses: actions-rs/cargo@v1
with:
command: test
args: --release --workspace --features intel-mkl-static,linfa-clustering/blas,linfa-ica/blas,linfa-reduction/blas,linfa-linear/blas,linfa-preprocessing/blas,linfa-pls/blas,linfa-elasticnet/blas
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
Version 0.6.0 - 2022-06-15
========================

New Algorithms
-----------
* Multinomial Naive Bayes added to `linfa-bayes` by [@sgrigory]
* Follow The Regularized Leader added as `linfa-ftrl` by [@MilaKyr]

Changes
-----------
* **BLAS backend no longer required to build Linfa**
* remove `SeedableRng` trait bound from `KMeans` and `GaussianMixture`
* replace uses of Isaac RNG with Xoshiro RNG

Breaking Changes
-----------
* parametrize `AsTargets` by the dimensionality of the targets and introduce `AsSingleTargets` and `AsMultiTargets`
* `Dataset` and `DatasetView` can now be parametrized by target dimensionality, with 2D being the default
* single-target algorithms no longer accept 2D target arrays as input
* `cross_validate` changed to `cross_validate_single`, `cross_validate_multi` changed to `cross_validate`
* `Pr` has been constrained to `0. <= prob <= 1.` with new constructors

Version 0.5.1 - 2022-02-28
========================

Note that the commits for this release are in the `0-5-1` branch.

Changes
-----------
* remove `Float` trait bound from many `Dataset` impls, making non-float datasets usable
* fix build errors in 0.5.0 caused by breaking minor releases from dependencies
* fix bug in k-means where the termination condition of the algorithm was calculated incorrectly
* fix build failure when building `linfa` alone, caused by incorrect feature selection for `ndarray`

Version 0.5.0 - 2021-10-20
========================

Expand Down
38 changes: 12 additions & 26 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[package]
name = "linfa"
version = "0.5.0"
version = "0.6.0"
authors = [
"Luca Palmieri <rust@lpalmieri.com>",
"Lorenz Schmidt <bytesnake@mailbox.org>",
"Paul Körbitz <koerbitz@google.com>"
"Paul Körbitz <koerbitz@google.com>",
"Yuhan Lin <yuhanliin@protonmail.com>"
]
description = "A Machine Learning framework for Rust"
edition = "2018"
Expand All @@ -21,14 +22,14 @@ exclude = [".github/"]
[features]
default = []

netlib-static = ["blas", "ndarray-linalg", "netlib-src/static"]
netlib-system = ["blas", "ndarray-linalg", "netlib-src/system"]
netlib-static = ["blas", "ndarray-linalg/netlib-static"]
netlib-system = ["blas", "ndarray-linalg/netlib-system"]

openblas-static = ["blas", "ndarray-linalg", "openblas-src/static"]
openblas-system = ["blas", "ndarray-linalg", "openblas-src/system"]
openblas-static = ["blas", "ndarray-linalg/openblas-static"]
openblas-system = ["blas", "ndarray-linalg/openblas-system"]

intel-mkl-static = ["blas", "ndarray-linalg", "intel-mkl-src/mkl-static-lp64-seq", "intel-mkl-src/download"]
intel-mkl-system = ["blas", "ndarray-linalg", "intel-mkl-src/mkl-dynamic-lp64-seq"]
intel-mkl-static = ["blas", "ndarray-linalg/intel-mkl-static"]
intel-mkl-system = ["blas", "ndarray-linalg/intel-mkl-system"]

blas = ["ndarray/blas"]

Expand All @@ -39,10 +40,12 @@ num-traits = "0.2"
rand = { version = "0.8", features = ["small_rng"] }
approx = "0.4"

ndarray = { version = "0.15", default-features = false, features = ["approx"] }
ndarray = { version = "0.15", features = ["approx"] }
ndarray-linalg = { version = "0.14", optional = true }

thiserror = "1.0"
# Temporary fix for compatibility issue between intel-mkl-tool and anyhow (https://github.com/rust-math/intel-mkl-src/issues/68)
anyhow = { version = "<=1.0.48" }

[dependencies.serde_crate]
package = "serde"
Expand All @@ -51,23 +54,6 @@ version = "1.0"
default-features = false
features = ["std", "derive"]

[dependencies.intel-mkl-src]
version = "0.6.0"
default-features = false
optional = true

[dependencies.netlib-src]
version = "0.8.0"
optional = true
features = ["cblas"]
default-features = false

[dependencies.openblas-src]
version = "0.10.4"
optional = true
default-features = false
features = ["cblas"]

[dev-dependencies]
ndarray-rand = "0.14"
linfa-datasets = { path = "datasets", features = ["winequality", "iris", "diabetes"] }
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,34 @@ Where does `linfa` stand right now? [Are we learning yet?](http://www.arewelearn
| [elasticnet](algorithms/linfa-elasticnet/) | Elastic Net | Tested | Supervised learning | Linear regression with elastic net constraints |
| [logistic](algorithms/linfa-logistic/) | Logistic regression | Tested | Partial fit | Builds two-class logistic regression models
| [reduction](algorithms/linfa-reduction/) | Dimensionality reduction | Tested | Pre-processing | Diffusion mapping and Principal Component Analysis (PCA) |
| [trees](algorithms/linfa-trees/) | Decision trees | Experimental | Supervised learning | Linear decision trees
| [trees](algorithms/linfa-trees/) | Decision trees | Tested / Benchmarked | Supervised learning | Linear decision trees
| [svm](algorithms/linfa-svm/) | Support Vector Machines | Tested | Supervised learning | Classification or regression analysis of labeled datasets |
| [hierarchical](algorithms/linfa-hierarchical/) | Agglomerative hierarchical clustering | Tested | Unsupervised learning | Cluster and build hierarchy of clusters |
| [bayes](algorithms/linfa-bayes/) | Naive Bayes | Tested | Supervised learning | Contains Gaussian Naive Bayes |
| [ica](algorithms/linfa-ica/) | Independent component analysis | Tested | Unsupervised learning | Contains FastICA implementation |
| [pls](algorithms/linfa-pls/) | Partial Least Squares | Tested | Supervised learning | Contains PLS estimators for dimensionality reduction and regression |
| [tsne](algorithms/linfa-tsne/) | Dimensionality reduction| Tested | Unsupervised learning | Contains exact solution and Barnes-Hut approximation t-SNE |
| [preprocessing](algorithms/linfa-preprocessing/) |Normalization & Vectorization| Tested | Pre-processing | Contains data normalization/whitening and count vectorization/tf-idf |
| [preprocessing](algorithms/linfa-preprocessing/) |Normalization & Vectorization| Tested / Benchmarked | Pre-processing | Contains data normalization/whitening and count vectorization/tf-idf |
| [nn](algorithms/linfa-nn/) | Nearest Neighbours & Distances | Tested / Benchmarked | Pre-processing | Spatial index structures and distance functions |
| [ftrl](algorithms/linfa-ftrl/) | Follow The Reguralized Leader - proximal | Tested / Benchmarked | Partial fit | Contains L1 and L2 regularization. Possible incremental update |

We believe that only a significant community effort can nurture, build, and sustain a machine learning ecosystem in Rust - there is no other way forward.

If this strikes a chord with you, please take a look at the [roadmap](https://github.com/rust-ml/linfa/issues/7) and get involved!

## BLAS/Lapack backend

At the moment you can choose between the following BLAS/LAPACK backends: `openblas`, `netblas` or `intel-mkl`
Some algorithm crates need to use an external library for linear algebra routines. By default, we use a pure-Rust implementation. However, you can also choose an external BLAS/LAPACK backend library instead, by enabling the `blas` feature and a feature corresponding to your BLAS backend. Currently you can choose between the following BLAS/LAPACK backends: `openblas`, `netblas` or `intel-mkl`.

|Backend | Linux | Windows | macOS |
|:--------|:-----:|:-------:|:-----:|
|OpenBLAS |✔️ |- |- |
|Netlib |✔️ |- |- |
|Intel MKL|✔️ |✔️ |✔️ |

For example if you want to use the system IntelMKL library for the PCA example, then pass the corresponding feature:
```
cd linfa-reduction && cargo run --release --example pca --features linfa/intel-mkl-system
```
This selects the `intel-mkl` system library as BLAS/LAPACK backend. On the other hand if you want to compile the library and link it with the generated artifacts, pass `intel-mkl-static`.
Each BLAS backend has two features available. The feature allows you to choose between linking the BLAS library in your system or statically building the library. For example, the features for the `intel-mkl` backend are `intel-mkl-static` and `intel-mkl-system`.

An example set of Cargo flags for enabling the Intel MKL backend on an algorithm crate is `--features blas,linfa/intel-mkl-system`. Note that the BLAS backend features are defined on the `linfa` crate, and should only be specified for the final executable.

# License
Dual-licensed to be compatible with the Rust project.
Expand Down
8 changes: 4 additions & 4 deletions algorithms/linfa-bayes/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "linfa-bayes"
version = "0.5.0"
version = "0.6.0"
authors = ["VasanthakumarV <vasanth260m12@gmail.com>"]
description = "Collection of Naive Bayes Algorithms"
edition = "2018"
Expand All @@ -11,12 +11,12 @@ keywords = ["factorization", "machine-learning", "linfa", "unsupervised"]
categories = ["algorithms", "mathematics", "science"]

[dependencies]
ndarray = { version = "0.15" , features = ["blas", "approx"]}
ndarray = { version = "0.15" , features = ["approx"]}
ndarray-stats = "0.5"
thiserror = "1.0"

linfa = { version = "0.5.0", path = "../.." }
linfa = { version = "0.6.0", path = "../.." }

[dev-dependencies]
approx = "0.4"
linfa-datasets = { version = "0.5.0", path = "../../datasets", features = ["winequality"] }
linfa-datasets = { version = "0.6.0", path = "../../datasets", features = ["winequality"] }
Loading

0 comments on commit a11b682

Please sign in to comment.