rustyml 0.6.0

A high-performance machine learning library in pure Rust, offering statistical utilities, ML algorithms, and future support for neural networks and transformer architectures.
Documentation
# Changelog


All notable changes to this project will be documented in this file.
This change log records updates after 2025-3-24.

Please view [SomeB1oody/RustyML](https://github.com/SomeB1oody/RustyML) for more info.

## [v0.6.0] - 2025-5-5

### Added

- Add `get_weights` method across layers and `LayerWeight` enum

## [v0.6.0] - 2025-5-4

### Changed

- Refactor optimizer state handling with unified cache

## [v0.6.0] - 2025-5-3

### Added

- Ensure `fit` validates optimizer and layers before training

### Changed

- Refactor parameter updates to use parallel processing

### Removed

- Remove method `update_parameters` in `Layer` trait
- Remove getter methods from Dense layer

## [v0.6.0] - 2025-5-2

### Changed

- Refactor RMSprop implementation with unified cache structure

## [v0.6.0] - 2025-5-1

### Added

- Add detailed documentation and examples to neural network layers

### Changed

- Refactor layers to enforce explicit activation usage
- Optimize LSTM computations with parallel processing using Rayon
- Refactor LSTM to consolidate gate logic into reusable structures
- Refactor Adam optimizer state management into `AdamStates`

## [v0.6.0] - 2025-4-30

### Added

- Add doc comment for `LSTM`

### Removed

- Remove redundant method documentation comments

## [v0.6.0] - 2025-4-29

### Added

- Add LSTM layer initial implementation and associated tests

## [v0.6.0] - 2025-4-28

### Changed

Refactor traits in neural_network module definitions into traits module

## [v0.6.0] - 2025-4-27

### Added

- Add doc comment for traits module

## [v0.6.0] - 2025-4-26

### Changed

Refactor `LinearSVC` to use `RegularizationType` for penalties

## [v0.6.0] - 2025-4-25

### Changed

- Refactor regressors to use shared `RegressorCommonGetterFunctions` trait

## [v0.6.0] - 2025-4-24

### Added

- Add regularization support to linear and logistic regression

### Changed

- Refactor `KernelType` into machine_learning module

## [v0.5.1] - 2025-4-23

### Changed

- Modularize activation functions into a separate module

## [v0.5.1] - 2025-4-22

### Changed

- Optimize activation functions with parallel processing

## [v0.5.1] - 2025-4-21

### Changed

- Refactor optimizer implementations into separate files

## [v0.5.1] - 2025-4-20

### Changed

- Refactor loss functions into separate modules

## [v0.5.1] - 2025-4-19

### Added

- Add doc comments for layer `SimpleRNN`

## [v0.5.1] - 2025-4-18

### Changed

- Modularize `layer` into separate `dense` and `simple_rnn` modules

## [v0.5.1] - 2025-4-17

### Added

- Add `SimpleRNN` layer initial implementation

### Changed

- Use rand v0.9.1

## [v0.5.1] - 2025-4-16

### Changed

- Optimize neural network computations with parallelism

## [v0.5.1] - 2025-4-15

### Changed

- `ModelError` is used in the neural network implementation

## [v0.5.1] - 2025-4-14

### Changed

- Standardize documentation comments across modules

## [v0.5.0] - 2025-4-13

### Changed

- Replace `ndarray-linalg` with `nalgebra` for `PCA`, `LDA`, and `KernelPCA`

## [v0.5.0] - 2025-4-12

### Changed

- Refactor metrics API to remove `Result` usage and add panics

## [v0.5.0] - 2025-4-11

### Added

- Added getter methods for accessing key properties

### Changed

- Replaced public fields with private ones in `Dense`, `Adam`, and `RMSprop` structs to improve encapsulation.

## [v0.5.0] - 2025-4-10

### Added

- Add activation functions support to `Dense` layer

## [v0.4.0] - 2025-4-9

### Added

- Add RMSprop optimizer support to the neural network
- Add MAE(Mean Absolute Error) support in loss function computation
- Add doc comments for neural_network module

## [v0.4.0] - 2025-4-8

### Added

- Add `Adam` optimizer for neural network
- Added new loss functions: `CategoricalCrossEntropy` and `SparseCategoricalCrossEntropy`

### Changed

- Replaced slices with `ndarray`'s `ArrayView` to improve consistency and compatibility with numerical operations in metric module
- Refactor polynomial feature generation to exclude constant term

## [v0.4.0] - 2025-4-7

### Added

- Add neural network support(initial implementation)

## [v0.3.0] - 2025-4-6

### Added

- Add dataset module and put iris and diabetes datasets in it
- Enhance SVM/LDA documentation

## [v0.3.0] - 2025-4-5

### Changed

- Refactor to use `ArrayView` for memory-efficient data handling
- Refactor outputs to use `Array` instead of `Vec` in DBSCAN and KNN

## [v0.2.1] - 2025-4-4

### Added

- Add variance calculation in math module
- Add MSE calculation in metric module
- Print info after training completes for `fit` functions of struct `LDA`, `SVC`, `LinearSVC` and `PCA`
- Integrate Rayon for parallel computation across modules (**7 s faster** in `cargo test`!!!)

### Changed

- Refactor functions in math module and metric module to use `ArrayView1` for improved efficiency

### Removed

- Remove MSE calculation(named mean_squared_error, but actually calculate variance) in math module

## [v0.2.1] - 2025-4-3

### Added

- Add t-Distributed Stochastic Neighbor Embedding (t-SNE) implementation

### Changed

- Remove gaussian kernel calculation function, put gaussian kernel calculation directly in function `fit` of struct `MeanShift`

## [v0.2.1] - 2025-4-2

### Added

- Add LinearSVC support
- Add KernelPCA support
- Add `ProcessingError(String)` to `crate::ModelError` 
- Add LDA(Linear Discriminant Analysis) support

### Changed

- Change the location of function `standardize` from `crate::utility::principal_component_analysis` to `crate::utility`

## [v0.2.1] - 2025-4-1

### Added

- Add SVC(Support Vector Classification) support

## [v0.2.0] - 2025-4-1

### Added

- Add `train_test_split` function in utility module to split dataset for training and dataset for test
- Add function `normalized_mutual_info` and `adjusted_mutual_info` to metric module to calculate NMI and AMI info
- Add AUC-ROC value calculation in metric module

## [v0.2.0] - 2025-3-31

### Changed

- Change `principal_component_analysis` module to `utility` module, change `principal_component_analysis_test` module to `utility_test` module
- Keep the algorithm functions in the math module, and move the functions that evaluate the model's performance (such as R-square values) and structures (confusion matrices) to the metric module. Some of them are used in both ways, then keep them in both modules.
- Change the output of some of the functions in math module and metric module from `T` to `Result<T, crate::ModelError>`

## [v0.1.1] - 2025-3-31

### Added

- Add function `preliminary_check` in machine_learning module to performs validation checks on the input data matrices
- Add confusion matrix in math module

### Changed

- Change type of field `coefficients` of struct `LinearRegression` from `Option<Vec<f64>>` to `Option<Array1<f64>>`
- Change the output of some methods of struct `LinearRegression` from `Vec<f64>` to `Array1<f64>`
- Change variant `InputValidationError` of enum type `ModelError` from `InputValidationError(&str)` to `InputValidationError(String)`

## [v0.1.0] - 2025-3-30

### Added

- Add function `fit_predict` for some models
- Add examples for functions in math.rs
- Add input validation
- Add doc comments for machine learning modules
- Add prelude module(all re-exports are there)

### Changed

- Change input types of function `fit`, `predict` and `fit_predict` to `Array1` and `Array2`
- Rename the crate from `rust_ai` to `rustyml`
- Change the output of function `fit` from `&mut Self` to `Result<&mut Self, ModelError>` or `Result<&mut Self, Box<dyn std::error::Error>>`

## [v0.1.0] - 2025-3-29

### Added

- Add function `generate_tree_structure` for `DecisionTree` to generate tree structure as string
- Add isolation forest implementation
- Add PCA(Principal Component Analysis) implementation
- Add function `standard_deviation` in math module to calculates the standard deviation of a set of values

## [v0.1.0] - 2025-3-28

### Added

- Add Decision Tree model
- Add following functions to math.rs:
    - `entropy`: Calculates the entropy of a label set
    - `gini`: Calculates the Gini impurity of a label set
    - `information_gain`: Calculates the information gain when splitting a dataset
    - `gain_ratio`: Calculates the gain ratio for a dataset split
    - `mean_squared_error`: Calculates the Mean Squared Error (MSE) of a set of values

### Changed

- Replaced string-based distance calculation method options with an enum `crate::machine_learning::DistanceCalculation`
- For KNN model: replaced string-based weight function options with an enum `crate::machine_learning::knn::WeightingStrategy`
- For decision tree: replaced string-based algorithm options with an enum `crate::machine_learning::decision_tree::Algorithm`

## [v0.1.0] - 2025-3-27

### Added

- Add changelog.md to record updates
- Add DBSCAN model
- Add function `fit_predict` to fit and predict in one step
- Add doc comments to tell user `p` value of function `minkowski_distance` in model is always 3

## [v0.1.0] - 2025-3-26

### Added

- Add "xx model converged at iteration x, cost: x" when finishing `fit`
- Add description for `n_iter` field
- Add getter functions for `KMeans`
- implement `Default` trait for `KMeans`

### Changed

- Rename `max_iteration` and `tolerance` to `max_iter` and `tol`
- Change doc comments to enhanced consistency

### Removed

- Remove examples in math.rs(add them back later)

## [v0.1.0] - 2025-3-25

### Added

- Add MeanShift model
- Add `InputValidationError` in `ModelError`, indicating the input data provided  does not meet the expected format, type, or validation rules
- Add `gaussian_kernel` in math module, calculate the Gaussian kernel (RBF kernel)

### Changed

- Change the output of all `predict` functions(except KNN) from `T` to `Result<T, crate::ModelError>`
- Correct doc comments