Core functions
Reference for compute_expectation_with_monte_carlo
Compute \(E_{p(x | C_i)} [p(x | C_j)]\) for all classes from samples with a monte carlo estimator. Args: data: [num_samples, n_features], the inputs target: [num_samples], the classes class_samples: [n_class, M, n_features], the M samples per class class_indices: [n_class, indices], the indices of samples per class n_class: The number of classes k_nearest: The number of neighbors for k-NN distance: Which distance metric to use
Returns:
Name | Type | Description |
---|---|---|
expectation |
Array
|
[n_class, n_class], matrix with probabilities |
similarity_arrays |
Dict[int, Dict[int, SimilarityArrays]]
|
[n_class, M, SimilarityArrays], dict of arrays with kNN class proportions, raw and normalized by the Parzen-window, accessed via class and sample indices |
Source code in spectral_metric/lib.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
Reference for find_samples
Find M samples per class Args: data: [num_samples, n_features], the inputs target: [num_samples], the classes n_class: The number of classes M: (int, float), Number or proportion of sample per class seed: seeding for sampling.
Returns: Selected items per class and their indices.
Source code in spectral_metric/lib.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|