online-ml / river

🌊 Online machine learning in Python
https://riverml.xyz
BSD 3-Clause "New" or "Revised" License
5.03k stars 540 forks source link

AttributeError: 'Vertex' object has no attribute 'uuid' #1507

Closed superpowertriangel closed 7 months ago

superpowertriangel commented 7 months ago

Hi when trying to open a pickeled pipeline with KNN_Classifier (with SWINN) and a StandardScaler I get the following issue. The same happens when trying to use copy.deepcopy on the trained model.

File "/app/main.py", line 3, in pickle.load(open(f"KNN_Classifier.pkl", 'rb')) File "/usr/local/lib/python3.10/site-packages/river/neighbors/ann/nn_vertex.py", line 23, in hash return self.uuid AttributeError: 'Vertex' object has no attribute 'uuid'

Versions

river version: 0.21.0 Python version: 3.10 Operating system: wsl, macos

smastelini commented 7 months ago

Hi @superpowertriangel, I will check it ASAP. In the meantime, could you share a MWE?

superpowertriangel commented 7 months ago

I used optuna to finde the best hyperparameters and then created a new model from the hyperparameters:

dist = functools.partial(utils.math.minkowski_distance, p=p)

engine=neighbors.SWINN( graph_k=graph_k, prune_prob=prune_prob, n_iters=n_iters, dist_func=dist, seed=42) model=preprocessing.StandardScaler() | neighbors.KNNClassifier(neighbor,engine=engine,softmax=softmax)

Thanks @smastelini

smastelini commented 7 months ago

Hey @superpowertriangel, I just merged #1508 to fix that issue. Please, let me know if that does the trick for you.

Cheers,

superpowertriangel commented 7 months ago

@smastelini Everything works like a charm now!! Thanks a lot