Commit e863c9bb authored by lucas_miranda's avatar lucas_miranda
Browse files

Set default radius for latent entropy computation using an empirically derived linear equation

parent f4152036
......@@ -211,12 +211,12 @@ class neighbor_cluster_purity(tf.keras.callbacks.Callback):
"""
def __init__(
self, variational=True, validation_data=None, r=0.75, samples=10000, log_dir="."
self, r, variational=True, validation_data=None, samples=10000, log_dir="."
):
super().__init__()
self.r = r
self.variational = variational
self.validation_data = validation_data
self.r = r # Make radius default depend on encoding dimensions
self.samples = samples
self.log_dir = log_dir
......
......@@ -403,7 +403,7 @@ else:
phenotype_class=pheno_class,
predictor=predictor,
loss=loss,
logparam=None,
logparam=logparam,
outpath=output_path,
)
......
......@@ -75,8 +75,8 @@ def get_callbacks(
cp: bool = False,
reg_cat_clusters: bool = False,
reg_cluster_variance: bool = False,
entropy_samples: int = 10000,
entropy_radius: float = 0.75,
entropy_samples: int = 15000,
entropy_radius: float = None,
logparam: dict = None,
outpath: str = ".",
) -> List[Union[Any]]:
......@@ -113,7 +113,13 @@ def get_callbacks(
)
entropy = deepof.model_utils.neighbor_cluster_purity(
r=entropy_radius,
r=(
entropy_radius
if entropy_radius is not None
else 0.15 * logparam["encoding"]
- 0.18 # equation derived empirically to keep neighbor number constant.
# See examples/set_default_entropy_radius.ipynb for details
),
samples=entropy_samples,
validation_data=X_val,
log_dir=os.path.join(outpath, "metrics", run_ID),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment