Skip to content

Commit

Permalink
Prepare release
Browse files Browse the repository at this point in the history
  • Loading branch information
SandroMartens committed Feb 23, 2024
1 parent 20f90ac commit d51b506
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
15 changes: 10 additions & 5 deletions dbgsom/BaseSom.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

from typing_extensions import Self

from line_profiler import profile

# from matplotlib import pyplot as plt
# import matplotlib

Expand Down Expand Up @@ -938,10 +940,11 @@ def exponential_decay(
return sigma


@nb.njit(
# parallel=True,
fastmath=True
)
# @nb.njit(
# # parallel=True,
# fastmath=True
# )
@profile
def numba_voronoi_set_centers(winners: npt.NDArray, data: npt.NDArray, shape: tuple):
"""
Calculates the centers of the Voronoi regions based on the winners and data arrays.
Expand All @@ -968,7 +971,9 @@ def numba_voronoi_set_centers(winners: npt.NDArray, data: npt.NDArray, shape: tu
return voronoi_set_centers


@nb.njit(fastmath=True)
@nb.njit(fastmath=True,
# parallel=True,
)
def numba_quantization_error(
data: npt.NDArray, winners: npt.NDArray, length, weights: npt.NDArray
):
Expand Down
17 changes: 9 additions & 8 deletions dbgsom/SomClassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
check_is_fitted,
check_X_y,
)
from dbgsom.BaseSom import BaseSom
from .BaseSom import BaseSom


class SomClassifier(BaseSom, TransformerMixin, ClassifierMixin):
Expand Down Expand Up @@ -206,12 +206,13 @@ def predict_proba(self, X: npt.ArrayLike) -> np.ndarray:
sample_probabilities = np.array(probabilities_rows)

else:
X_transformed = self.transform(X)
node_probabilities = self._extract_values_from_graph("probabilities")
# Sample Probabilities do not sum to 1
sample_probabilities_unnormalized = X_transformed @ node_probabilities
sample_probabilities = sample_probabilities_unnormalized / (
sample_probabilities_unnormalized.sum(axis=1)[np.newaxis].T
)
pass
# X_transformed = self.transform(X)
# node_probabilities = self._extract_values_from_graph("probabilities")
# # Sample Probabilities do not sum to 1
# sample_probabilities_unnormalized = X_transformed @ node_probabilities
# sample_probabilities = sample_probabilities_unnormalized / (
# sample_probabilities_unnormalized.sum(axis=1)[np.newaxis].T
# )

return sample_probabilities
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
long_description = f.read()

setup(
name="dbgsom",
version="1.0.1",
name="DBGSOM",
version="1.1.0",
description="A directed batch growing approach to enhance the topology preservation of self-organizing maps ",
long_description=long_description,
author="Sandro Martens",
author_email="[email protected]",
license="MIT",
packages=["dbgsom"],
packages=["DBGSOM"],
install_requires=[
"numpy",
"networkx",
Expand Down

0 comments on commit d51b506

Please sign in to comment.