Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Re: How to make nested lists in JSL?

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Aug 11, 2016 3:59 AM
(12976 views)

I have a data table with geographical points (GPS-locations). Each row represents one location with columns longitude, latitude, etc.

I'm trying to do a cluster analysis on these points.

I already have an algorithm that searches for each point all the points within a predefined radius (neighborhood) and adds them to a list named cluster.

So for each point in my data table, I can generate a list, which contains all the points in the neighborhood of the point(cluster).

Now I'm searching for a solution to add all these cluster-lists into one list which then contains all the cluster lists.

I want to have a nested list, or a list in a list, so that I can iterate through all the clusters and for example merge some of the clusters etc.

Is that even possible with jmp/jsl?

Thank's for your help!

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

The list is a very flexible data structure, to the point that you can have lists that are not homogeneous (that is, in which the elements do not have the same data type). You can certainly create a 'list of lists' - For example:

k = 3; // No. of items in the list of lists

myList = {};

For(i=1, i<=k, i++,

kk = RandomInteger(1, 5); // No. of items in this list

itemList = {};

For(ii=1, ii<=kk, ii++,

InsertInto(itemList, Char(RandomInteger(1, 10)));

);

Print(itemList);

InsertInto(myList, Eval(EvalList({itemList})));

);

Print(myList);

5 REPLIES 5

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

The list is a very flexible data structure, to the point that you can have lists that are not homogeneous (that is, in which the elements do not have the same data type). You can certainly create a 'list of lists' - For example:

k = 3; // No. of items in the list of lists

myList = {};

For(i=1, i<=k, i++,

kk = RandomInteger(1, 5); // No. of items in this list

itemList = {};

For(ii=1, ii<=kk, ii++,

InsertInto(itemList, Char(RandomInteger(1, 10)));

);

Print(itemList);

InsertInto(myList, Eval(EvalList({itemList})));

);

Print(myList);

Highlighted
##

If you have some sort of "key", then associative arrays would be helpful. I'm guessing that in your case the associative array key would be the cluster.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to make nested lists in JSL?

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to make nested lists in JSL?

Each cluster has a so called core, which is the point, the cluster has been initially built on.

So I have a point P (represented by a row-number of my data table).

Next step is to search for all those points in my data table, that are in a pre defined radius around my point P.

When i have all the points, I insert them into a new list L. Afterwards I insert the point P into the List L at the position 1.

Now my list L represents a cluster. The core of the cluster is my point P. And my list looks like this:

L = { <row-number of point P> , <row-numbers of all the points within radius R around P> }

One could say, that the row-number of the point P is in fact the "key" of the cluster/list.

I should mention, that L ist not a nested list! L is Inserted into another List.

clusterList = { ..., L-2, L-1, L, L+1, L+2, ...}

clusterList is the nested List.

After I have created the cluster List I want to iterate through it and merge certain clusters.

For example:

P is the core of cluster L.

If L+2 contains P, then insert all the points from L into L+2 and delete L afterwards.

Iterate with next list in clusterList...

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to make nested lists in JSL?

After reading your detailed description of what you want, I suggest that since a data table is just an X by Y matrix to JMP, that you may want to look into just keeping the data in a data table, rather than doing all of the moving to lists and lists of lists.

Using "Get Rows Where", and creating new column(s) to save the various P values that were found in the given radius for P, you will have all of your data organized right in your data table.

Jim

Highlighted
##

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: How to make nested lists in JSL?

clearLog();

// Lets say you are staring with something like this

// point(row) -> Cluster List

// p1 = {1,4,6,8};

// p2 = {2,9,6,4,1,7};

// p3 = {3,2,5};

// When you are generating you initial cluster lists (I presume you iterate over your table rows)

// add them to an Associative Array on the fly.

// clusterAa = associativeArray();

// while(iterating over your points and lists,

// clusterAa["p1"] = {1,4,6,8}; // The key here is a String but could be an Integer, value = cluster list

// e.g. clusterAa[row] = Cluster List;

// );

// Jumping forward you should have an array like this.

clusterAa = associativeArray({

{"p1", {1,4,6,8}},

{"p2", {2,9,6,4,1,7}},

{"p3", {3,2,5}}

});

listOfPoints = clusterAa << getKeys; // Get the keys as a list {"p1", "p2", "p3"}

i=1;

listOfClusterLists = {};

while(i <= nItems(listOfPoints), // Iterate over the list and add to a linal list

insertInto(listOfClusterLists, evalList(list(clusterAa[listOfPoints*])));*

i++;

);

show(listOfClusterLists);

// Result = listOfClusterLists = {{1, 4, 6, 8}, {2, 9, 6, 4, 1, 7}, {3, 2, 5}};

Of course you could also try the Clustering Tool under the Multivariate Methods tab in JMP. I've had some reasonable success doing K-Means clustering using this tool.

- Tags:
- associative array

Article Labels

There are no labels assigned to this post.