Select to view content in your preferred language

Need to understand the pseudocode

797
2
05-30-2022 03:08 PM
MaryamZakeri
Emerging Contributor

Hello everyone,

I have two sets of Origin and Destination locations (Longitude, Latitude + ID) for more than 6000 trips and I want to cluster them using GMM, based on their locations. In other words, trips with similar OD pairs will be in the same cluster.

I asked a friend to tell me how to have OD pairs presented as the input to the GMM algorithm and they gave me the below pseudocode that I cannot figure out. Can anyone help me figure out what to do to develop the code? I am not super proficient with python.

Or if there is any other way that you can help me to achieve my purpose, I'd appreciate it if you could share.

 

You'll need 2 sets, You're name of CSV file, And a hadhmap:
Map clusterOD(filename){

Arr = readCsv(filename) //array[n][2]

Originset

DesSet

Omean
DMean

// Floating mean
For I in range(sizeof(arr)){
N = 1
For j in range(I, sizeof(arr))
{
//Gets all means and adds to set
}

}

Map

//Permutati
Add to hadhmap
Sort and grav

0 Kudos
2 Replies
by Anonymous User
Not applicable

The best interpreter would be the author of the pseudo code. Send it back and ask for clarification? The syntax isn’t python either, but you have a method with an argument, variable(s) and a for loop… which is not very helpful.

Towards data science/medium has a pretty comprehensive example of working with spatial data to get you started: 
gmm-gaussian-mixture-models-how-to-successfully-use-it-to-cluster-your-data 

I’d suggest scraping the pseudo code and work through the example.

MaryamZakeri
Emerging Contributor

Thanks, appreciate your answer.

0 Kudos