use millwright::prelude::*;
fn main() -> Result<()> {
let features = Frame::from_rows(
vec![
vec![0.0, 0.1],
vec![0.4, 0.2],
vec![0.2, 0.5],
vec![9.0, 9.1],
vec![9.4, 8.7],
vec![8.8, 9.5],
],
vec!["a".into(), "b".into()],
)?;
let train = Dataset::new(features.clone(), vec![0.0, 0.0, 0.0, 1.0, 1.0, 1.0])?;
let mut pipe = Pipeline::new()
.step("scale", StandardScaler::new())
.estimator("rf", RandomForest::new());
pipe.set_param("rf__n_trees", ParamValue::Int(50))?;
pipe.set_param("rf__max_depth", ParamValue::Int(4))?;
pipe.fit(&train)?;
println!("pipeline steps: {:?}", pipe.step_names());
let test = Frame::from_rows(
vec![vec![0.3, 0.2], vec![9.1, 9.0]],
vec!["a".into(), "b".into()],
)?;
let preds = pipe.predict(&test)?;
println!("predictions: {preds:?}");
assert_eq!(preds, vec![0.0, 1.0]);
println!("ok — the spine holds.");
Ok(())
}