Removed sorting the training set for plotting as it isn't needed (anymore)

This commit is contained in:
lluni 2023-01-15 23:39:02 +01:00
parent b840dd6d8f
commit cd47bd7d12
Signed by: lluni
GPG key ID: ACEEB468BC325D35

View file

@ -79,20 +79,18 @@ fn main() -> Result<(), Box<dyn Error>> {
.draw()?;
// add the first plot
let mut data1: Vec<(f64,f64)> = x_test.iter().zip(y_test_true.iter())
let data1: Vec<(f64,f64)> = x_test.iter().zip(y_test_true.iter())
.map(|(x, y)| (x[0], y[0]))
.collect();
data1.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());
chart
.draw_series(LineSeries::new(data1, &RED)).unwrap()
.label("true values")
.legend(|(x, y)| PathElement::new(vec![(x, y), (x + 1, y)], &RED));
// add the second plot
let mut data2: Vec<(f64,f64)> = x_test.iter().zip(y_test_pred.iter())
let data2: Vec<(f64,f64)> = x_test.iter().zip(y_test_pred.iter())
.map(|(x, y)| (x[0], y[0]))
.collect();
data2.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());
chart
.draw_series(LineSeries::new(data2, &BLUE)).unwrap()
.label("predicted values")