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

swh:1:snp:7bb11892490e1dc1b1ff3be1d93f489dadb3e857
  • Code
  • Branches (1)
  • Releases (0)
    • Branches
    • Releases
    • HEAD
    • refs/heads/master
    No releases to show
  • 8306d99
  • /
  • test
  • /
  • score.py
Raw File Download
Permalinks

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.

  • content
  • directory
  • revision
  • snapshot
content badge Iframe embedding
swh:1:cnt:033d56b5ebe37d7033be9321aa17ea1db69a48db
directory badge Iframe embedding
swh:1:dir:892f10df507d1f9e5b4f08f94035d8aa1fa69841
revision badge
swh:1:rev:c5b693d0a66e83c9387433b33c0eab481bd4a763
snapshot badge
swh:1:snp:7bb11892490e1dc1b1ff3be1d93f489dadb3e857
Citations

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.

  • content
  • directory
  • revision
  • snapshot
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 ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: c5b693d0a66e83c9387433b33c0eab481bd4a763 authored by Wesley Tansey on 08 May 2020, 15:42:20 UTC
Fixed bug in easy that created too large a support for the alternative distribution
Tip revision: c5b693d
score.py
import sys
import numpy as np
import os.path


def tpr_fdr(truth, estimated):
    # Get the true positive and false discovery rate
    trues = truth == 1
    tpr = estimated[trues].sum() / float(trues.sum())
    discs = estimated == 1
    fdr = (1 - truth[discs]).sum() / float(discs.sum())
    return (tpr, fdr)


# Get the two signals, true and estimated
truth = np.loadtxt(sys.argv[1] + 'true_signals.csv', delimiter=',').flatten()
bh = np.loadtxt(sys.argv[1] + 'bh_discoveries.csv', delimiter=',').flatten()
fdrl = np.loadtxt(sys.argv[1] + 'fdrl_discoveries.csv', delimiter=',').flatten()
hmrf = np.loadtxt(sys.argv[1] + 'hmrf_discoveries.csv', delimiter=',').flatten()
sfdr = np.loadtxt(sys.argv[1] + 'sfdr_discoveries.csv', delimiter=',').flatten()
oracle = np.loadtxt(sys.argv[1] + 'oracle_discoveries.csv', delimiter=',').flatten()

bh_tpr, bh_fdr = tpr_fdr(truth, bh)
fdrl_tpr, fdrl_fdr = tpr_fdr(truth, fdrl)
hmrf_tpr, hmrf_fdr = tpr_fdr(truth, hmrf)
sfdr_tpr, sfdr_fdr = tpr_fdr(truth, sfdr)
oracle_tpr, oracle_fdr = tpr_fdr(truth, oracle)

if not os.path.isfile(sys.argv[2]):
    with open(sys.argv[2], 'wb') as f:
        f.write('BH_TPR,BH_FDR,FDRL_TPR,FDRL_FDR,HMRF_TPR,HMRF_FDR,SFDR_TPR,SFDR_FDR,ORACLE_TPR,ORACLE_FDR\n')

with open(sys.argv[2], 'a') as f:
    f.write('{0:.4f},{1:.4f},{2:.4f},{3:.4f},{4:.4f},{5:.4f},{6:.4f},{7:.4f},{8:.4f},{9:.4f}\n'.format(bh_tpr, bh_fdr, fdrl_tpr, fdrl_fdr, hmrf_tpr, hmrf_fdr, sfdr_tpr, sfdr_fdr, oracle_tpr, oracle_fdr))

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— Contact— JavaScript license information— Web API

back to top