Class/Object

ai.catboost.spark

Pool

Related Docs: object Pool | package spark

Permalink

class Pool extends Params with HasLabelCol with HasFeaturesCol with HasWeightCol with Logging

CatBoost's abstraction of a dataset.

Features data can be stored in raw (features column has org.apache.spark.ml.linalg.Vector type) or quantized (float feature values are quantized into integer bin values, features column has Array[Byte] type) form.

Raw Pool can be transformed to quantized form using quantize method. This is useful if this dataset is used for training multiple times and quantization parameters do not change. Pre-quantized Pool allows to cache quantized features data and so do not re-run feature quantization step at the start of an each training.

Linear Supertypes
Logging, HasWeightCol, HasFeaturesCol, HasLabelCol, Params, Serializable, Serializable, Identifiable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Pool
  2. Logging
  3. HasWeightCol
  4. HasFeaturesCol
  5. HasLabelCol
  6. Params
  7. Serializable
  8. Serializable
  9. Identifiable
  10. AnyRef
  11. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Pool(data: DataFrame, pairsData: DataFrame)

    Permalink

    Construct Pool from DataFrame also specifying pairs data in an additional DataFrame

    Construct Pool from DataFrame also specifying pairs data in an additional DataFrame

    Example:
    1. val spark = SparkSession.builder()
        .master("local[4]")
        .appName("PoolWithPairsTest")
        .getOrCreate();
      val srcData = Seq(
        Row(Vectors.dense(0.1, 0.2, 0.11), "0.12", 0x0L, 0.12f, 0),
        Row(Vectors.dense(0.97, 0.82, 0.33), "0.22", 0x0L, 0.18f, 1),
        Row(Vectors.dense(0.13, 0.22, 0.23), "0.34", 0x1L, 1.0f, 2),
        Row(Vectors.dense(0.23, 0.01, 0.0), "0.0", 0x1L, 1.2f, 3)
      )
      val srcDataSchema = Seq(
        StructField("features", SQLDataTypes.VectorType),
        StructField("label", StringType),
        StructField("groupId", LongType),
        StructField("weight", FloatType)
        StructField("sampleId", LongType)
      )
      val df = spark.createDataFrame(spark.sparkContext.parallelize(srcData), StructType(srcDataSchema))
      val srcPairsData = Seq(
        Row(0x0L, 0, 1),
        Row(0x1L, 3, 2)
      )
      val srcPairsDataSchema = Seq(
        StructField("groupId", LongType),
        StructField("winnerId", IntegerType),
        StructField("loserId", IntegerType)
      )
      val pairsDf = spark.createDataFrame(
        spark.sparkContext.parallelize(srcPairsData),
        StructType(srcPairsDataSchema)
      )
      val pool = new Pool(df, pairsDf)
        .setGroupIdCol("groupId")
        .setWeightCol("weight")
        .setSampleIdCol("sampleId")
      pool.data.show()
      pool.pairsData.show()
  2. new Pool(data: DataFrame)

    Permalink

    Construct Pool from DataFrame Call set*Col methods to specify non-default columns.

    Construct Pool from DataFrame Call set*Col methods to specify non-default columns. Only features and label columns with "features" and "label" names are assumed by default.

    Example:
    1. val spark = SparkSession.builder()
        .master("local[4]")
        .appName("PoolTest")
        .getOrCreate();
      val srcData = Seq(
        Row(Vectors.dense(0.1, 0.2, 0.11), "0.12", 0x0L, 0.12f),
        Row(Vectors.dense(0.97, 0.82, 0.33), "0.22", 0x0L, 0.18f),
        Row(Vectors.dense(0.13, 0.22, 0.23), "0.34", 0x1L, 1.0f)
      )
      val srcDataSchema = Seq(
        StructField("features", SQLDataTypes.VectorType),
        StructField("label", StringType),
        StructField("groupId", LongType),
        StructField("weight", FloatType)
      )
      val df = spark.createDataFrame(spark.sparkContext.parallelize(srcData), StructType(srcDataSchema))
      val pool = new Pool(df)
        .setGroupIdCol("groupId")
        .setWeightCol("weight")
      pool.data.show()
  3. new Pool(uid: String, data: DataFrame = null, featuresLayout: TFeaturesLayoutPtr = null, quantizedFeaturesInfo: QuantizedFeaturesInfoPtr = null, pairsData: DataFrame = null, partitionedByGroups: Boolean = false)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def $[T](param: Param[T]): T

    Permalink
    Attributes
    protected
    Definition Classes
    Params
  4. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. final val baselineCol: Param[String]

    Permalink
  7. def cache(): Pool

    Permalink

    Persist Datasets of this Pool with the default storage level (MEMORY_AND_DISK).

  8. def calcNanModesAndBorders(nanModeAndBordersBuilder: TNanModeAndBordersBuilder, quantizationParams: QuantizationParamsTrait): Unit

    Permalink
    Attributes
    protected
  9. def checkpoint(): Pool

    Permalink

    Returns Pool with eagerly checkpointed Datasets.

  10. def checkpoint(eager: Boolean): Pool

    Permalink

    Returns Pool with checkpointed Datasets.

    Returns Pool with checkpointed Datasets.

    eager

    Whether to checkpoint Datasets immediately

  11. final def clear(param: Param[_]): Pool.this.type

    Permalink
    Definition Classes
    Params
  12. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  13. def copy(extra: ParamMap): Pool

    Permalink
    Definition Classes
    Pool → Params
  14. def copyValues[T <: Params](to: T, extra: ParamMap): T

    Permalink
    Attributes
    protected
    Definition Classes
    Params
  15. def copyWithModifiedData(modifiedData: DataFrame, partitionedByGroups: Boolean = false): Pool

    Permalink

    used to add additional columns to data (for example estimated features) It is impossible to just write an external function for this because copyValues is protected

  16. def count: Long

    Permalink

    returns

    Number of objects in the dataset, similar to the same method of org.apache.spark.sql.Dataset

  17. def createQuantizationSchema(quantizationParams: QuantizationParamsTrait): QuantizedFeaturesInfoPtr

    Permalink
    Attributes
    protected
  18. def createQuantized(quantizedFeaturesInfo: QuantizedFeaturesInfoPtr): Pool

    Permalink
    Attributes
    protected
  19. val data: DataFrame

    Permalink
  20. final def defaultCopy[T <: Params](extra: ParamMap): T

    Permalink
    Attributes
    protected
    Definition Classes
    Params
  21. def ensurePartitionByGroupsIfPresent(): Pool

    Permalink

    ensure that if groups are present data in partitions contains whole groups in consecutive order

  22. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  23. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  24. def explainParam(param: Param[_]): String

    Permalink
    Definition Classes
    Params
  25. def explainParams(): String

    Permalink
    Definition Classes
    Params
  26. final def extractParamMap(): ParamMap

    Permalink
    Definition Classes
    Params
  27. final def extractParamMap(extra: ParamMap): ParamMap

    Permalink
    Definition Classes
    Params
  28. final val featuresCol: Param[String]

    Permalink
    Definition Classes
    HasFeaturesCol
  29. var featuresLayout: TFeaturesLayoutPtr

    Permalink
    Attributes
    protected
  30. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  31. final def get[T](param: Param[T]): Option[T]

    Permalink
    Definition Classes
    Params
  32. final def getBaselineCol: String

    Permalink
  33. def getBaselineCount: Int

    Permalink

    returns

    dimension of formula baseline, 0 if no baseline specified

  34. def getCatFeaturesUniqValueCounts: Array[Int]

    Permalink
  35. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  36. final def getDefault[T](param: Param[T]): Option[T]

    Permalink
    Definition Classes
    Params
  37. def getEstimatedFeatureCount: Int

    Permalink
  38. def getFeatureCount: Int

    Permalink
  39. def getFeatureNames: Array[String]

    Permalink
  40. final def getFeaturesCol: String

    Permalink
    Definition Classes
    HasFeaturesCol
  41. def getFeaturesLayout: TFeaturesLayoutPtr

    Permalink
  42. final def getGroupIdCol: String

    Permalink
  43. final def getGroupWeightCol: String

    Permalink
  44. final def getLabelCol: String

    Permalink
    Definition Classes
    HasLabelCol
  45. final def getOrDefault[T](param: Param[T]): T

    Permalink
    Definition Classes
    Params
  46. def getParam(paramName: String): Param[Any]

    Permalink
    Definition Classes
    Params
  47. final def getSampleIdCol: String

    Permalink
  48. final def getSubgroupIdCol: String

    Permalink
  49. def getTargetType: ERawTargetType

    Permalink
  50. final def getTimestampCol: String

    Permalink
  51. final def getWeightCol: String

    Permalink
    Definition Classes
    HasWeightCol
  52. final val groupIdCol: Param[String]

    Permalink
  53. final val groupWeightCol: Param[String]

    Permalink
  54. final def hasDefault[T](param: Param[T]): Boolean

    Permalink
    Definition Classes
    Params
  55. def hasParam(paramName: String): Boolean

    Permalink
    Definition Classes
    Params
  56. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  57. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  58. def initializeLogIfNecessary(isInterpreter: Boolean): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  59. final def isDefined(param: Param[_]): Boolean

    Permalink
    Definition Classes
    Params
  60. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  61. def isQuantized: Boolean

    Permalink
  62. final def isSet(param: Param[_]): Boolean

    Permalink
    Definition Classes
    Params
  63. def isTraceEnabled(): Boolean

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  64. final val labelCol: Param[String]

    Permalink
    Definition Classes
    HasLabelCol
  65. def localCheckpoint(): Pool

    Permalink

    Returns Pool with eagerly locally checkpointed Datasets.

  66. def localCheckpoint(eager: Boolean): Pool

    Permalink

    Returns Pool with locally checkpointed Datasets.

    Returns Pool with locally checkpointed Datasets.

    eager

    Whether to checkpoint Datasets immediately

  67. def log: Logger

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  68. def logDebug(msg: ⇒ String, throwable: Throwable): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  69. def logDebug(msg: ⇒ String): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  70. def logError(msg: ⇒ String, throwable: Throwable): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  71. def logError(msg: ⇒ String): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  72. def logInfo(msg: ⇒ String, throwable: Throwable): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  73. def logInfo(msg: ⇒ String): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  74. def logName: String

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  75. def logTrace(msg: ⇒ String, throwable: Throwable): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  76. def logTrace(msg: ⇒ String): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  77. def logWarning(msg: ⇒ String, throwable: Throwable): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  78. def logWarning(msg: ⇒ String): Unit

    Permalink
    Attributes
    protected
    Definition Classes
    Logging
  79. def mapQuantizedPartitions[R](selectedColumns: Seq[String], includeEstimatedFeatures: Boolean, includePairsIfPresent: Boolean, dstColumnNames: Array[String], dstRowLength: Int, f: (TDataProviderPtr, TDataProviderPtr, ArrayBuffer[Array[Any]], TLocalExecutor) ⇒ Iterator[R])(implicit arg0: Encoder[R], arg1: ClassTag[R]): Dataset[R]

    Permalink

    Map over partitions for quantized Pool

  80. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  81. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  82. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  83. def pairsCount: Long

    Permalink

    returns

    Number of pairs in the dataset

  84. val pairsData: DataFrame

    Permalink
  85. lazy val params: Array[Param[_]]

    Permalink
    Definition Classes
    Params
  86. val partitionedByGroups: Boolean

    Permalink
  87. def persist(): Pool

    Permalink

    Persist Datasets of this Pool with the default storage level (MEMORY_AND_DISK).

  88. def persist(storageLevel: StorageLevel): Pool

    Permalink

    Returns Pool with Datasets persisted with the given storage level.

  89. def quantize(quantizedFeaturesInfo: QuantizedFeaturesInfoPtr): Pool

    Permalink

    Create Pool with quantized features from Pool with raw features.

    Create Pool with quantized features from Pool with raw features. This variant of the method is useful if QuantizedFeaturesInfo with data for quantization (borders and nan modes) has already been computed. Used, for example, to quantize evaluation datasets after the training dataset has been quantized.

  90. def quantize(quantizationParams: QuantizationParamsTrait = new QuantizationParams()): Pool

    Permalink

    Create Pool with quantized features from Pool with raw features

    Create Pool with quantized features from Pool with raw features

    Example:
    1. val spark = SparkSession.builder()
        .master("local[*]")
        .appName("QuantizationTest")
        .getOrCreate();
      val srcData = Seq(
        Row(Vectors.dense(0.1, 0.2, 0.11), "0.12"),
        Row(Vectors.dense(0.97, 0.82, 0.33), "0.22"),
        Row(Vectors.dense(0.13, 0.22, 0.23), "0.34")
      )
      val srcDataSchema = Seq(
        StructField("features", SQLDataTypes.VectorType),
        StructField("label", StringType)
      )
      val df = spark.createDataFrame(spark.sparkContext.parallelize(srcData), StructType(srcDataSchema))
      val pool = new Pool(df)
      val quantizedPool = pool.quantize(new QuantizationParams)
      val quantizedPoolWithTwoBinsPerFeature = pool.quantize(new QuantizationParams().setBorderCount(1))
      quantizedPool.data.show()
      quantizedPoolWithTwoBinsPerFeature.data.show()
  91. def quantizeForModelApplication[Model <: PredictionModel[Vector, Model]](model: CatBoostModelTrait[Model]): Pool

    Permalink

    Create Pool with quantized features from Pool with raw features.

    Create Pool with quantized features from Pool with raw features. This variant of the method is used when we want to apply CatBoostModel on Pool

  92. val quantizedFeaturesInfo: QuantizedFeaturesInfoPtr

    Permalink
  93. def repartition(partitionCount: Int, byGroupColumnsIfPresent: Boolean = true): Pool

    Permalink

    Repartition data to the specified number of partitions.

    Repartition data to the specified number of partitions. Useful to repartition data to create one partition per executor for training (where each executor gets its' own CatBoost worker with a part of the training data).

  94. def sample(fraction: Double): Pool

    Permalink

    Create subset of this pool with the fraction of the samples (or groups of samples if present)

  95. final val sampleIdCol: Param[String]

    Permalink
  96. final def set(paramPair: ParamPair[_]): Pool.this.type

    Permalink
    Attributes
    protected
    Definition Classes
    Params
  97. final def set(param: String, value: Any): Pool.this.type

    Permalink
    Attributes
    protected
    Definition Classes
    Params
  98. final def set[T](param: Param[T], value: T): Pool.this.type

    Permalink
    Definition Classes
    Params
  99. final def setBaselineCol(value: String): Pool.this.type

    Permalink
  100. final def setDefault(paramPairs: ParamPair[_]*): Pool.this.type

    Permalink
    Attributes
    protected
    Definition Classes
    Params
  101. final def setDefault[T](param: Param[T], value: T): Pool.this.type

    Permalink
    Attributes
    protected
    Definition Classes
    Params
  102. def setFeaturesCol(value: String): Pool

    Permalink

  103. final def setGroupIdCol(value: String): Pool.this.type

    Permalink
  104. final def setGroupWeightCol(value: String): Pool.this.type

    Permalink
  105. def setLabelCol(value: String): Pool

    Permalink

  106. final def setSampleIdCol(value: String): Pool.this.type

    Permalink
  107. final def setSubgroupIdCol(value: String): Pool.this.type

    Permalink
  108. final def setTimestampCol(value: String): Pool.this.type

    Permalink
  109. def setWeightCol(value: String): Pool

    Permalink

  110. final val subgroupIdCol: Param[String]

    Permalink
  111. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  112. final val timestampCol: Param[String]

    Permalink
  113. def toString(): String

    Permalink
    Definition Classes
    Identifiable → AnyRef → Any
  114. val uid: String

    Permalink
    Definition Classes
    Pool → Identifiable
  115. def unpersist(blocking: Boolean): Pool

    Permalink

    Mark Datasets of this Pool as non-persistent, and remove all blocks for them from memory and disk.

    Mark Datasets of this Pool as non-persistent, and remove all blocks for them from memory and disk.

    blocking

    Whether to block until all blocks are deleted.

  116. def unpersist(): Pool

    Permalink

    Mark Datasets of this Pool as non-persistent, and remove all blocks for them from memory and disk.

  117. def updateCatFeaturesInfo(isInitialization: Boolean, quantizedFeaturesInfo: QuantizedFeaturesInfoPtr): Unit

    Permalink
    Attributes
    protected
  118. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  119. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  120. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  121. final val weightCol: Param[String]

    Permalink
    Definition Classes
    HasWeightCol

Inherited from Logging

Inherited from HasWeightCol

Inherited from HasFeaturesCol

Inherited from HasLabelCol

Inherited from Params

Inherited from Serializable

Inherited from Serializable

Inherited from Identifiable

Inherited from AnyRef

Inherited from Any

Caching and Persistence

setParam

Ungrouped