giotto-ai / giotto-tda

A high-performance topological machine learning toolbox in Python
https://giotto-ai.github.io/gtda-docs
Other
858 stars 175 forks source link

[BUG] Cannot run Scaler() #683

Closed albienaculan14 closed 5 months ago

albienaculan14 commented 1 year ago

I re-ran the Lorenz attractor notebook from giotto-tda examples. In the part using scaler,

diagramScaler = Scaler()

X_scaled = diagramScaler.fit_transform(X_diagrams)

diagramScaler.plot(X_scaled, sample=window_number)

I get the following error:

TypeError: Parameter function is of type <class 'numpy._ArrayFunctionDispatcher'> while it should be of type (<class 'function'>, <class 'NoneType'>).

I also ran this using the data that I have and the Scaler method also produced the same error.

taoshen1 commented 1 year ago

I have the same question

Lunamos commented 1 year ago

The same TypeError also happens in Lab.fit_transform_resample(X, X) in time_series_forecasting.ipynb.

beew commented 11 months ago

What is your numpy version? There is no update for a while, probably new versions of libraries break backward compatibility. It works here with

Python implementation: CPython
Python version       : 3.10.9
IPython version      : 8.13.1

sklearn: 1.2.2

plotly: 5.13.1
openml: 0.13.0
numpy : 1.23.5

Almost all examples are broken with scikit-learn 1.3.x. I hope there is an update as this is a very interesting software,

hawkinglai commented 6 months ago

It is easily to be solved using the lambda x: np.max(x), be like:

Scaler(metric='persistence_image', function=lambda x: np.max(x), n_jobs=-1).fit_transform(persistence_diagrams)