pub struct CounterfactualGenerator<F: Float + Debug> {
pub max_features: usize,
pub learning_rate: f64,
pub max_iterations: usize,
pub distance_metric: DistanceMetric,
pub original_predictions: HashMap<String, F>,
}
Expand description
Counterfactual explanation generator
Fields§
§max_features: usize
Maximum number of features to perturb
learning_rate: f64
Learning rate for optimization
max_iterations: usize
Maximum optimization iterations
distance_metric: DistanceMetric
Distance metric to use
original_predictions: HashMap<String, F>
Cache of original predictions
Implementations§
Source§impl<F> CounterfactualGenerator<F>
impl<F> CounterfactualGenerator<F>
Sourcepub fn new(
max_features: usize,
learning_rate: f64,
max_iterations: usize,
distance_metric: DistanceMetric,
) -> Self
pub fn new( max_features: usize, learning_rate: f64, max_iterations: usize, distance_metric: DistanceMetric, ) -> Self
Create a new counterfactual generator
Sourcepub fn generate_counterfactual(
&mut self,
original_input: &ArrayD<F>,
_target_prediction: F,
) -> Result<ArrayD<F>>
pub fn generate_counterfactual( &mut self, original_input: &ArrayD<F>, _target_prediction: F, ) -> Result<ArrayD<F>>
Generate counterfactual explanation
Sourcepub fn compute_distance(&self, input1: &ArrayD<F>, input2: &ArrayD<F>) -> f64
pub fn compute_distance(&self, input1: &ArrayD<F>, input2: &ArrayD<F>) -> f64
Compute distance between two inputs
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for CounterfactualGenerator<F>
impl<F> RefUnwindSafe for CounterfactualGenerator<F>where
F: RefUnwindSafe,
impl<F> Send for CounterfactualGenerator<F>where
F: Send,
impl<F> Sync for CounterfactualGenerator<F>where
F: Sync,
impl<F> Unpin for CounterfactualGenerator<F>where
F: Unpin,
impl<F> UnwindSafe for CounterfactualGenerator<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more