MCPcopy Create free account
hub / github.com/Open-Quant/openquant / validate_xy

Function validate_xy

crates/openquant/src/feature_importance.rs:248–262  ·  view source on GitHub ↗
(x: &[Vec<f64>], y: &[f64], feature_names: &[String])

Source from the content-addressed store, hash-verified

246}
247
248fn 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
264fn rows(x: &[Vec<f64>], idx: &[usize]) -> Vec<Vec<f64>> {
265 idx.iter().map(|i| x[*i].clone()).collect()

Callers 2

mean_decrease_accuracyFunction · 0.85

Calls 2

is_emptyMethod · 0.80
lenMethod · 0.80

Tested by

no test coverage detected