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

Predicting Best Matching for new data #39

Closed
theSage21 opened this issue Jul 23, 2016 · 4 comments
Closed

Predicting Best Matching for new data #39

theSage21 opened this issue Jul 23, 2016 · 4 comments
Labels

Comments

@theSage21
Copy link

Hi,

Noob question here. Once I've got my map, how do I predict the best matching units for new data?

@xgdgsc
Copy link
Collaborator

xgdgsc commented Jul 25, 2016

@theSage21
Copy link
Author

@xgdgsc Let me rephrase.
How do I use somoclu to classify new data given an already existing set of .wts and .ux?
Essentially what is the equivalent of predict given that fit is done via something like
somoclu -x 10 -y 10 input_file output_file?

@ghost
Copy link

ghost commented Jul 28, 2016

In python prediction is relatively straight forward:

W = som.codebook.reshape((som.codebook.shape[0] * som.codebook.shape[1], som.codebook.shape[2]))
X = data

D = -2*np.dot(W, X.T) + (W**2).sum(1)[:, None] + (X**2).sum(1)[:, None].T
BMU = (D==D.min(0)[None,:]).astype("float32").T
NBMU =  BMU.reshape((X.shape[0], som.codebook.shape[0], som.codebook.shape[1]))
new_bmus = np.vstack(NBMU.nonzero()[1:][::-1]).T

X can be a single instance or as many as your RAM would allow.

@theSage21
Copy link
Author

@Dringite thank you.

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

No branches or pull requests

3 participants