TD_PolynomialFeaturesFit function stores all the specified values in an argument in a tabular format.
All polynomial combinations of the values with degrees less than or equal to the specified degree are generated. For example, for a 2-D input sample [x, y], the degree-2 polynomial features are [x, y, x-squared, xy, y-squared,1].
Use the TD_PolynomialFeatureFit method to fit a polynomial function to a given dataset. The method involves transforming the original input features into a set of polynomial features, which you can use to fit a polynomial function to the dataset.
For example, a dataset of n observations, where each observation is represented by a set of p input features, X = {x_1, x_2, ..., x_p}, and a target variable, Y. You can represent this dataset as a matrix X of size n x p, where each row represents an observation, and a vector Y of size n.
The TD_PolynomialFeatureFit method involves transforming the input feature matrix X into a new matrix X', where each column of X' represents a polynomial function of the original input features. The degree of the polynomial function used for the transformation is a hyperparameter that needs to be specified.
If the degree of the polynomial function is 2, then the transformed input feature matrix X' would be:
where the first column represents a constant term, and the remaining columns represent the original input features and their pairwise products.
After obtaining the input feature matrix X', you can fit a polynomial function to the dataset by solving the following equation:
Y = X' β + ε
where β is a vector of coefficients that define the polynomial function and ε is a vector of error terms. You can estimate the coefficients β using linear regression techniques, such as ordinary least squares (OLS) regression.
The degree of the polynomial function used for the fit is an important hyperparameter that you need to tune. Higher degree polynomial functions capture more complex relationships, but also run the risk of overfitting the data. Best practice is to balance the complexity of the model with the available data and the desired level of accuracy.