class_docstr: An unsupervised learning algorithm that attempts to find discrete groupings within data.
  
  As the result of KMeans, members of a group are as similar as possible to one another and as
  different as possible from members of other groups. You define the attributes that you want
  the algorithm to use to determine similarity.
docstr: A k-means clustering class :class:`~sagemaker.amazon.AmazonAlgorithmEstimatorBase`.
  
  Finds k clusters of data in an unlabeled dataset.
  
  This Estimator may be fit via calls to
  :meth:`~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.fit_ndarray`
  or
  :meth:`~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.fit`.
  The former allows a KMeans model to be fit on a 2-dimensional numpy
  array. The latter requires Amazon
  :class:`~sagemaker.amazon.record_pb2.Record` protobuf serialized data to
  be stored in S3.
  
  To learn more about the Amazon protobuf Record class and how to
  prepare bulk data in this format, please consult AWS technical
  documentation:
  https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-training.html.
  
  After this Estimator is fit, model data is stored in S3. The model
  may be deployed to an Amazon SageMaker Endpoint by invoking
  :meth:`~sagemaker.amazon.estimator.EstimatorBase.deploy`. As well as
  deploying an Endpoint, ``deploy`` returns a
  :class:`~sagemaker.amazon.kmeans.KMeansPredictor` object that can be
  used to k-means cluster assignments, using the trained k-means model
  hosted in the SageMaker Endpoint.
  
  KMeans Estimators can be configured by setting hyperparameters. The
  available hyperparameters for KMeans are documented below. For further
  information on the AWS KMeans algorithm, please consult AWS technical
  documentation:
  https://docs.aws.amazon.com/sagemaker/latest/dg/k-means.html.
  
  Args:
      role (str): An AWS IAM role (either name or full ARN). The Amazon
          SageMaker training jobs and APIs that create Amazon SageMaker
          endpoints use this role to access training data and model
          artifacts. After the endpoint is created, the inference code
          might use the IAM role, if accessing AWS resource.
      instance_count (int or PipelineVariable): Number of Amazon EC2 instances to use
          for training.
      instance_type (str or PipelineVariable): Type of EC2 instance to use for training,
          for example, 'ml.c4.xlarge'.
      k (int): The number of clusters to produce.
      init_method (str): How to initialize cluster locations. One of
          'random' or 'kmeans++'.
      max_iterations (int): Maximum iterations for Lloyds EM procedure in
          the local kmeans used in finalize stage.
      tol (float): Tolerance for change in ssd for early stopping in local
          kmeans.
      num_trials (int): Local version is run multiple times and the one
          with the best loss is chosen. This determines how many times.
      local_init_method (str): Initialization method for local version.
          One of 'random', 'kmeans++'
      half_life_time_size (int): The points can have a decayed weight.
          When a point is observed its weight, with regard to the
          computation of the cluster mean is 1. This weight will decay
          exponentially as we observe more points. The exponent
          coefficient is chosen such that after observing
          ``half_life_time_size`` points after the mentioned point, its
          weight will become 1/2. If set to 0, there will be no decay.
      epochs (int): Number of passes done over the training data.
      center_factor (int): The algorithm will create
          ``num_clusters * extra_center_factor`` as it runs and reduce the
          number of centers to ``k`` when finalizing
      eval_metrics (list[str] or list[PipelineVariable]): JSON list of metrics types
          to be used for reporting the score for the model. Allowed values are "msd"
          Means Square Error, "ssd": Sum of square distance. If test data
          is provided, the score shall be reported in terms of all
          requested metrics.
      **kwargs: base class keyword argument values.
  
  .. tip::
  
      You can find additional parameters for initializing this class at
      :class:`~sagemaker.estimator.amazon_estimator.AmazonAlgorithmEstimatorBase` and
      :class:`~sagemaker.estimator.EstimatorBase`.
docstr_tok: ["A","k-means","clustering","class",":","class",":","`","~sagemaker.amazon.AmazonAlgorithmEstimatorBase","`",".","Finds","k","clusters","of","data","in","an","unlabeled","dataset",".","This","Estimator","may","be","fit","via","calls","to",":","meth",":","`","~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.fit_ndarray","`","or",":","meth",":","`","~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.fit","`",".","The","former","allows","a","KMeans","model","to","be","fit","on","a","2-dimensional","numpy","array",".","The","latter","requires","Amazon",":","class",":","`","~sagemaker.amazon.record_pb2.Record","`","protobuf","serialized","data","to","be","stored","in","S3",".","To","learn","more","about","the","Amazon","protobuf","Record","class","and","how","to","prepare","bulk","data","in","this","format",",","please","consult","AWS","technical","documentation",":","https",":","\/\/docs.aws.amazon.com\/sagemaker\/latest\/dg\/cdf-training.html",".","After","this","Estimator","is","fit",",","model","data","is","stored","in","S3",".","The","model","may","be","deployed","to","an","Amazon","SageMaker","Endpoint","by","invoking",":","meth",":","`","~sagemaker.amazon.estimator.EstimatorBase.deploy","`",".","As","well","as","deploying","an","Endpoint",",","``","deploy","``","returns","a",":","class",":","`","~sagemaker.amazon.kmeans.KMeansPredictor","`","object","that","can","be","used","to","k-means","cluster","assignments",",","using","the","trained","k-means","model","hosted","in","the","SageMaker","Endpoint",".","KMeans","Estimators","can","be","configured","by","setting","hyperparameters",".","The","available","hyperparameters","for","KMeans","are","documented","below",".","For","further","information","on","the","AWS","KMeans","algorithm",",","please","consult","AWS","technical","documentation",":","https",":","\/\/docs.aws.amazon.com\/sagemaker\/latest\/dg\/k-means.html",".","Args",":","role","(","str",")",":","An","AWS","IAM","role","(","either","name","or","full","ARN",")",".","The","Amazon","SageMaker","training","jobs","and","APIs","that","create","Amazon","SageMaker","endpoints","use","this","role","to","access","training","data","and","model","artifacts",".","After","the","endpoint","is","created",",","the","inference","code","might","use","the","IAM","role",",","if","accessing","AWS","resource",".","instance_count","(","int","or","PipelineVariable",")",":","Number","of","Amazon","EC2","instances","to","use","for","training",".","instance_type","(","str","or","PipelineVariable",")",":","Type","of","EC2","instance","to","use","for","training",",","for","example",",","'ml.c4.xlarge","'",".","k","(","int",")",":","The","number","of","clusters","to","produce",".","init_method","(","str",")",":","How","to","initialize","cluster","locations",".","One","of","'random","'","or","'kmeans++","'",".","max_iterations","(","int",")",":","Maximum","iterations","for","Lloyds","EM","procedure","in","the","local","kmeans","used","in","finalize","stage",".","tol","(","float",")",":","Tolerance","for","change","in","ssd","for","early","stopping","in","local","kmeans",".","num_trials","(","int",")",":","Local","version","is","run","multiple","times","and","the","one","with","the","best","loss","is","chosen",".","This","determines","how","many","times",".","local_init_method","(","str",")",":","Initialization","method","for","local","version",".","One","of","'random","'",",","'kmeans++'","half_life_time_size","(","int",")",":","The","points","can","have","a","decayed","weight",".","When","a","point","is","observed","its","weight",",","with","regard","to","the","computation","of","the","cluster","mean","is","1",".","This","weight","will","decay","exponentially","as","we","observe","more","points",".","The","exponent","coefficient","is","chosen","such","that","after","observing","``","half_life_time_size","``","points","after","the","mentioned","point",",","its","weight","will","become","1\/2",".","If","set","to","0",",","there","will","be","no","decay",".","epochs","(","int",")",":","Number","of","passes","done","over","the","training","data",".","center_factor","(","int",")",":","The","algorithm","will","create","``","num_clusters","*","extra_center_factor","``","as","it","runs","and","reduce","the","number","of","centers","to","``","k","``","when","finalizing","eval_metrics","(","list","[","str","]","or","list","[","PipelineVariable","]",")",":","JSON","list","of","metrics","types","to","be","used","for","reporting","the","score","for","the","model",".","Allowed","values","are","``","msd","''","Means","Square","Error",",","``","ssd","''",":","Sum","of","square","distance",".","If","test","data","is","provided",",","the","score","shall","be","reported","in","terms","of","all","requested","metrics",".","*","*","kwargs",":","base","class","keyword","argument","values",".","..","tip",":",":","You","can","find","additional","parameters","for","initializing","this","class","at",":","class",":","`","~sagemaker.estimator.amazon_estimator.AmazonAlgorithmEstimatorBase","`","and",":","class",":","`","~sagemaker.estimator.EstimatorBase","`","."]
code: def __init__(
      self,
      role: Optional[Union[str, PipelineVariable]] = None,
      instance_count: Optional[Union[int, PipelineVariable]] = None,
      instance_type: Optional[Union[str, PipelineVariable]] = None,
      k: Optional[int] = None,
      init_method: Optional[str] = None,
      max_iterations: Optional[int] = None,
      tol: Optional[float] = None,
      num_trials: Optional[int] = None,
      local_init_method: Optional[str] = None,
      half_life_time_size: Optional[int] = None,
      epochs: Optional[int] = None,
      center_factor: Optional[int] = None,
      eval_metrics: Optional[List[Union[str, PipelineVariable]]] = None,
      **kwargs,
  ):
      """A k-means clustering class :class:`~sagemaker.amazon.AmazonAlgorithmEstimatorBase`.
  
      Finds k clusters of data in an unlabeled dataset.
  
      This Estimator may be fit via calls to
      :meth:`~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.fit_ndarray`
      or
      :meth:`~sagemaker.amazon.amazon_estimator.AmazonAlgorithmEstimatorBase.fit`.
      The former allows a KMeans model to be fit on a 2-dimensional numpy
      array. The latter requires Amazon
      :class:`~sagemaker.amazon.record_pb2.Record` protobuf serialized data to
      be stored in S3.
  
      To learn more about the Amazon protobuf Record class and how to
      prepare bulk data in this format, please consult AWS technical
      documentation:
      https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-training.html.
  
      After this Estimator is fit, model data is stored in S3. The model
      may be deployed to an Amazon SageMaker Endpoint by invoking
      :meth:`~sagemaker.amazon.estimator.EstimatorBase.deploy`. As well as
      deploying an Endpoint, ``deploy`` returns a
      :class:`~sagemaker.amazon.kmeans.KMeansPredictor` object that can be
      used to k-means cluster assignments, using the trained k-means model
      hosted in the SageMaker Endpoint.
  
      KMeans Estimators can be configured by setting hyperparameters. The
      available hyperparameters for KMeans are documented below. For further
      information on the AWS KMeans algorithm, please consult AWS technical
      documentation:
      https://docs.aws.amazon.com/sagemaker/latest/dg/k-means.html.
  
      Args:
          role (str): An AWS IAM role (either name or full ARN). The Amazon
              SageMaker training jobs and APIs that create Amazon SageMaker
              endpoints use this role to access training data and model
              artifacts. After the endpoint is created, the inference code
              might use the IAM role, if accessing AWS resource.
          instance_count (int or PipelineVariable): Number of Amazon EC2 instances to use
              for training.
          instance_type (str or PipelineVariable): Type of EC2 instance to use for training,
              for example, 'ml.c4.xlarge'.
          k (int): The number of clusters to produce.
          init_method (str): How to initialize cluster locations. One of
              'random' or 'kmeans++'.
          max_iterations (int): Maximum iterations for Lloyds EM procedure in
              the local kmeans used in finalize stage.
          tol (float): Tolerance for change in ssd for early stopping in local
              kmeans.
          num_trials (int): Local version is run multiple times and the one
              with the best loss is chosen. This determines how many times.
          local_init_method (str): Initialization method for local version.
              One of 'random', 'kmeans++'
          half_life_time_size (int): The points can have a decayed weight.
              When a point is observed its weight, with regard to the
              computation of the cluster mean is 1. This weight will decay
              exponentially as we observe more points. The exponent
              coefficient is chosen such that after observing
              ``half_life_time_size`` points after the mentioned point, its
              weight will become 1/2. If set to 0, there will be no decay.
          epochs (int): Number of passes done over the training data.
          center_factor (int): The algorithm will create
              ``num_clusters * extra_center_factor`` as it runs and reduce the
              number of centers to ``k`` when finalizing
          eval_metrics (list[str] or list[PipelineVariable]): JSON list of metrics types
              to be used for reporting the score for the model. Allowed values are "msd"
              Means Square Error, "ssd": Sum of square distance. If test data
              is provided, the score shall be reported in terms of all
              requested metrics.
          **kwargs: base class keyword argument values.
  
      .. tip::
  
          You can find additional parameters for initializing this class at
          :class:`~sagemaker.estimator.amazon_estimator.AmazonAlgorithmEstimatorBase` and
          :class:`~sagemaker.estimator.EstimatorBase`.
      """
      super(KMeans, self).__init__(
          role, instance_count, instance_type, **kwargs
      )
      self.k = k
      self.init_method = init_method
      self.max_iterations = max_iterations
      self.tol = tol
      self.num_trials = num_trials
      self.local_init_method = local_init_method
      self.half_life_time_size = half_life_time_size
      self.epochs = epochs
      self.center_factor = center_factor
      self.eval_metrics = eval_metrics
  
imports: from __future__ import absolute_import
  from typing import Union, Optional, List
  from sagemaker import image_uris
  from sagemaker.amazon.amazon_estimator import AmazonAlgorithmEstimatorBase
  from sagemaker.amazon.common import RecordSerializer, RecordDeserializer
  from sagemaker.amazon.hyperparameter import Hyperparameter
  from sagemaker.amazon.validation import gt, isin, ge, le
  from sagemaker.predictor import Predictor
  from sagemaker.model import Model
  from sagemaker.session import Session
  from sagemaker.utils import pop_out_unused_kwarg
  from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
  from sagemaker.workflow.entities import PipelineVariable
label_desc: Use image node_id 1 to create a new KMeans object from inherited base classes: AmazonAlgorithmEstimatorBase with example: obj = KMeans(role, instance_count, instance_type, k, init_method, max_iterations, tol, num_trials, local_init_method, half_life_time_size, epochs, center_factor, eval_metrics)