Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ART1: calling predict() multiple times does not give same result #288

Open
peterdekker opened this issue Jan 29, 2022 · 4 comments
Open

Comments

@peterdekker
Copy link

The ART1 documentation says that calling predict/train on the same model multiple times, trains a new model: http://neupy.com/modules/generated/neupy.algorithms.ART1.html Thus I would expect that they give the same result. However, different calls of predict() on the same model give different results. With my data, the result is different for the second run and then stays the same. Code:

from neupy.algorithms import ART1
artnet = ART1(
    step=0.1,
    rho=0.5,
    n_clusters=5,
)
for i in range(10):
    clusters = artnet.predict(data)
    print(clusters)

yields result:

[0. 1. 2. ... 1. 1. 1.]
[0. 1. 1. ... 1. 1. 1.]
[0. 1. 1. ... 1. 1. 1.]
[0. 1. 1. ... 1. 1. 1.]
[0. 1. 1. ... 1. 1. 1.]
[0. 1. 1. ... 1. 1. 1.]
[0. 1. 1. ... 1. 1. 1.]
[0. 1. 1. ... 1. 1. 1.]
[0. 1. 1. ... 1. 1. 1.]
[0. 1. 1. ... 1. 1. 1.]

The data is 2700 data points of about 200 features. If needed I can supply the data.

@peterdekker
Copy link
Author

I may have found the cause. It seems the weight_21 and weight_12 fields of the ART class are re-used across runs, and not reset.

@itdxer
Copy link
Owner

itdxer commented Jan 31, 2022

@peterdekker thank you for reporting the problem. I wouldn't necessary say that this is a bug, but rather bad design on my part. It would be reproducible if during each iteration you would initialize a new object

from neupy.algorithms import ART1

for i in range(10):
    artnet = ART1(
        step=0.1,
        rho=0.5,
        n_clusters=5,
    )
    clusters = artnet.predict(data)
    print(clusters)

@peterdekker
Copy link
Author

Thanks for looking into it! I indeed worked around it by creating a new object. Maybe it would then mainly an issue of describing the predict() method differently in the documentation.

@peterdekker
Copy link
Author

So, given that weights_12 and weights_21 are re-used over invocations of train(), could train() actually be used to train the model incrementally on multiple batches of data? That would actually be useful for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants