Created
December 21, 2021 03:35
-
-
Save jayhuang75/5053853a6e0fa704feba26980414018e to your computer and use it in GitHub Desktop.
go-train-delay-ml-pipeline-lr
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
| async fn linear_regression_model_build( | |
| &self, | |
| x: &DenseMatrix<f64>, | |
| y: &Vec<f64>, | |
| ) -> Result<String, AppError> { | |
| // train split | |
| let (x_train, _, y_train, _) = train_test_split(x, y, 0.3, true); | |
| // model | |
| let linear_regression_model = | |
| LinearRegression::fit(&x_train, &y_train, Default::default())?; | |
| let file_name = format!( | |
| "./models/go_train_delay_lr_{}.model", | |
| chrono::offset::Utc::now().date().to_string() | |
| ); | |
| // Save the model | |
| let linear_regression_model_bytes = bincode::serialize(&linear_regression_model)?; | |
| File::create(file_name.clone()) | |
| .and_then(|mut f| f.write_all(&linear_regression_model_bytes))?; | |
| Ok(file_name) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment