Nabla-ML
Nabla-ML is a Rust library inspired by NumPy, providing a multi-dimensional array implementation with various mathematical and array manipulation functionalities.
Features
- Array Creation: Create 1D and 2D arrays using vectors and matrices.
- Random Arrays: Generate arrays with random numbers, including uniform and normal distributions.
- Arithmetic Operations: Perform element-wise addition, subtraction, multiplication, and division.
- Mathematical Functions: Apply functions like square root, exponential, sine, cosine, logarithm, hyperbolic tangent, ReLU, Leaky ReLU, and Sigmoid to arrays.
- Array Reshaping: Change the shape of arrays while maintaining data integrity.
- File I/O: Save and load arrays in a compressed format.
- Linear Regression: Perform linear regression using gradient descent.
- MNIST Dataset Handling: Convert and load MNIST data for machine learning tasks.
Usage
Array Creation
use NDArray;
let arr = from_vec;
let matrix = from_matrix;
Random Arrays
use NDArray;
let random_array = randn;
let random_matrix = randn_2d;
Mathematical Functions
use NDArray;
let arr = from_vec;
let sqrt_arr = arr.sqrt;
let exp_arr = arr.exp;
let tanh_arr = arr.tanh;
let relu_arr = arr.relu;
let leaky_relu_arr = arr.leaky_relu;
let sigmoid_arr = arr.sigmoid;
File I/O with .nab Format
use ;
let array = from_vec;
save_nab.expect;
let loaded_array = load_nab.expect;
assert_eq!;
assert_eq!;
Linear Regression
use NDArray;
let X = from_matrix;
let y = from_vec;
let = linear_regression;
println!;
MNIST Dataset Handling
use NDArray;
mnist_csv_to_nab.expect;
let =
load_and_split_dataset.expect;
Mnist dataset in .nab format can be found here
One-Hot Encoding
use NDArray;
// Convert labels to one-hot encoded format
let labels = vec!;
let one_hot = one_hot_encode;
// Result will be a 2D NDArray:
// [1, 0, 0] # Class 0
// [0, 1, 0] # Class 1
// [0, 0, 1] # Class 2
// [0, 1, 0] # Class 1
// [1, 0, 0] # Class 0
License
This project is licensed under the AGPL-3.0 License - see the LICENSE file for details.