Skip to content

Instantly share code, notes, and snippets.

@Steboss89
Created June 10, 2021 13:45
Show Gist options
  • Save Steboss89/16687c7293148470234084a77e5d584b to your computer and use it in GitHub Desktop.
Save Steboss89/16687c7293148470234084a77e5d584b to your computer and use it in GitHub Desktop.
linear Regression model in rusty_machine
// MODEL!
let mut linearRegression = LinRegressor::default();
// train
linearRegression.train(&x_train_matrix, &y_train_vector);
// predictions
let preds = linearRegression.predict(&x_test_matrix).unwrap();
// convert to matrix both preds and y_test
let preds_matrix = Matrix::new(test_size, 1, preds);
let y_preds_matrix = Matrix::new(test_size, 1, y_test);
// compute the mse
let mse = neg_mean_squared_error(&preds_matrix, &y_preds_matrix);
println!("Final negMSE (the higher the better) {:?}", mse);
// return the mse
mse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment