feat: extends interface of Matrix to support for broad range of types

This commit is contained in:
Volodymyr Orlov
2020-03-26 15:28:26 -07:00
parent 84ffd331cd
commit 02b85415d9
27 changed files with 1021 additions and 868 deletions
+7 -5
View File
@@ -1,6 +1,8 @@
use crate::linalg::Matrix;
use std::fmt::Debug;
use crate::math::num::FloatExt;
use crate::linalg::Matrix;
#[derive(Debug)]
pub enum LinearRegressionSolver {
QR,
@@ -8,15 +10,15 @@ pub enum LinearRegressionSolver {
}
#[derive(Debug)]
pub struct LinearRegression<M: Matrix> {
pub struct LinearRegression<T: FloatExt + Debug, M: Matrix<T>> {
coefficients: M,
intercept: f64,
intercept: T,
solver: LinearRegressionSolver
}
impl<M: Matrix> LinearRegression<M> {
impl<T: FloatExt + Debug, M: Matrix<T>> LinearRegression<T, M> {
pub fn fit(x: &M, y: &M, solver: LinearRegressionSolver) -> LinearRegression<M>{
pub fn fit(x: &M, y: &M, solver: LinearRegressionSolver) -> LinearRegression<T, M>{
let b = y.transpose();
let (x_nrows, num_attributes) = x.shape();