범주형 데이터: 특성 교차
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
특성 교차는 데이터 세트의 두 개 이상의 범주형 또는 버케팅된 특성을 교차 (카티전 프로덕트 계산)하여 만듭니다. 다항식 변환과 마찬가지로 특성 교차를 사용하면 선형 모델이 비선형성을 처리할 수 있습니다. 특성 교차는 특성 간의 상호작용도 인코딩합니다.
예를 들어 다음과 같은 범주형 특성이 있는 리프 데이터 세트를 생각해 보겠습니다.
edges
: smooth
, toothed
, lobed
값을 포함합니다.
arrangement
: opposite
및 alternate
값 포함
위 순서가 원핫 표현식의 특성 열 순서라고 가정하면 smooth
가장자리와 opposite
배열이 있는 리프는 {(1, 0, 0), (1, 0)}
로 표현됩니다.
이 두 특성의 특성 교차 또는 카티언곱은 다음과 같습니다.
{Smooth_Opposite, Smooth_Alternate, Toothed_Opposite, Toothed_Alternate,
Lobed_Opposite, Lobed_Alternate}
여기서 각 항의 값은 기본 지형지물 값의 곱입니다. 예를 들면 다음과 같습니다.
Smooth_Opposite = edges[0] * arrangement[0]
Smooth_Alternate = edges[0] * arrangement[1]
Toothed_Opposite = edges[1] * arrangement[0]
Toothed_Alternate = edges[1] * arrangement[1]
Lobed_Opposite = edges[2] * arrangement[0]
Lobed_Alternate = edges[2] * arrangement[1]
예를 들어 리프에 lobed
가장자리와 alternate
배열이 있는 경우 기능 교차 벡터는 Lobed_Alternate
에 대해 1의 값을 갖고 다른 모든 항목에 대해 0의 값을 갖습니다.
{0, 0, 0, 0, 0, 1}
이러한 특성은 종 내에서 변하지 않으므로 이 데이터 세트를 나무 종별로 잎을 분류하는 데 사용할 수 있습니다.
다항식 변환을 특성 교차와 비교하려면 여기를 클릭하세요.
특성 교차는
다항식 변환과 다소 유사합니다.
두 방법 모두 여러 특성을 결합하여 모델이 학습하여 비선형성을 학습할 수 있는 새로운 합성 특성을 만듭니다. 다항식 변환은 일반적으로 수치 데이터를 결합하는 반면, 특성 교차는 범주형 데이터를 결합합니다.
지형지물 교차를 사용하는 경우
도메인 지식을 통해 교차할 유용한 특성 조합을 제안할 수 있습니다. 이러한 도메인 지식이 없으면 효과적인 기능 교차 또는 다항식 변환을 수동으로 결정하기 어려울 수 있습니다. 계산 비용이 많이 드는 경우 신경망을 사용하여 학습 중에 유용한 기능 조합을 자동으로 찾아 적용하는 것이 가능합니다.
주의하세요. 두 개의 희소한 지형지물을 교차하면 두 개의 원래 지형지물보다 더 희소한 새로운 지형지물이 생성됩니다. 예를 들어 특성 A가 100개 요소의 희소 특성이고 특성 B가 200개 요소의 희소 특성이면 A와 B의 특성 교차는 20,000개 요소의 희소 특성을 생성합니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-05-23(UTC)
[null,null,["최종 업데이트: 2025-05-23(UTC)"],[[["\u003cp\u003eFeature crosses are created by combining two or more categorical or bucketed features to capture interactions and nonlinearities within a dataset.\u003c/p\u003e\n"],["\u003cp\u003eThey enable linear models to handle nonlinearities similar to polynomial transforms, but feature crosses work with categorical data while polynomial transforms are applied to numerical data.\u003c/p\u003e\n"],["\u003cp\u003eFeature crosses can be particularly effective when guided by domain expertise, but using neural networks can automate the process of discovering valuable combinations.\u003c/p\u003e\n"],["\u003cp\u003eOveruse of feature crosses with sparse features should be avoided, as it can lead to excessive sparsity in the resulting feature set.\u003c/p\u003e\n"]]],[],null,["# Categorical data: Feature crosses\n\n[**Feature crosses**](/machine-learning/glossary#feature-cross) are created by\ncrossing (taking the Cartesian product of) two or more categorical or bucketed\nfeatures of the dataset. Like [polynomial\ntransforms](/machine-learning/crash-course/numerical-data/polynomial-transforms),\nfeature crosses allow linear models to handle nonlinearities. Feature crosses\nalso encode interactions between features.\n\nFor example, consider a leaf dataset with the categorical features:\n\n- `edges`, containing values `smooth`, `toothed`, and `lobed`\n- `arrangement`, containing values `opposite` and `alternate`\n\nAssume the order above is the order of the feature columns in a one-hot\nrepresentation, so that a leaf with `smooth` edges and `opposite` arrangement\nis represented as `{(1, 0, 0), (1, 0)}`.\n\nThe feature cross, or Cartesian product, of these two features would be:\n\n`{Smooth_Opposite, Smooth_Alternate, Toothed_Opposite, Toothed_Alternate,\nLobed_Opposite, Lobed_Alternate}`\n\nwhere the value of each term is the product of the base feature values, such\nthat:\n\n- `Smooth_Opposite = edges[0] * arrangement[0]`\n- `Smooth_Alternate = edges[0] * arrangement[1]`\n- `Toothed_Opposite = edges[1] * arrangement[0]`\n- `Toothed_Alternate = edges[1] * arrangement[1]`\n- `Lobed_Opposite = edges[2] * arrangement[0]`\n- `Lobed_Alternate = edges[2] * arrangement[1]`\n\nFor example, if a leaf has a `lobed` edge and an `alternate` arrangement, the\nfeature-cross vector will have a value of 1 for `Lobed_Alternate`, and a value\nof 0 for all other terms:\n\n`{0, 0, 0, 0, 0, 1}`\n\nThis dataset could be used to classify leaves by tree species, since these\ncharacteristics do not vary within a species.\n**Click here to compare polynomial transforms\nwith feature crosses** \n\nFeature crosses are somewhat analogous to\n[Polynomial transforms](/machine-learning/crash-course/numerical-data/polynomial-transforms).\nBoth combine multiple features into a new synthetic feature that the model can\ntrain on to learn nonlinearities. Polynomial transforms typically combine\nnumerical data, while feature crosses combine categorical data.\n\nWhen to use feature crosses\n---------------------------\n\nDomain knowledge can suggest a useful combination of features\nto cross. Without that domain knowledge, it can be difficult to determine\neffective feature crosses or polynomial transforms by hand. It's often possible,\nif computationally expensive, to use\n[neural networks](/machine-learning/crash-course/neural-networks) to\n*automatically* find and apply useful feature combinations during training.\n\nBe careful---crossing two sparse features produces an even sparser new\nfeature than the two original features. For example, if feature A is a\n100-element sparse feature and feature B is a 200-element sparse feature,\na feature cross of A and B yields a 20,000-element sparse feature.\n| **Key terms:**\n|\n| - [Feature cross](/machine-learning/glossary#feature-cross)\n- [Neural network](/machine-learning/glossary#neural_network) \n[Help Center](https://support.google.com/machinelearningeducation)"]]