Skip to content

Instantly share code, notes, and snippets.

View rmazzine's full-sized avatar
🎯
Focusing

Raphael Mazzine, PhD rmazzine

🎯
Focusing
View GitHub Profile
@rmazzine
rmazzine / requirements.txt
Created May 8, 2022 09:38
Python Packages For DiCE loop problem
absl-py==1.0.0
alabaster==0.7.12
albumentations==0.1.12
altair==4.2.0
appdirs==1.4.4
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
arviz==0.12.0
astor==0.8.1
astropy==4.3.1
@rmazzine
rmazzine / simple_cf_gen.py
Last active July 13, 2021 11:16
Simple Counterfactual Generator
import numpy as np
def simple_cf_generator(factual_oh, adapted_nn, tolerance=100):
# Get the current prediction result of the factual class
current_pred = adapted_nn.predict(np.array([factual_oh]))[0][0]
# The predictor will always start with a probability lower than 0.5
if current_pred < 0.5:
predictor = adapted_nn.predict
else:
predictor = lambda x: 1 - adapted_nn(x)