Created
June 30, 2021 14:56
-
-
Save Steboss89/60cd572ea0516c7d046dd8bddbfa17bd to your computer and use it in GitHub Desktop.
Linear regression in smartcore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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