Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Revision 45f6a33c0276fb344367de006252ba59881fe62b authored by Nicolas F. Chaves-de-Plaza on 11 December 2023, 10:25:31 UTC, committed by Nicolas F. Chaves-de-Plaza on 11 December 2023, 10:25:31 UTC
Updated documentation
1 parent c552d7b
  • Files
  • Changes
  • f3436ac
  • /
  • experiments_and_plots
  • /
  • plot_nearest_neighbor_perservation_per_theta_value_MNIST.py
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • revision
  • directory
  • content
revision badge
swh:1:rev:45f6a33c0276fb344367de006252ba59881fe62b
directory badge Iframe embedding
swh:1:dir:727b2b52c0867af9b12316adbb05d419f44ec1dd
content badge Iframe embedding
swh:1:cnt:d29a2ac8ebc6297d6e48980d2ddfbce1be570315

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • revision
  • directory
  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
plot_nearest_neighbor_perservation_per_theta_value_MNIST.py
"""
This script goes through the nearest neighbor preservation data generated by the
`data_generation_nearest_neighbor_preservation_per_theta_value_MNIST.py`
script and creates a plot with one precision/recall curve per theta value.
"""
###########
# IMPORTS #
###########

from pathlib import Path
import numpy as np
from matplotlib import pyplot as plt
from hyperbolicTSNE import Datasets

#################################
# GENERAL EXPERIMENT PARAMETERS #
#################################

BASE_DIR = "../results/nnp_per_theta_MNIST"

# Constants
dataset = Datasets.MNIST  # The dataset to run the experiment on

###################
# EXPERIMENT LOOP #
###################

# Save final embedding
fig, ax = plt.subplots()
ax.set_title("MNIST")
ax.set_xlabel('Precision')
ax.set_ylabel('Recall')

for theta in [x / 10 for x in range(0, 11, 1)]:  # Iterate over the different values for theta

    print(f"[nnp_per_theta] Processing {dataset}, Theta: {theta}")

    run_dir = Path(f"{BASE_DIR}/theta_{theta}/")

    precisions = np.load(run_dir.joinpath(f"precisions_theta_{theta}.npy"))
    recalls = np.load(run_dir.joinpath(f"recalls_theta_{theta}.npy"))

    ax.plot(precisions, recalls, label=f"{theta}")

ax.legend()
fig.savefig(Path(BASE_DIR).joinpath(f"{dataset}_prec-vs-rec_per_theta.png"))
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API