Title: | OD-Means: k-Means for Origin-Destination |
---|---|
Description: | OD-means is a hierarchical adaptive k-means algorithm based on origin-destination pairs. In the first layer of the hierarchy, the clusters are separated automatically based on the variation of the within-cluster distance of each cluster until convergence. The second layer of the hierarchy corresponds to the sub clustering process of small clusters based on the distance between the origin and destination of each cluster. |
Authors: | Sebastian Moreno [aut, cre], Cristobal Heredia [aut], Wilfredo Yushimito [ths], Gonzalo Huerta [ths] |
Maintainer: | Sebastian Moreno <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.1 |
Built: | 2025-02-12 04:56:30 UTC |
Source: | https://github.com/cran/ODMeans |
First Hierarchy Function
first_hierarchy(data, numK, limitsSeparation, maxDist, kmeans_pp = FALSE)
first_hierarchy(data, numK, limitsSeparation, maxDist, kmeans_pp = FALSE)
data |
A data frame with four columns: |
numK |
Initial number of clusters in the first call of k-means in the global hierarchy. |
limitsSeparation |
Within cluster distance threshold to determine if a global cluster must be separated into two new clusters. |
maxDist |
Meter distance threshold used to re-estimate centroids in global hierarchy. |
kmeans_pp |
Boolean value, if TRUE it initialize centroids using kmeans++. |
Returns an S3 class object similar to kmeans S3 Class, with eight properties.
data(ODMeansTaxiData) first_hierarchy_data = first_hierarchy(ODMeansTaxiData, 10, 300, 1000)
data(ODMeansTaxiData) first_hierarchy_data = first_hierarchy(ODMeansTaxiData, 10, 300, 1000)
ODMeans Function
odmeans( data, numKGlobal, limitSeparationGlobal, maxDistGlobal, distHierarchical, numKLocal, limitSeparationLocal, maxDistLocal, kmeans_pp = FALSE )
odmeans( data, numKGlobal, limitSeparationGlobal, maxDistGlobal, distHierarchical, numKLocal, limitSeparationLocal, maxDistLocal, kmeans_pp = FALSE )
data |
A data frame with four columns: |
numKGlobal |
Initial number of clusters in the first call of k-means in the global hierarchy. |
limitSeparationGlobal |
Within cluster distance threshold to determine if a global cluster must be separated into two new clusters. |
maxDistGlobal |
Meter distance threshold used to re-estimate centroids in global hierarchy. |
distHierarchical |
Meter distance threshold between origin and destination to generate new local clusters from a first layer cluster |
numKLocal |
Initial number of clusters in the first call of k-means in the local hierarchy. |
limitSeparationLocal |
Within cluster distance threshold to determine if a local cluster must be separated into two new clusters. |
maxDistLocal |
Meter distance threshold used to re-estimate centroids in local hierarchy. |
kmeans_pp |
Boolean value, if TRUE it initialize centroids using kmeans++. |
Returns an S3 class object similar to kmeans S3 Class, with eight properties.
data(ODMeansTaxiData) odmeans_data = odmeans(ODMeansTaxiData, 10, 300, 1000, 2200, 3, 50, 100)
data(ODMeansTaxiData) odmeans_data = odmeans(ODMeansTaxiData, 10, 300, 1000, 2200, 3, 50, 100)
Graph ODMeans Function
odmeans_graph( odmeans_data, title = "ODMeans Graph", maptype = "roadmap", zoom = 4, add_cluster = TRUE )
odmeans_graph( odmeans_data, title = "ODMeans Graph", maptype = "roadmap", zoom = 4, add_cluster = TRUE )
odmeans_data |
It receives an object from S3 ODMeans class. However, it can also work with objects from similar classes like S3 k-Means |
title |
It receives an string, and corresponds to the title of the plot. |
maptype |
It receives a string with the type of the map. Depending on the map selected, it will change the background of it. The possible values are: “terrain”, “satellite”, “roadmap”, “hybrid”. |
zoom |
An integer from 3 (continent) to 21 (building), which controls the level of zoom applied to the map. |
add_cluster |
Receives TRUE or FALSE value. When True, it adds the number of the cluster to the arrows. |
A ggplot graph showing a map with the centers of the clusters.
data(ODMeansTaxiData) odmeans_data = odmeans(ODMeansTaxiData, 10, 300, 1000, 2200, 3, 50, 100) odmeans_plot = odmeans_graph(odmeans_data, "ODMeans Taxi Graph", "roadmap", 11, FALSE)
data(ODMeansTaxiData) odmeans_data = odmeans(ODMeansTaxiData, 10, 300, 1000, 2200, 3, 50, 100) odmeans_plot = odmeans_graph(odmeans_data, "ODMeans Taxi Graph", "roadmap", 11, FALSE)
A synthetic data frame containing 1700 Origin-Destination points.
data(ODMeansSampleData)
data(ODMeansSampleData)
A data frame with 10000 rows and 5 variables:
Consists of the origin latitude dimension
Consists of the origin longitude dimension
Consists of the destination latitude dimension
Consists of the destination longitude dimension
Original cluster of the points when it was created
...
Synthetic data
The data frame contains the 452,166 trips collected for the months of March (2014 to 2016), July (2014 to 2016), and November (2014 and 2015). The data points are the taxi's initial and ending location based on latitude and longitude.
data(ODMeansTaxiData)
data(ODMeansTaxiData)
A data frame with 452,166 rows and 4 variables:
Origin latitude dimension
Origin longitude dimension
Destination latitude dimension
Destination longitude dimension
...
Fantaxico, Fermanti Servicios de Ingeniería S.A, Santiago, Chile.
Second Hierarchy Clusters
second_hierarchy( data, Kcluster, distHierarchical, numKLocal, limitSeparationLocal, maxDistLocal )
second_hierarchy( data, Kcluster, distHierarchical, numKLocal, limitSeparationLocal, maxDistLocal )
data |
A data frame with four columns: |
Kcluster |
An ODMeans structure, result of function first_hierarchy. |
distHierarchical |
Meter distance threshold between origin and destination to generate new local clusters from a first layer cluster. |
numKLocal |
Initial number of clusters in the first call of k-means in the local hierarchy. |
limitSeparationLocal |
Within cluster distance threshold to determine if a local cluster must be separated into two new clusters. |
maxDistLocal |
Meter distance threshold used to re-estimate centroids in local hierarchy. |
Returns an S3 class object similar to kmeans S3 Class, with eight properties.
data(ODMeansTaxiData) first_hierarchy_data = first_hierarchy(ODMeansTaxiData, 10, 500, 1000) second_hierarchy_data = second_hierarchy(ODMeansTaxiData, first_hierarchy_data, 2200, 3, 50, 100)
data(ODMeansTaxiData) first_hierarchy_data = first_hierarchy(ODMeansTaxiData, 10, 500, 1000) second_hierarchy_data = second_hierarchy(ODMeansTaxiData, first_hierarchy_data, 2200, 3, 50, 100)