diff options
-rw-r--r-- | src/python/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/python/example/ex_diagrams.py (renamed from src/cython/example/ex_diagrams.py) | 21 | ||||
-rw-r--r-- | src/python/gudhi/sktda/__init__.py | 6 | ||||
-rw-r--r-- | src/python/gudhi/sktda/kernel_methods.py (renamed from src/cython/sktda/kernel_methods.py) | 0 | ||||
-rw-r--r-- | src/python/gudhi/sktda/metrics.py (renamed from src/cython/sktda/metrics.py) | 5 | ||||
-rw-r--r-- | src/python/gudhi/sktda/preprocessing.py (renamed from src/cython/sktda/preprocessing.py) | 0 | ||||
-rw-r--r-- | src/python/gudhi/sktda/vector_methods.py (renamed from src/cython/sktda/vector_methods.py) | 0 |
7 files changed, 19 insertions, 15 deletions
diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 9e128d30..26cd6ec1 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -49,6 +49,7 @@ if(PYTHONINTERP_FOUND) set(GUDHI_PYTHON_MODULES "${GUDHI_PYTHON_MODULES}'alpha_complex', ") set(GUDHI_PYTHON_MODULES "${GUDHI_PYTHON_MODULES}'euclidean_witness_complex', ") set(GUDHI_PYTHON_MODULES "${GUDHI_PYTHON_MODULES}'euclidean_strong_witness_complex', ") + set(GUDHI_PYTHON_MODULES "${GUDHI_PYTHON_MODULES}'sktda', ") add_gudhi_debug_info("Python version ${PYTHON_VERSION_STRING}") add_gudhi_debug_info("Cython version ${CYTHON_VERSION}") @@ -199,6 +200,7 @@ if(PYTHONINTERP_FOUND) # Other .py files file(COPY "gudhi/persistence_graphical_tools.py" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/gudhi") + file(COPY "gudhi/sktda" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/gudhi/") add_custom_command( OUTPUT gudhi.so diff --git a/src/cython/example/ex_diagrams.py b/src/python/example/ex_diagrams.py index aee20245..3dc6fe84 100644 --- a/src/cython/example/ex_diagrams.py +++ b/src/python/example/ex_diagrams.py @@ -2,12 +2,11 @@ import matplotlib.pyplot as plt import numpy as np from sklearn.kernel_approximation import RBFSampler -import sys -sys.path.append("../sktda/") -from preprocessing import * -from metrics import * -from vector_methods import * -from kernel_methods import * +from gudhi.sktda import Landscape, Silhouette, BettiCurve, ComplexPolynomial,\ + TopologicalVector, DiagramScaler, BirthPersistenceTransform,\ + PersistenceImage, PersistenceWeightedGaussianKernel,\ + PersistenceScaleSpaceKernel, SlicedWassersteinDistance,\ + SlicedWassersteinKernel, BottleneckDistance, PersistenceFisherKernel D = np.array([[0.,4.],[1.,2.],[3.,8.],[6.,8.]]) plt.scatter(D[:,0],D[:,1]) @@ -44,11 +43,11 @@ TV = TopologicalVector(threshold=-1) tv = TV.fit_transform(diags) print("Topological vector is " + str(tv[0,:])) -diagsT = DiagramPreprocessor(use=True, scalers=[([0,1], BirthPersistenceTransform())]).fit_transform(diags) -PI = PersistenceImage(bandwidth=1., weight=lambda x: x[1], im_range=[0,10,0,10], resolution=[100,100]) -pi = PI.fit_transform(diagsT) -plt.imshow(np.flip(np.reshape(pi[0], [100,100]), 0)) -plt.show() +#diagsT = DiagramPreprocessor(use=True, scalers=[([0,1], BirthPersistenceTransform())]).fit_transform(diags) +#PI = PersistenceImage(bandwidth=1., weight=lambda x: x[1], im_range=[0,10,0,10], resolution=[100,100]) +#pi = PI.fit_transform(diagsT) +#plt.imshow(np.flip(np.reshape(pi[0], [100,100]), 0)) +#plt.show() plt.scatter(D[:,0],D[:,1]) D = np.array([[1.,5.],[3.,6.],[2.,7.]]) diff --git a/src/python/gudhi/sktda/__init__.py b/src/python/gudhi/sktda/__init__.py new file mode 100644 index 00000000..f020248d --- /dev/null +++ b/src/python/gudhi/sktda/__init__.py @@ -0,0 +1,6 @@ +from .kernel_methods import * +from .metrics import * +from .preprocessing import * +from .vector_methods import * + +__all__ = ["kernel_methods", "metrics", "preprocessing", "vector_methods"] diff --git a/src/cython/sktda/kernel_methods.py b/src/python/gudhi/sktda/kernel_methods.py index d90bf164..d90bf164 100644 --- a/src/cython/sktda/kernel_methods.py +++ b/src/python/gudhi/sktda/kernel_methods.py diff --git a/src/cython/sktda/metrics.py b/src/python/gudhi/sktda/metrics.py index 18db432a..8092f7af 100644 --- a/src/cython/sktda/metrics.py +++ b/src/python/gudhi/sktda/metrics.py @@ -3,12 +3,11 @@ All rights reserved """ -import sys import numpy as np from sklearn.base import BaseEstimator, TransformerMixin from sklearn.metrics import pairwise_distances try: - from gudhi import bottleneck_distance + from .. import bottleneck_distance USE_GUDHI = True except ImportError: USE_GUDHI = False @@ -120,7 +119,6 @@ class BottleneckDistance(BaseEstimator, TransformerMixin): if USE_GUDHI: for i in range(num_diag1): - #sys.stdout.write( str(i*1.0 / num_diag1) + "\r") for j in range(i+1, num_diag1): matrix[i,j] = bottleneck_distance(X[i], X[j], self.epsilon) matrix[j,i] = matrix[i,j] @@ -133,7 +131,6 @@ class BottleneckDistance(BaseEstimator, TransformerMixin): if USE_GUDHI: for i in range(num_diag1): - #sys.stdout.write( str(i*1.0 / num_diag1) + "\r") for j in range(num_diag2): matrix[i,j] = bottleneck_distance(X[i], self.diagrams_[j], self.epsilon) else: diff --git a/src/cython/sktda/preprocessing.py b/src/python/gudhi/sktda/preprocessing.py index 512b02f3..512b02f3 100644 --- a/src/cython/sktda/preprocessing.py +++ b/src/python/gudhi/sktda/preprocessing.py diff --git a/src/cython/sktda/vector_methods.py b/src/python/gudhi/sktda/vector_methods.py index 3862f815..3862f815 100644 --- a/src/cython/sktda/vector_methods.py +++ b/src/python/gudhi/sktda/vector_methods.py |