(y_true: Vec<i64>, y_pred: Vec<i64>)
| 202 | use crate::graphs::util::simple_context; |
| 203 | |
| 204 | fn test_helper(y_true: Vec<i64>, y_pred: Vec<i64>) -> Result<f64> { |
| 205 | let array_t = array_type(vec![y_true.len() as u64], INT64); |
| 206 | let c = simple_context(|g| { |
| 207 | let y_true = g.input(array_t.clone())?; |
| 208 | let y_pred = g.input(array_t)?; |
| 209 | g.custom_op( |
| 210 | CustomOperation::new(AucScore { |
| 211 | fp: FixedPrecisionConfig::default(), |
| 212 | }), |
| 213 | vec![y_true, y_pred], |
| 214 | ) |
| 215 | })?; |
| 216 | let mapped_c = run_instantiation_pass(c)?; |
| 217 | let result = random_evaluate( |
| 218 | mapped_c.get_context().get_main_graph()?, |
| 219 | vec![ |
| 220 | Value::from_flattened_array(&y_true, INT64)?, |
| 221 | Value::from_flattened_array(&y_pred, INT64)?, |
| 222 | ], |
| 223 | )?; |
| 224 | Ok(result.to_i64(INT64)? as f64 / FixedPrecisionConfig::default().denominator_f64()) |
| 225 | } |
| 226 | |
| 227 | #[test] |
| 228 | fn test_auc_simple_case() -> Result<()> { |
no test coverage detected