Skip to content

Commit

Permalink
updates to plot journal knees
Browse files Browse the repository at this point in the history
  • Loading branch information
mariolpantunes committed Jan 23, 2025
1 parent e1bf33e commit 0d368aa
Show file tree
Hide file tree
Showing 6 changed files with 479 additions and 496 deletions.
563 changes: 272 additions & 291 deletions docs/kneeliverse/clustering.html

Large diffs are not rendered by default.

397 changes: 200 additions & 197 deletions docs/kneeliverse/convex_hull.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/search.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/plot_journal_knees.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def main(args):

points = np.genfromtxt(args.i, delimiter=',')
logger.info(f'Loading {args.i} file ({len(points)})...')
reduced, removed = rdp.mp_grdp(points, t=0.001, min_points=20)
reduced, removed = rdp.mp_grdp(points, t=0.0001, min_points=20)
space_saving = round((1.0-(len(reduced)/len(points)))*100.0, 2)
logger.info('Number of data points after RDP: %s(%s %%)', len(reduced), space_saving)

Expand Down
4 changes: 0 additions & 4 deletions src/kneeliverse/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@


import math
import logging
import numpy as np


logger = logging.getLogger(__name__)


def single_linkage(points: np.ndarray, t: float = 0.01) -> np.ndarray:
"""
Computes the 1D clustering of the input points.
Expand Down
7 changes: 5 additions & 2 deletions src/kneeliverse/convex_hull.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,14 @@ def _ccw(a:np.ndarray, b:np.ndarray, c:np.ndarray) -> float:
return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1])


def _dist_points(pi, pj):
def _dist_points(pi, pj) -> np.ndarray:
"""
Compute the distance between two points ($p_i$, $p_j$)
"""
return np.linalg.norm(pi - pj)


def _compare_points(p0, pi, pj):
def _compare_points(p0, pi, pj) -> int:
o = _ccw(p0, pi, pj)
if o == 0:
return -1 if _dist_points(p0, pj) >= _dist_points(p0, pi) else 1
Expand Down

0 comments on commit 0d368aa

Please sign in to comment.