vastorbit.VastFrame.polynomial_comb¶
- VastFrame.polynomial_comb(columns: Annotated[str | list[str], 'STRING representing one column or a list of columns'] | None = None, r: int = 2) VastFrame¶
Returns a VastFrame containing the different product combinations of the input
VastColumn. This function is ideal for bivariate analysis.- Parameters:
columns (SQLColumns, optional) – List of the
VastColumnnames. If empty, all numericalVastColumnare used.r (int, optional) – Degree of the polynomial.
- Returns:
the Polynomial object.
- Return type:
Examples
Let’s begin by importing vastorbit.
import vastorbit as vo
Hint
By assigning an alias to
vastorbit, we mitigate the risk of code collisions with other libraries. This precaution is necessary because vastorbit uses commonly known function names like “average” and “median”, which can potentially lead to naming conflicts. The use of an alias ensures that the functions fromvastorbitare used as intended without interfering with functions from other libraries.Let us create a
VastFramewith multiple columns:vdf = vo.VastFrame( { "col1": [1, 2, 3], "col2": [0, 7, 8], "col3": [3, 11, 93], } )
123col1Integer123col2Integer123col3Integer1 2 7 11 2 1 0 3 3 3 8 93 Rows: 1-3 | Columns: 3We can create a new
VastFramethat has a combination of the original columns using theVastFrame.polynomial_comb()method:new_vdf = vdf.polynomial_comb(r = 2)
123col1Integer123col2Integer123col3Integer123col1_col1Integer123col1_col2Integer123col1_col3Integer123col2_col2Integer123col2_col3Integer123col3_col3Integer1 3 8 93 9 24 279 64 744 8649 2 2 7 11 4 14 22 49 77 121 3 1 0 3 1 0 3 0 0 9 Rows: 1-3 | Columns: 9Note
This function is highly useful for data preparation, as certain combinations of variables may be relevant for predicting a specific column. It can be beneficial to combine it with a correlation matrix to determine if any of the created combinations can influence the response column.
See also
VastFrame.corr(): Computes the correlation matrix.