Performs k-means clustering on an H2O dataset
h2o.kmeans(
training_frame,
x,
model_id = NULL,
validation_frame = NULL,
nfolds = 0,
keep_cross_validation_models = TRUE,
keep_cross_validation_predictions = FALSE,
keep_cross_validation_fold_assignment = FALSE,
fold_assignment = c("AUTO", "Random", "Modulo", "Stratified"),
fold_column = NULL,
ignore_const_cols = TRUE,
score_each_iteration = FALSE,
k = 1,
estimate_k = FALSE,
user_points = NULL,
max_iterations = 10,
standardize = TRUE,
seed = -1,
init = c("Random", "PlusPlus", "Furthest", "User"),
max_runtime_secs = 0,
categorical_encoding = c("AUTO", "Enum", "OneHotInternal", "OneHotExplicit",
"Binary", "Eigen", "LabelEncoder", "SortByResponse", "EnumLimited"),
export_checkpoints_dir = NULL,
cluster_size_constraints = NULL
)
an object of class H2OClusteringModel.
Id of the training data frame.
A vector containing the character
names of the predictors in the model.
Destination id for this model; auto-generated if not specified.
Id of the validation data frame.
Number of folds for K-fold cross-validation (0 to disable or >= 2). Defaults to 0.
Logical
. Whether to keep the cross-validation models. Defaults to TRUE.
Logical
. Whether to keep the predictions of the cross-validation models. Defaults to FALSE.
Logical
. Whether to keep the cross-validation fold assignment. Defaults to FALSE.
Cross-validation fold assignment scheme, if fold_column is not specified. The 'Stratified' option will stratify the folds based on the response variable, for classification problems. Must be one of: "AUTO", "Random", "Modulo", "Stratified". Defaults to AUTO.
Column with cross-validation fold index assignment per observation.
Logical
. Ignore constant columns. Defaults to TRUE.
Logical
. Whether to score during each iteration of model training. Defaults to FALSE.
The max. number of clusters. If estimate_k is disabled, the model will find k centroids, otherwise it will find up to k centroids. Defaults to 1.
Logical
. Whether to estimate the number of clusters (<=k) iteratively and deterministically. Defaults
to FALSE.
This option allows you to specify a dataframe, where each row represents an initial cluster center. The user- specified points must have the same number of columns as the training observations. The number of rows must equal the number of clusters
Maximum training iterations (if estimate_k is enabled, then this is for each inner Lloyds iteration) Defaults to 10.
Logical
. Standardize columns before computing distances Defaults to TRUE.
Seed for random numbers (affects certain parts of the algo that are stochastic and those might or might not be enabled by default). Defaults to -1 (time-based random number).
Initialization mode Must be one of: "Random", "PlusPlus", "Furthest", "User". Defaults to Furthest.
Maximum allowed runtime in seconds for model training. Use 0 to disable. Defaults to 0.
Encoding scheme for categorical features Must be one of: "AUTO", "Enum", "OneHotInternal", "OneHotExplicit", "Binary", "Eigen", "LabelEncoder", "SortByResponse", "EnumLimited". Defaults to AUTO.
Automatically export generated models to this directory.
An array specifying the minimum number of points that should be in each cluster. The length of the constraints array has to be the same as the number of clusters.
h2o.cluster_sizes
, h2o.totss
, h2o.num_iterations
, h2o.betweenss
, h2o.tot_withinss
, h2o.withinss
, h2o.centersSTD
, h2o.centers
if (FALSE) {
library(h2o)
h2o.init()
prostate_path <- system.file("extdata", "prostate.csv", package = "h2o")
prostate <- h2o.uploadFile(path = prostate_path)
h2o.kmeans(training_frame = prostate, k = 10, x = c("AGE", "RACE", "VOL", "GLEASON"))
}
Run the code above in your browser using DataLab