Skip to content

max

MaxTransformer ¤

MaxTransformer(
    inputCol=None,
    inputCols=None,
    outputCol=None,
    inputDtype=None,
    outputDtype=None,
    layerName=None,
    mathFloatConstant=None,
)

Bases: BaseTransformer, SingleInputSingleOutputParams, MultiInputSingleOutputParams, MathFloatConstantParams

MaxLayer Spark Transformer for use in Spark pipelines. This transformer gets the max of a column and a constant or another column.

Initializes an MaxTransformer transformer.

Parameters:

Name Type Description Default
inputCol Optional[str]

Input column name. Only used if inputCols is not specified. If specified, we max this column by the mathFloatConstant.

None
inputCols Optional[List[str]]

Input column names.

None
outputCol Optional[str]

Output column name.

None
inputDtype Optional[str]

Input data type to cast input column(s) to before transforming.

None
outputDtype Optional[str]

Output data type to cast the output column to after transforming.

None
layerName Optional[str]

Name of the layer. Used as the name of the Keras layer in the keras model. If not set, we use the uid of the Spark transformer.

None
mathFloatConstant Optional[float]

Optional constant to use for max op. If not provided, then two input columns are required.

None

Returns:

Type Description
None

None - class instantiated.

Source code in src/kamae/spark/transformers/max.py
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
@keyword_only
def __init__(
    self,
    inputCol: Optional[str] = None,
    inputCols: Optional[List[str]] = None,
    outputCol: Optional[str] = None,
    inputDtype: Optional[str] = None,
    outputDtype: Optional[str] = None,
    layerName: Optional[str] = None,
    mathFloatConstant: Optional[float] = None,
) -> None:
    """
    Initializes an MaxTransformer transformer.

    :param inputCol: Input column name. Only used if inputCols is not specified.
    If specified, we max this column by the mathFloatConstant.
    :param inputCols: Input column names.
    :param outputCol: Output column name.
    :param inputDtype: Input data type to cast input column(s) to before
    transforming.
    :param outputDtype: Output data type to cast the output column to after
    transforming.
    :param layerName: Name of the layer. Used as the name of the Keras layer
    in the keras model. If not set, we use the uid of the Spark transformer.
    :param mathFloatConstant: Optional constant to use for max op. If not provided,
    then two input columns are required.
    :returns: None - class instantiated.
    """
    super().__init__()
    self._setDefault(mathFloatConstant=None)
    kwargs = self._input_kwargs
    self.setParams(**kwargs)

compatible_dtypes property ¤

compatible_dtypes

List of compatible data types for the layer. If the computation can be performed on any data type, return None.

Returns:

Type Description
Optional[List[DataType]]

List of compatible data types for the layer.

get_keras_layer ¤

get_keras_layer()

Gets the Keras layer for the max transformer.

Returns:

Type Description
Layer

Keras layer with name equal to the layerName parameter that performs a max operation.

Source code in src/kamae/spark/transformers/max.py
140
141
142
143
144
145
146
147
148
149
150
151
152
def get_keras_layer(self) -> keras.layers.Layer:
    """
    Gets the Keras layer for the max transformer.

    :returns: Keras layer with name equal to the layerName parameter that
     performs a max operation.
    """
    return MaxLayer(
        name=self.getLayerName(),
        input_dtype=self.getInputKerasDtype(),
        output_dtype=self.getOutputKerasDtype(),
        max_constant=self.getMathFloatConstant(),
    )