class_docstr: Learning algorithm for a decision tree model for classification or
  regression.
  
  .. versionadded:: 1.1.0
class_docstr_tok: ["Learning","algorithm","for","a","decision","tree","model","for","classification","or","regression",".","..","versionadded",":",":","1.1.0"]
docstr: Train a decision tree model for classification.
  
  .. versionadded:: 1.1.0
  
  Parameters
  ----------
  data :  :py:class:`pyspark.RDD`
      Training data: RDD of LabeledPoint. Labels should take values
      {0, 1, ..., numClasses-1}.
  numClasses : int
      Number of classes for classification.
  categoricalFeaturesInfo : dict
      Map storing arity of categorical features. An entry (n -> k)
      indicates that feature n is categorical with k categories
      indexed from 0: {0, 1, ..., k-1}.
  impurity : str, optional
      Criterion used for information gain calculation.
      Supported values: "gini" or "entropy".
      (default: "gini")
  maxDepth : int, optional
      Maximum depth of tree (e.g. depth 0 means 1 leaf node, depth 1
      means 1 internal node + 2 leaf nodes).
      (default: 5)
  maxBins : int, optional
      Number of bins used for finding splits at each node.
      (default: 32)
  minInstancesPerNode : int, optional
      Minimum number of instances required at child nodes to create
      the parent split.
      (default: 1)
  minInfoGain : float, optional
      Minimum info gain required to create a split.
      (default: 0.0)
  
  Returns
  -------
  :py:class:`DecisionTreeModel`
  
  Examples
  --------
  >>> from numpy import array
  >>> from pyspark.mllib.regression import LabeledPoint
  >>> from pyspark.mllib.tree import DecisionTree
  >>>
  >>> data = [
  ...     LabeledPoint(0.0, [0.0]),
  ...     LabeledPoint(1.0, [1.0]),
  ...     LabeledPoint(1.0, [2.0]),
  ...     LabeledPoint(1.0, [3.0])
  ... ]
  >>> model = DecisionTree.trainClassifier(sc.parallelize(data), 2, {})
  >>> print(model)
  DecisionTreeModel classifier of depth 1 with 3 nodes
  
  >>> print(model.toDebugString())
  DecisionTreeModel classifier of depth 1 with 3 nodes
    If (feature 0 <= 0.5)
     Predict: 0.0
    Else (feature 0 > 0.5)
     Predict: 1.0
  >>> model.predict(array([1.0]))
  1.0
  >>> model.predict(array([0.0]))
  0.0
  >>> rdd = sc.parallelize([[1.0], [0.0]])
  >>> model.predict(rdd).collect()
  [1.0, 0.0]
docstr_tok: ["Train","a","decision","tree","model","for","classification",".","..","versionadded",":",":","1.1.0","Parameters","--","--","--","--","--","data",":",":","py",":","class",":","`","pyspark.RDD","`","Training","data",":","RDD","of","LabeledPoint",".","Labels","should","take","values","{","0",",","1",",","...",",","numClasses-1","}",".","numClasses",":","int","Number","of","classes","for","classification",".","categoricalFeaturesInfo",":","dict","Map","storing","arity","of","categorical","features",".","An","entry","(","n","-",">","k",")","indicates","that","feature","n","is","categorical","with","k","categories","indexed","from","0",":","{","0",",","1",",","...",",","k-1","}",".","impurity",":","str",",","optional","Criterion","used","for","information","gain","calculation",".","Supported","values",":","``","gini","''","or","``","entropy","''",".","(","default",":","``","gini","''",")","maxDepth",":","int",",","optional","Maximum","depth","of","tree","(","e.g",".","depth","0","means","1","leaf","node",",","depth","1","means","1","internal","node","+","2","leaf","nodes",")",".","(","default",":","5",")","maxBins",":","int",",","optional","Number","of","bins","used","for","finding","splits","at","each","node",".","(","default",":","32",")","minInstancesPerNode",":","int",",","optional","Minimum","number","of","instances","required","at","child","nodes","to","create","the","parent","split",".","(","default",":","1",")","minInfoGain",":","float",",","optional","Minimum","info","gain","required","to","create","a","split",".","(","default",":","0.0",")","Returns","--","--","--","-",":","py",":","class",":","`","DecisionTreeModel","`","Examples","--","--","--","--",">",">",">","from","numpy","import","array",">",">",">","from","pyspark.mllib.regression","import","LabeledPoint",">",">",">","from","pyspark.mllib.tree","import","DecisionTree",">",">",">",">",">",">","data","=","[","...","LabeledPoint","(","0.0",",","[","0.0","]",")",",","...","LabeledPoint","(","1.0",",","[","1.0","]",")",",","...","LabeledPoint","(","1.0",",","[","2.0","]",")",",","...","LabeledPoint","(","1.0",",","[","3.0","]",")","...","]",">",">",">","model","=","DecisionTree.trainClassifier","(","sc.parallelize","(","data",")",",","2",",","{","}",")",">",">",">","print","(","model",")","DecisionTreeModel","classifier","of","depth","1","with","3","nodes",">",">",">","print","(","model.toDebugString","(",")",")","DecisionTreeModel","classifier","of","depth","1","with","3","nodes","If","(","feature","0","<","=","0.5",")","Predict",":","0.0","Else","(","feature","0",">","0.5",")","Predict",":","1.0",">",">",">","model.predict","(","array","(","[","1.0","]",")",")","1.0",">",">",">","model.predict","(","array","(","[","0.0","]",")",")","0.0",">",">",">","rdd","=","sc.parallelize","(","[","[","1.0","]",",","[","0.0","]","]",")",">",">",">","model.predict","(","rdd",")",".collect","(",")","[","1.0",",","0.0","]"]
code: def trainClassifier(
      cls,
      data: RDD[LabeledPoint],
      numClasses: int,
      categoricalFeaturesInfo: Dict[int, int],
      impurity: str = "gini",
      maxDepth: int = 5,
      maxBins: int = 32,
      minInstancesPerNode: int = 1,
      minInfoGain: float = 0.0,
  ) -> DecisionTreeModel:
      """
      Train a decision tree model for classification.
  
      .. versionadded:: 1.1.0
  
      Parameters
      ----------
      data :  :py:class:`pyspark.RDD`
          Training data: RDD of LabeledPoint. Labels should take values
          {0, 1, ..., numClasses-1}.
      numClasses : int
          Number of classes for classification.
      categoricalFeaturesInfo : dict
          Map storing arity of categorical features. An entry (n -> k)
          indicates that feature n is categorical with k categories
          indexed from 0: {0, 1, ..., k-1}.
      impurity : str, optional
          Criterion used for information gain calculation.
          Supported values: "gini" or "entropy".
          (default: "gini")
      maxDepth : int, optional
          Maximum depth of tree (e.g. depth 0 means 1 leaf node, depth 1
          means 1 internal node + 2 leaf nodes).
          (default: 5)
      maxBins : int, optional
          Number of bins used for finding splits at each node.
          (default: 32)
      minInstancesPerNode : int, optional
          Minimum number of instances required at child nodes to create
          the parent split.
          (default: 1)
      minInfoGain : float, optional
          Minimum info gain required to create a split.
          (default: 0.0)
  
      Returns
      -------
      :py:class:`DecisionTreeModel`
  
      Examples
      --------
      >>> from numpy import array
      >>> from pyspark.mllib.regression import LabeledPoint
      >>> from pyspark.mllib.tree import DecisionTree
      >>>
      >>> data = [
      ...     LabeledPoint(0.0, [0.0]),
      ...     LabeledPoint(1.0, [1.0]),
      ...     LabeledPoint(1.0, [2.0]),
      ...     LabeledPoint(1.0, [3.0])
      ... ]
      >>> model = DecisionTree.trainClassifier(sc.parallelize(data), 2, {})
      >>> print(model)
      DecisionTreeModel classifier of depth 1 with 3 nodes
  
      >>> print(model.toDebugString())
      DecisionTreeModel classifier of depth 1 with 3 nodes
        If (feature 0 <= 0.5)
         Predict: 0.0
        Else (feature 0 > 0.5)
         Predict: 1.0
      >>> model.predict(array([1.0]))
      1.0
      >>> model.predict(array([0.0]))
      0.0
      >>> rdd = sc.parallelize([[1.0], [0.0]])
      >>> model.predict(rdd).collect()
      [1.0, 0.0]
      """
      return cls._train(
          data,
          "classification",
          numClasses,
          categoricalFeaturesInfo,
          impurity,
          maxDepth,
          maxBins,
          minInstancesPerNode,
          minInfoGain,
      )
  
imports: import sys
  import random
  from pyspark import RDD, since
  from pyspark.mllib.common import callMLlibFunc, inherit_doc, JavaModelWrapper
  from pyspark.mllib.linalg import _convert_to_vector
  from pyspark.mllib.regression import LabeledPoint
  from pyspark.mllib.util import JavaLoader, JavaSaveable
  from typing import Dict, Optional, Tuple, Union, overload, TYPE_CHECKING
  from pyspark.rdd import RDD
label_desc: Use image node_id 2 for calling the DecisionTree obj's underlying member method code with example usage: obj.trainClassifier(cls, data, numClasses, categoricalFeaturesInfo, impurity, maxDepth, maxBins, minInstancesPerNode, minInfoGain) and returns: cls