Skip to content

Instantly share code, notes, and snippets.

@Steboss89
Created June 30, 2021 14:56
Show Gist options
  • Save Steboss89/60cd572ea0516c7d046dd8bddbfa17bd to your computer and use it in GitHub Desktop.
Save Steboss89/60cd572ea0516c7d046dd8bddbfa17bd to your computer and use it in GitHub Desktop.
Linear regression in smartcore
// train split
let (x_train, x_test, y_train, y_test) = train_test_split(&xmatrix.unwrap(), &y, 0.3, true);
// model
let linear_regression = LinearRegression::fit(&x_train, &y_train, Default::default()).unwrap();
// predictions
let preds = linear_regression.predict(&x_test).unwrap();
// metrics
let mse = mean_squared_error(&y_test, &preds);
println!("MSE: {:?}", mse);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment