[null,null,["最后更新时间 (UTC):2025-03-06。"],[[["\u003cp\u003eSynthetic features, like polynomial transforms, enable linear models to represent non-linear relationships by introducing new features based on existing ones.\u003c/p\u003e\n"],["\u003cp\u003ePolynomial transforms involve raising an existing feature to a power, often informed by domain knowledge, such as physical laws involving squared terms.\u003c/p\u003e\n"],["\u003cp\u003eBy incorporating synthetic features, linear regression models can effectively separate data points that are not linearly separable using curves instead of straight lines.\u003c/p\u003e\n"],["\u003cp\u003eThis approach maintains the simplicity of linear regression while expanding its capacity to capture complex patterns within the data.\u003c/p\u003e\n"],["\u003cp\u003eFeature crosses, a related concept for categorical data, synthesize new features by combining existing features, further enhancing model flexibility.\u003c/p\u003e\n"]]],[],null,["# Numerical data: Polynomial transforms\n\nSometimes, when the ML practitioner has domain knowledge suggesting\nthat one variable is related to the square, cube, or other power of another\nvariable, it's useful to create a\n[**synthetic feature**](/machine-learning/glossary#synthetic_feature) from one\nof the existing numerical [**features**](/machine-learning/glossary#feature).\n\nConsider the following spread of data points, where pink circles represent\none class or category (for example, a species of tree) and green triangles\nanother class (or species of tree):\n**Figure 17.** Two classes that can't be separated by a line.\n\nIt's not possible to draw a straight line that cleanly separates the two\nclasses, but it *is* possible to draw a curve that does so:\n**Figure 18.** Separating the classes with *y = x^2^*.\n\nAs discussed in the\n[Linear regression module](/machine-learning/crash-course/linear-regression),\na linear model with one feature, $x_1$, is described by the linear equation: \n$$y = b + w_1x_1$$\n\nAdditional features are handled by the addition of terms \\\\(w_2x_2\\\\),\n\\\\(w_3x_3\\\\), etc.\n\n[**Gradient descent**](/machine-learning/glossary#gradient_descent) finds the\n[**weight**](/machine-learning/glossary#weight) $w_1$ (or weights\n\\\\(w_1\\\\), \\\\(w_2\\\\), \\\\(w_3\\\\), in the case of additional features) that minimizes\nthe loss of the model. But the data points shown cannot be separated by a line.\nWhat can be done?\n\nIt's possible to keep both the linear equation *and* allow nonlinearity\nby defining a new term, \\\\(x_2\\\\), that is simply \\\\(x_1\\\\) squared: \n$$x_2 = x_1\\^2$$\n\nThis synthetic feature, called a polynomial transform, is treated like any\nother feature. The previous linear formula becomes: \n$$y = b + w_1x_1 + w_2x_2$$\n\nThis can still be treated like a\n[**linear regression**](/machine-learning/glossary#linear_regression)\nproblem, and the weights determined through gradient descent, as usual, despite\ncontaining a hidden squared term, the polynomial transform. Without changing\nhow the linear model trains, the addition of a polynomial transform allows the\nmodel to separate the data points using a curve of the\nform $y = b + w_1x + w_2x\\^2$.\n\nUsually the numerical feature of interest is multiplied by itself, that is,\nraised to some power. Sometimes an ML practitioner can make an informed guess\nabout the appropriate exponent. For example, many relationships in the physical\nworld are related to squared terms,\nincluding acceleration due to gravity, the\nattenuation of light or sound over distance, and elastic potential energy.\n\nIf you transform a feature in a way that changes its scale, you should consider\nexperimenting with normalizing it as well. Normalizing after transforming\nmight make the model perform better. For more information, see\n[Numerical Data: Normalization](/machine-learning/crash-course/numerical-data/normalization).\n\nA related concept in\n[**categorical data**](/machine-learning/glossary#categorical_data) is the\n[**feature cross**](/machine-learning/glossary#feature_cross), which more\nfrequently synthesizes two different features.\n| **Key terms:**\n|\n| - [Categorical data](/machine-learning/glossary#categorical_data)\n| - [Feature](/machine-learning/glossary#feature)\n| - [Feature cross](/machine-learning/glossary#feature_cross)\n| - [Gradient descent](/machine-learning/glossary#gradient_descent)\n| - [Linear regression](/machine-learning/glossary#linear_regression)\n| - [Synthetic feature](/machine-learning/glossary#synthetic_feature)\n- [Weight](/machine-learning/glossary#weight) \n[Help Center](https://support.google.com/machinelearningeducation)"]]