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()?; .draw()?;
// add the first plot // 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])) .map(|(x, y)| (x[0], y[0]))
.collect(); .collect();
data1.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());
chart chart
.draw_series(LineSeries::new(data1, &RED)).unwrap() .draw_series(LineSeries::new(data1, &RED)).unwrap()
.label("true values") .label("true values")
.legend(|(x, y)| PathElement::new(vec![(x, y), (x + 1, y)], &RED)); .legend(|(x, y)| PathElement::new(vec![(x, y), (x + 1, y)], &RED));
// add the second plot // 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])) .map(|(x, y)| (x[0], y[0]))
.collect(); .collect();
data2.sort_by(|a, b| a.0.partial_cmp(&b.0).unwrap());
chart chart
.draw_series(LineSeries::new(data2, &BLUE)).unwrap() .draw_series(LineSeries::new(data2, &BLUE)).unwrap()
.label("predicted values") .label("predicted values")