basic_usage/
basic_usage.rs1use linear_ransac::{RansacSolver, Point};
2
3fn main() {
4 let data = vec![
6 Point::new(1.0, 3.0), Point::new(2.0, 5.0), Point::new(3.0, 7.0), Point::new(4.0, 9.0), Point::new(2.5, 50.0), Point::new(3.5, -10.0), Point::new(5.0, 11.0), ];
14
15 let result = RansacSolver::new()
17 .with_seed(123)
18 .fit(&data);
19
20 match result {
22 Ok(model) => {
23 println!("Succcess!");
24 println!("y = {:.2}x + {:.2}", model.slope, model.intercept);
25 println!("Prediction for x=10: {}", model.predict(10.0));
27 },
28 Err(e) => println!("RANSAC failed: {}", e),
29 }
30}