Message Boards Message Boards

0
|
1979 Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

A subtle difference in the handling of Associations ?

Posted 3 years ago

Dear All,

I'm currently facing a strange result I can't seem to understand. The problem however, is very easy to explain. I'm handling two lists, Xtrain and Ytrain (for Machine Learning endeavors). The first is a collection of 99 335 elements of the form 100-uplet, the second is again a collection of 99 335 elements of the form 4-uplet.

I'm trying to create a set which takes each element of the Xtrain set and bound it with an arrow to the corresponding element of the Ytrain set. Seems rather easy right ?

Here is the deal. Creating a set using the Thread function works just fine. (see below, we still get our 99 335 elements of the form : x_ -> y_ ) However, put into an Association format, and everything fall apart. Without any sort of explanation, we get 51 173 elements.

It's easy to check that they do not appear out of nowhere, for the intersection of the association with the simple list give us all the element of the association.

However, taking the complement show us that for some reason, the second element lack 2370 elements only from the first one, and not 48 162 as expected.

I'm really confused about this differences. Can someone explain to me why this difference appears in the first place, and what to do to solve it ?

Thank you very much.

3 lines of incomprehension

2 Replies

And there we go, it was exactly that. A huge thanks, and a happy day to you!

Posted 3 years ago

Hi Alexandre,

The keys in an Association have to be unique, so one possibility is that the Xtrain values are not unique. What is the result of

Length /@ {Xtrain, DeleteDuplicates@Xtrain}
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract