Function smartnoise_runtime::components::impute::impute_categorical_arrayd[][src]

pub fn impute_categorical_arrayd<T: Clone>(
    data: ArrayD<T>,
    categories: Vec<Vec<T>>,
    weights: Option<Vec<Vec<Float>>>,
    null_value: Vec<Vec<T>>,
    enforce_constant_time: bool
) -> Result<ArrayD<T>> where
    T: Clone + PartialEq + Default + Ord + Hash

Returns data with imputed values in place on null_value.

Arguments

Return

Data with null_value values replaced with imputed values.

Example

use ndarray::prelude::*;
use smartnoise_runtime::components::impute::impute_categorical_arrayd;
let data: ArrayD<String> = arr2(&[["a".to_string(), "b".to_string(), "null_3".to_string()],
                                  ["c".to_string(), "null_2".to_string(), "a".to_string()]]).into_dyn();
let categories: Vec<Vec<String>> = vec![vec!["a".to_string(), "c".to_string()],
                                        vec!["b".to_string(), "d".to_string()],
                                        vec!["f".to_string()]];
let weights = Some(vec![vec![1., 1.],
                        vec![1., 2.],
                        vec![1.]]);
let null_value: Vec<Vec<String>> = vec![vec!["null_1".to_string()],
                                        vec!["null_2".to_string()],
                                        vec!["null_3".to_string()]];

let imputed = impute_categorical_arrayd(data, categories, weights, null_value, false);