Skip to content

Commit

Permalink
Make compatible with pip packaging system
Browse files Browse the repository at this point in the history
  • Loading branch information
danjjl committed Jun 12, 2023
1 parent 3e442db commit d7e0c09
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 224 deletions.
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ Both methods are illustrated in the following figures :
![Illustration of sample based scoring.](https://user-images.githubusercontent.com/747240/244666630-cdfe12cc-22a2-4b23-be15-3e60dbedb437.png)
![Illustration of event based scoring.](https://user-images.githubusercontent.com/747240/244666619-8dd90008-79af-4836-8769-daa204bbe16c.png)

## Code
## Installation

The package can be installed through pip using the following command :

An example usage of the library is provided in `example.ipynb`.
`pip install timescoring`

## Code

The library provides three classes :
The `timescoring` package provides three classes :

- `annotation.Annotation` : store annotations
- `scoring.SampleScoring(ref, hyp)` : Compute sample based scoring
Expand Down Expand Up @@ -58,7 +62,7 @@ Scores are provided as attributes of the scoring class. The following metrics ca
```python
## Loading Annotations ##

from annotations import Annotation
from timescoring.annotations import Annotation

# Annotation objects can be instantiated from a binary mask

Expand All @@ -82,15 +86,15 @@ labels = Annotation(events, fs, numSamples)

## Computing performance score ##

import scoring
import visualization
from timescoring import scoring
from timescoring import visualization

fs = 1
duration = 66*60
ref = Annotation([(8*60, 12*60), (30*60, 35*60), (48*60, 50*60)], fs, duration)
hyp = Annotation([(8*60, 12*60), (28*60, 32*60), (50.5*60, 51*60), (60*60, 62*60)], fs, duration)
scores = scoring.SampleScoring(ref, hyp)
figSamples = visualization.plotSampleScoring(ref, hyp, param)
figSamples = visualization.plotSampleScoring(ref, hyp)

# Scores can also be computed per event
param = scoring.EventScoring.Parameters(
Expand Down
212 changes: 0 additions & 212 deletions example.ipynb

This file was deleted.

28 changes: 28 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "timescoring"
version = "0.0.1"
authors = [
{ name="Jonathan Dan", email="[email protected]" },
{ name="Una Pale", email="[email protected]" },
{ name="PEDESITE" }
]
description = "Library for measuring performance of time series classification"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"matplotlib>=3.7.1",
"numpy>=1.24.3 ",
"nptyping>=2.5.0"]
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
]

[project.urls]
"Homepage" = "https://github.com/esl-epfl/epilepsy_performance_metrics"
"Bug Tracker" = "https://github.com/esl-epfl/epilepsy_performance_metrics/issues"
Empty file added src/timescoring/__init__.py
Empty file.
File renamed without changes.
2 changes: 1 addition & 1 deletion scoring.py → src/timescoring/scoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import numpy as np

from annotations import Annotation
from .annotations import Annotation

class _Scoring:
"""" Base class for different scoring methods. The class provides the common
Expand Down
4 changes: 2 additions & 2 deletions visualization.py → src/timescoring/visualization.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import matplotlib.pyplot as plt
import numpy as np

from annotations import Annotation
import scoring
from .annotations import Annotation
from . import scoring

def plotSampleScoring(ref : Annotation, hyp : Annotation, fs : int = 1) -> plt.figure:
"""Build an overview plot showing the outcome of sample scoring.
Expand Down
4 changes: 2 additions & 2 deletions test.py → tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import numpy as np

from annotations import Annotation
import scoring
from src.timescoring.annotations import Annotation
from src.timescoring import scoring

class TestAnnotation(unittest.TestCase):
def assertListOfTupleEqual(expected, actual, message):
Expand Down

0 comments on commit d7e0c09

Please sign in to comment.