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

Function validate_search_data

crates/openquant/src/hyperparameter_tuning.rs:360–385  ·  view source on GitHub ↗
(data: &SearchData<'_>, n_splits: usize)

Source from the content-addressed store, hash-verified

358}
359
360fn validate_search_data(data: &SearchData<'_>, n_splits: usize) -> Result<(), String> {
361 if data.x.is_empty() {
362 return Err("x cannot be empty".to_string());
363 }
364 if data.y.is_empty() {
365 return Err("y cannot be empty".to_string());
366 }
367 if data.x.len() != data.y.len() {
368 return Err("x/y length mismatch".to_string());
369 }
370 if data.samples_info_sets.len() != data.x.len() {
371 return Err("samples_info_sets length must match x length".to_string());
372 }
373 if n_splits < 2 {
374 return Err("n_splits must be >= 2".to_string());
375 }
376 if let Some(sw) = data.sample_weight {
377 if sw.len() != data.y.len() {
378 return Err("sample_weight length mismatch".to_string());
379 }
380 if sw.iter().any(|w| *w < 0.0) {
381 return Err("sample_weight cannot contain negative values".to_string());
382 }
383 }
384 Ok(())
385}
386
387fn evaluate_params<C, F>(
388 build_classifier: &F,

Callers 1

search_over_paramsFunction · 0.85

Calls 2

is_emptyMethod · 0.80
lenMethod · 0.80

Tested by

no test coverage detected