pub struct Matrix<T> { /* private fields */ }
Expand description

The Matrix struct.

Can be instantiated with any type.

Implementations

👎Deprecated

Compute the QR decomposition of the matrix.

Returns the tuple (Q,R).

Note: this function is deprecated in favor of HouseholderQr and will be removed in a future release.

Examples
use rulinalg::matrix::Matrix;

let m = matrix![1.0, 0.5, 0.5;
                0.5, 1.0, 0.5;
                0.5, 0.5, 1.0];

let (q, r) = m.qr_decomp().unwrap();
Failures
  • Cannot compute the QR decomposition.
👎Deprecated

Cholesky decomposition

Returns the cholesky decomposition of a positive definite matrix.

NOTE: This function is deprecated, and will be removed in a future release. Please see Cholesky for its replacement.

Examples
use rulinalg::matrix::Matrix;

let m = matrix![1.0, 0.5, 0.5;
                0.5, 1.0, 0.5;
                0.5, 0.5, 1.0];

let l = m.cholesky();
Panics
  • The matrix is not square.
Failures
  • Matrix is not positive definite.

Converts matrix to bidiagonal form

Returns (B, U, V), where B is bidiagonal and self = U B V_T.

Note that if self has self.rows() > self.cols() the matrix will be transposed and then reduced - this will lead to a sub-diagonal instead of super-diagonal.

Failures
  • The matrix cannot be reduced to bidiagonal form.

Singular Value Decomposition

Computes the SVD using the Golub-Reinsch algorithm.

Returns Σ, U, V, such that self = U Σ VT. Σ is a diagonal matrix whose elements correspond to the non-negative singular values of the matrix. The singular values are ordered in non-increasing order. U and V have orthonormal columns, and each column represents the left and right singular vectors for the corresponding singular value in Σ, respectively.

If self has M rows and N columns, the dimensions of the returned matrices are as follows.

If M >= N:

  • Σ: N x N
  • U: M x N
  • V: N x N

If M < N:

  • Σ: M x M
  • U: M x M
  • V: N x M

Note: This version of the SVD is sometimes referred to as the ‘economy SVD’.

Failures

This function may fail in some cases. The current decomposition whilst being efficient is fairly basic. Hopefully the algorithm can be made not to fail in the near future.

Returns H, where H is the upper hessenberg form.

If the transformation matrix is also required, you should use upper_hess_decomp.

Examples
use rulinalg::matrix::Matrix;

let a = matrix![2., 0., 1., 1.;
                2., 0., 1., 2.;
                1., 2., 0., 0.;
                2., 0., 1., 1.];
let h = a.upper_hessenberg();

println!("{:}", h.expect("Could not get upper Hessenberg form."));
Panics
  • The matrix is not square.
Failures
  • The matrix cannot be reduced to upper hessenberg form.

Returns (U,H), where H is the upper hessenberg form and U is the unitary transform matrix.

Note: The current transform matrix seems broken…

Examples
use rulinalg::matrix::BaseMatrix;

let a = matrix![1., 2., 3.;
                4., 5., 6.;
                7., 8., 9.];

// u is the transform, h is the upper hessenberg form.
let (u, h) = a.clone().upper_hess_decomp().expect("This matrix should decompose!");

assert_matrix_eq!(h, u.transpose() * a * u, comp = abs, tol = 1e-12);
Panics
  • The matrix is not square.
Failures
  • The matrix cannot be reduced to upper hessenberg form.
👎Deprecated

Computes L, U, and P for LUP decomposition.

Returns L,U, and P respectively.

This function is deprecated. Please see PartialPivLu for a replacement.

Examples
use rulinalg::matrix::Matrix;

let a = matrix![1.0, 2.0, 0.0;
                0.0, 3.0, 4.0;
                5.0, 1.0, 2.0];

let (l, u, p) = a.lup_decomp().expect("This matrix should decompose!");
Panics
  • Matrix is not square.
Failures
  • Matrix cannot be LUP decomposed.

Eigenvalues of a square matrix.

Returns a Vec of eigenvalues.

Examples
use rulinalg::matrix::Matrix;

let a = Matrix::new(4,4, (1..17).map(|v| v as f64).collect::<Vec<f64>>());
let e = a.eigenvalues().expect("We should be able to compute these eigenvalues!");
println!("{:?}", e);
Panics
  • The matrix is not square.
Failures
  • Eigenvalues cannot be computed.

Eigendecomposition of a square matrix.

Returns a Vec of eigenvalues, and a matrix with eigenvectors as the columns.

The eigenvectors are only gauranteed to be correct if the matrix is real-symmetric.

Examples
use rulinalg::matrix::Matrix;

let a = matrix![3., 2., 4.;
                2., 0., 2.;
                4., 2., 3.];

let (e, m) = a.eigendecomp().expect("We should be able to compute this eigendecomp!");
println!("{:?}", e);
println!("{:?}", m.data());
Panics
  • The matrix is not square.
Failures
  • The eigen decomposition can not be computed.

Constructor for Matrix struct.

Requires both the row and column dimensions.

Examples
use rulinalg::matrix::{Matrix, BaseMatrix};

let mat = Matrix::new(2,2, vec![1.0, 2.0, 3.0, 4.0]);

assert_eq!(mat.rows(), 2);
assert_eq!(mat.cols(), 2);
Panics
  • The input data does not match the given dimensions.

Constructor for Matrix struct that takes a function f and constructs a new matrix such that A_ij = f(j, i), where i is the row index and j the column index.

Requires both the row and column dimensions as well as a generating function.

Examples
use rulinalg::matrix::{Matrix, BaseMatrix};

// Let's assume you have an array of "things" for
// which you want to generate a distance matrix:
let things: [i32; 3] = [1, 2, 3];
let distances: Matrix<f64> = Matrix::from_fn(things.len(), things.len(), |col, row| {
    (things[col] - things[row]).abs().into()
});

assert_eq!(distances.rows(), 3);
assert_eq!(distances.cols(), 3);
assert_eq!(distances.data(), &vec![
    0.0, 1.0, 2.0,
    1.0, 0.0, 1.0,
    2.0, 1.0, 0.0,
]);
Warning

This function will be changed in a future release so that A_ij = f(i, j) - to be consistent with the rest of the library.

Returns a non-mutable reference to the underlying data.

Returns a mutable slice of the underlying data.

Consumes the Matrix and returns the Vec of data.

Constructs matrix of all zeros.

Requires both the row and the column dimensions.

Examples
use rulinalg::matrix::Matrix;

let mat = Matrix::<f64>::zeros(2,3);

Constructs matrix with given diagonal.

Requires slice of diagonal elements.

Examples
use rulinalg::matrix::Matrix;

let mat = Matrix::from_diag(&vec![1.0,2.0,3.0,4.0]);

Constructs matrix of all ones.

Requires both the row and the column dimensions.

Examples
use rulinalg::matrix::Matrix;

let mat = Matrix::<f64>::ones(2,3);

Constructs the identity matrix.

Requires the size of the matrix.

Examples
use rulinalg::matrix::Matrix;

let I = Matrix::<f64>::identity(4);

The mean of the matrix along the specified axis.

  • Axis Row - Arithmetic mean of rows.
  • Axis Col - Arithmetic mean of columns.

Calling mean() on an empty matrix will return an empty matrix.

Examples
use rulinalg::matrix::{Matrix, Axes};

let a = matrix![1.0, 2.0;
                3.0, 4.0];

let c = a.mean(Axes::Row);
assert_eq!(c, vector![2.0, 3.0]);

let d = a.mean(Axes::Col);
assert_eq!(d, vector![1.5, 3.5]);

The variance of the matrix along the specified axis.

  • Axis Row - Sample variance of rows.
  • Axis Col - Sample variance of columns.
Examples
use rulinalg::matrix::{Matrix, Axes};

let a = matrix![1.0, 2.0;
                3.0, 4.0];

let c = a.variance(Axes::Row).unwrap();
assert_eq!(c, vector![2.0, 2.0]);

let d = a.variance(Axes::Col).unwrap();
assert_eq!(d, vector![0.5, 0.5]);
Failures
  • There are one or fewer row/columns in the working axis.

Solves the equation Ax = y.

Requires a Vector y as input.

The method performs an LU decomposition internally, consuming the matrix in the process. If solving the same system for multiple right-hand sides is desired, see PartialPivLu.

Examples
use rulinalg::matrix::Matrix;
use rulinalg::vector::Vector;

let a = matrix![2.0, 3.0;
                1.0, 2.0];
let y = vector![13.0, 8.0];

let x = a.solve(y).unwrap();

assert_eq!(x, vector![2.0, 3.0]);
Panics
  • The matrix column count and vector size are different.
  • The matrix is not square.
Failures
  • The matrix cannot be decomposed into an LUP form to solve.
  • There is no valid solution as the matrix is singular.

Computes the inverse of the matrix.

Internally performs an LU decomposition.

Examples
use rulinalg::matrix::Matrix;

let a = matrix![2., 3.;
                1., 2.];
let inv = a.clone().inverse().expect("This matrix should have an inverse!");

let I = a * inv;

assert_matrix_eq!(I, matrix![1.0, 0.0; 0.0, 1.0]);
Panics
  • The matrix is not square.
Failures
  • The matrix could not be LUP decomposed.
  • The matrix has zero determinant.

Computes the determinant of the matrix.

Examples
let a = matrix![1.0, 2.0, 0.0;
                0.0, 3.0, 4.0;
                5.0, 1.0, 2.0];

let det = a.det();
Panics
  • The matrix is not square.

Attempts to convert the matrix into a new matrix of different scalar type.

Failures
  • One or more of the elements in the matrix cannot be converted into the new type.

Trait Implementations

Performs elementwise addition between two matrices.

This will reuse allocated memory from self.

The resulting type after applying the + operator.
Performs the + operation. Read more

Scalar addition with matrix.

Will reuse the memory allocated for the existing matrix.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between two matrices.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Scalar addition with matrix.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between two matrices.

This will reuse allocated memory from m.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between two matrices.

This will reuse allocated memory from self.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition between Matrix and MatrixSlice.

The resulting type after applying the + operator.
Performs the + operation. Read more

Scalar addition with matrix.

The resulting type after applying the + operator.
Performs the + operation. Read more

Scalar addition with matrix.

Will reuse the memory allocated for the existing matrix.

The resulting type after applying the + operator.
Performs the + operation. Read more

Performs elementwise addition assignment between two matrices.

Performs the += operation. Read more

Performs addition assignment between a matrix and a scalar.

Performs the += operation. Read more

Performs elementwise addition assignment between two matrices.

Performs the += operation. Read more

Performs elementwise addition assignment between two matrices.

Performs the += operation. Read more

Performs elementwise addition assignment between two matrices.

Performs the += operation. Read more

Performs elementwise addition assignment between two matrices.

Performs the += operation. Read more

Performs elementwise addition assignment between two matrices.

Performs the += operation. Read more

Performs elementwise addition assignment between two matrices.

Performs the += operation. Read more

Performs elementwise addition assignment between two matrices.

Performs the += operation. Read more

Performs addition assignment between a matrix and a scalar.

Performs the += operation. Read more
Rows in the matrix.
Columns in the matrix.
Row stride in the matrix.
Returns true if the matrix contais no elements
Top left index of the matrix.
Convert the matrix struct into a owned Matrix.
The sum of all elements in the matrix Read more
The elementwise product of two matrices. Read more
The elementwise division of two matrices. Read more
Vertically concatenates two matrices. With self on top. Read more
Returns a MatrixSlice over the whole matrix. Read more
Get a reference to an element in the matrix without bounds checking.
Get a reference to an element in the matrix. Read more
Returns the column of a matrix at the given index. None if the index is out of bounds. Read more
Returns the column of a matrix at the given index without doing a bounds check. Read more
Returns the row of a matrix at the given index. Read more
Returns the row of a matrix at the given index without doing unbounds checking Read more
Returns an iterator over the matrix data. Read more
Iterate over the columns of the matrix. Read more
Iterate over the rows of the matrix. Read more
Iterate over diagonal entries Read more
Compute the metric distance between two matrices. Read more
Extract the diagonal of the matrix Read more
Split the matrix at the specified axis returning two MatrixSlices. Read more
Produce a MatrixSlice from an existing matrix. Read more

Top left index of the slice.

Returns a MatrixSliceMut over the whole matrix. Read more
Get a mutable reference to an element in the matrix without bounds checks.
Get a mutable reference to an element in the matrix. Read more
Returns a mutable iterator over the matrix. Read more
Returns a mutable reference to the column of a matrix at the given index. None if the index is out of bounds. Read more
Returns a mutable reference to the column of a matrix at the given index without doing a bounds check. Read more
Returns a mutable reference to the row of a matrix at the given index. None if the index is out of bounds. Read more
Returns a mutable reference to the row of a matrix at the given index without doing a bounds check. Read more
Swaps two rows in a matrix. Read more
Swaps two columns in a matrix. Read more
Iterate over the mutable columns of the matrix. Read more
Iterate over the mutable rows of the matrix. Read more
Iterate over diagonal entries mutably Read more
Split the matrix at the specified axis returning two MatrixSliceMuts. Read more
Produce a MatrixSliceMut from an existing matrix. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
The cost function.
The gradient of the cost function.
The cost function.
The gradient of the cost function.
Formats the value using the given formatter. Read more

Formats the Matrix for display.

Scalar division with matrix.

Will reuse the memory allocated for the existing matrix.

The resulting type after applying the / operator.
Performs the / operation. Read more

Scalar division with matrix.

The resulting type after applying the / operator.
Performs the / operation. Read more

Scalar division with matrix.

The resulting type after applying the / operator.
Performs the / operation. Read more

Scalar division with matrix.

Will reuse the memory allocated for the existing matrix.

The resulting type after applying the / operator.
Performs the / operation. Read more

Performs division assignment between a matrix and a scalar.

Performs the /= operation. Read more

Performs division assignment between a matrix and a scalar.

Performs the /= operation. Read more
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Creates a Matrix from an iterator over slices.

Each of the slices produced by the iterator will become a row in the matrix.

Panics

Will panic if the iterators items do not have constant length.

Examples

We can create a new matrix from some data.

use rulinalg::matrix::{Matrix, BaseMatrix};

let a : Matrix<f64> = vec![4f64; 16].chunks(4).collect();

assert_eq!(a.rows(), 4);
assert_eq!(a.cols(), 4);

We can also do more interesting things.

use rulinalg::matrix::{Matrix, BaseMatrix};

let a = Matrix::new(4,2, (0..8).collect::<Vec<usize>>());

// Here we skip the first row and take only those
// where the first entry is less than 6.
let b = a.row_iter()
         .skip(1)
         .filter(|x| x[0] < 6)
         .collect::<Matrix<usize>>();

// We take the middle rows
assert_eq!(b.into_vec(), vec![2,3,4,5]);
Creates a value from an iterator. Read more
Creates a value from an iterator. Read more
Creates a value from an iterator. Read more
Feeds this value into the given [Hasher]. Read more
Feeds a slice of this type into the given [Hasher]. Read more

Indexes matrix.

Takes row index first then column.

The returned type after indexing.
Performs the indexing (container[index]) operation. Read more

Indexes mutable matrix.

Takes row index first then column.

Performs the mutable indexing (container[index]) operation. Read more
Maps the inputs using the inverse of the fitted transform.
Maps the inputs using the inverse of the fitted transform.

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Right-multiply a matrix by a permutation matrix.

The resulting type after applying the * operator.
Performs the * operation. Read more

Scalar multiplication with matrix.

Will reuse the memory allocated for the existing matrix.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies matrix by vector.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Right-multiply a matrix by a permutation matrix.

The resulting type after applying the * operator.
Performs the * operation. Read more

Scalar multiplication with matrix.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies matrix by vector.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies two matrices together.

The resulting type after applying the * operator.
Performs the * operation. Read more

Right-multiply a matrix by a permutation matrix.

The resulting type after applying the * operator.
Performs the * operation. Read more

Right-multiply a matrix by a permutation matrix.

The resulting type after applying the * operator.
Performs the * operation. Read more

Scalar multiplication with matrix.

The resulting type after applying the * operator.
Performs the * operation. Read more

Scalar multiplication with matrix.

Will reuse the memory allocated for the existing matrix.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies matrix by vector.

The resulting type after applying the * operator.
Performs the * operation. Read more

Multiplies matrix by vector.

The resulting type after applying the * operator.
Performs the * operation. Read more

Performs multiplication assignment between a matrix and a scalar.

Performs the *= operation. Read more

Performs multiplication assignment between a matrix and a scalar.

Performs the *= operation. Read more

Gets negative of matrix.

The resulting type after applying the - operator.
Performs the unary - operation. Read more

Gets negative of matrix.

The resulting type after applying the - operator.
Performs the unary - operation. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Performs elementwise subtraction between two matrices.

This will reuse allocated memory from self.

The resulting type after applying the - operator.
Performs the - operation. Read more

Scalar subtraction with matrix.

Will reuse the memory allocated for the existing matrix.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between two matrices.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Scalar subtraction with matrix.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between two matrices.

This will reuse allocated memory from m.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between two matrices.

This will reuse allocated memory from self.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction between Matrix and MatrixSlice.

The resulting type after applying the - operator.
Performs the - operation. Read more

Scalar subtraction with matrix.

The resulting type after applying the - operator.
Performs the - operation. Read more

Scalar subtraction with matrix.

Will reuse the memory allocated for the existing matrix.

The resulting type after applying the - operator.
Performs the - operation. Read more

Performs elementwise subtraction assignment between two matrices.

Performs the -= operation. Read more

Performs subtraction assignment between a matrix and a scalar.

Performs the -= operation. Read more

Performs elementwise subtraction assignment between two matrices.

Performs the -= operation. Read more

Performs elementwise subtraction assignment between two matrices.

Performs the -= operation. Read more

Performs elementwise subtraction assignment between two matrices.

Performs the -= operation. Read more

Performs elementwise subtraction assignment between two matrices.

Performs the -= operation. Read more

Performs elementwise subtraction assignment between two matrices.

Performs the -= operation. Read more

Performs elementwise subtraction assignment between two matrices.

Performs the -= operation. Read more

Performs elementwise subtraction assignment between two matrices.

Performs the -= operation. Read more

Performs subtraction assignment between a matrix and a scalar.

Performs the -= operation. Read more

Train and predict from the Naive Bayes model.

The input matrix must be rows made up of features. The target matrix should have indicator vectors in each row specifying the input class. e.g. [[1,0,0],[0,0,1]] shows class 1 first, then class 3.

Train the model using inputs and targets.

Predict output from inputs.

Supervised learning for the Neural Network.

The model is trained using back propagation.

Predict neural network output using forward propagation.

Train the model using gradient optimization and back propagation.

Predict output from inputs.

Train the model using data and outputs.

Supervised model trait for the GLM.

Predictions are made from the model by computing g^-1(Xb).

The model is trained using Iteratively Re-weighted Least Squares.

Predict output from inputs.

Train the model using inputs and targets.

Train the linear regression model.

Takes training data and output values as input.

Examples
use rusty_machine::learning::lin_reg::LinRegressor;
use rusty_machine::linalg::Matrix;
use rusty_machine::linalg::Vector;
use rusty_machine::learning::SupModel;

let mut lin_mod = LinRegressor::default();
let inputs = Matrix::new(3,1, vec![2.0, 3.0, 4.0]);
let targets = Vector::new(vec![5.0, 6.0, 7.0]);

lin_mod.train(&inputs, &targets).unwrap();

Predict output value from input data.

Model must be trained before prediction can be made.

Train the logistic regression model.

Takes training data and output values as input.

Examples
use rusty_machine::learning::logistic_reg::LogisticRegressor;
use rusty_machine::linalg::Matrix;
use rusty_machine::linalg::Vector;
use rusty_machine::learning::SupModel;

let mut logistic_mod = LogisticRegressor::default();
let inputs = Matrix::new(3,2, vec![1.0, 2.0, 1.0, 3.0, 1.0, 4.0]);
let targets = Vector::new(vec![5.0, 6.0, 7.0]);

logistic_mod.train(&inputs, &targets).unwrap();

Predict output value from input data.

Model must be trained before prediction can be made.

Train the model using the Pegasos algorithm and predict the model output from new data.

Predict output from inputs.
Train the model using inputs and targets.
Predict output from inputs.
Train the model using inputs and targets.
Fit the inputs to create the Transformer
Fit the inputs to create the Transformer
Transforms the inputs
Transforms the inputs

The Shuffler will transform the input Matrix by shuffling its rows in place.

Under the hood this uses a Fisher-Yates shuffle.

Transforms the inputs
Transforms the inputs

Train the model using inputs.

Predict output from inputs.

Train the model and predict the model output from new data.

Predict output from inputs.
Train the model using inputs.

Train the classifier using input data.

Predict output from inputs.

Predict classes from data.

Model must be trained.

Train the classifier using input data.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.