(x: &[Vec<f64>], y: &[f64], feature_names: &[String])
| 246 | } |
| 247 | |
| 248 | fn validate_xy(x: &[Vec<f64>], y: &[f64], feature_names: &[String]) -> Result<(), String> { |
| 249 | if x.is_empty() || y.is_empty() { |
| 250 | return Err("x and y cannot be empty".to_string()); |
| 251 | } |
| 252 | if x.len() != y.len() { |
| 253 | return Err("x/y length mismatch".to_string()); |
| 254 | } |
| 255 | if x[0].len() != feature_names.len() { |
| 256 | return Err("feature_names length mismatch".to_string()); |
| 257 | } |
| 258 | if x.iter().any(|r| r.len() != x[0].len()) { |
| 259 | return Err("ragged x rows".to_string()); |
| 260 | } |
| 261 | Ok(()) |
| 262 | } |
| 263 | |
| 264 | fn rows(x: &[Vec<f64>], idx: &[usize]) -> Vec<Vec<f64>> { |
| 265 | idx.iter().map(|i| x[*i].clone()).collect() |
no test coverage detected