PolynomialFeatures
Generate polynomial and interaction features up to a specified degree.
Given d input features, this converter produces all monomials of the
form x_1^p_1 * x_2^p_2 * … * x_d^p_d where p_1 + … + p_d <= degree
(and each p_i >= 0). For example, with two input features [a, b]
and degree=2, the output is [1, a, b, a², ab, b²].
When interaction_only=True only cross-terms are retained (no squared
or higher pure-power terms), which is useful when features are already on
a meaningful scale and self-interactions are not informative.
Setting include_bias=True (the default) prepends a column of ones,
acting as an intercept term for linear models that lack an explicit bias.
The order parameter controls whether the dense output array is stored
in C (row-major) or Fortran (column-major) order. "F" order can speed
up the transformation itself but may slow downstream estimators.
Output columns are typed as Float64 in DashAI.
Wraps sklearn.preprocessing.PolynomialFeatures.
References
Parameters
- degree : integer, default=
2 - The degree of the polynomial features.
- interaction_only : boolean, default=
False - If True, only interaction features are produced: features that are products of at most degree distinct input features.
- include_bias : boolean, default=
True - If True (default), then include a bias column (a column of ones that act as an intercept term).
- order : string, default=
C - Order of output array in the dense case. 'F' order is faster to compute, but may slow down subsequent estimators.
Methods
get_output_type(self, column_name: str = None) -> DashAI.back.types.dashai_data_type.DashAIDataType
PolynomialFeaturesReturn Float64 as the output type for all polynomial feature columns.
Parameters
- column_name : str or None, optional
- Name of the output column. Not used — all columns receive the same
Float64type. DefaultNone.
Returns
- Float
- A DashAI
Floattype backed bypyarrow.float64().
changes_row_count(self) -> 'bool'
BaseConverterIndicate whether this converter changes the number of dataset rows.
Returns
- bool
- True if the converter may add or remove rows, False otherwise.
fit(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> DashAI.back.converters.base_converter.BaseConverter
SklearnWrapperFit the scikit-learn transformer to the data.
Parameters
- x : DashAIDataset
- The input dataset to fit the transformer on.
- y : DashAIDataset, optional
- Target values for supervised transformers. Defaults to None.
Returns
- BaseConverter
- The fitted transformer instance (self).
get_metadata(cls) -> 'Dict[str, Any]'
BaseConverterGet metadata for the converter, used by the DashAI frontend.
Parameters
- cls : type
- The converter class (injected automatically by Python for classmethods).
Returns
- Dict[str, Any]
- Dictionary containing display name, short description, image preview path, category, icon, color, and whether the converter is supervised.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
transform(self, x: 'DashAIDataset', y: Optional[ForwardRef('DashAIDataset')] = None) -> 'DashAIDataset'
SklearnWrapperTransform the data using the fitted scikit-learn transformer.
Parameters
- x : DashAIDataset
- The input dataset to transform.
- y : DashAIDataset, optional
- Not used. Present for API consistency. Defaults to None.
Returns
- DashAIDataset
- The transformed dataset with updated DashAI column types.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.