selectFeatures: Machine Learning 기능 선택 변환

기능 선택 변환은 지정된 모드를 사용하여 지정된 변수에서 기능을 선택합니다.

사용

  selectFeatures(vars, mode, ...)

인수

vars

모드가 minCount()인 경우 기능 선택이 수행되는 변수의 이름을 지정하는 수식 또는 문자열의 벡터/목록입니다. 예들 들어 ~ var1 + var2 + var3입니다. mode가 mutualInformation()이면 종속 변수 및 독립 변수를 설명하는 수식 또는 명명된 문자열 목록입니다. 예들 들어 label ~ ``var1 + var2 + var3입니다.

mode

기능 선택 모드를 지정합니다. minCount 또는 mutualInformation일 수 있습니다.

...

Microsoft 컴퓨팅 엔진에 직접 전달할 추가 인수입니다.

세부 정보

기능 선택 변환은 개수 또는 상호 정보라는 두 가지 모드 중 하나를 사용하여 지정된 변수에서 기능을 선택합니다. 자세한 내용은 minCountmutualInformation을 참조하세요.

변환을 정의하는 maml 개체입니다.

참고 항목

minCount mutualInformation


 trainReviews <- data.frame(review = c( 
         "This is great",
         "I hate it",
         "Love it",
         "Do not like it",
         "Really like it",
         "I hate it",
         "I like it a lot",
         "I kind of hate it",
         "I do like it",
         "I really hate it",
         "It is very good",
         "I hate it a bunch",
         "I love it a bunch",
         "I hate it",
         "I like it very much",
         "I hate it very much.",
         "I really do love it",
         "I really do hate it",
         "Love it!",
         "Hate it!",
         "I love it",
         "I hate it",
         "I love it",
         "I hate it",
         "I love it"),
      like = c(TRUE, FALSE, TRUE, FALSE, TRUE,
         FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE,
         FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, 
         FALSE, TRUE, FALSE, TRUE), stringsAsFactors = FALSE
     )

     testReviews <- data.frame(review = c(
         "This is great",
         "I hate it",
         "Love it",
         "Really like it",
         "I hate it",
         "I like it a lot",
         "I love it",
         "I do like it",
         "I really hate it",
         "I love it"), stringsAsFactors = FALSE)

 # Use a categorical hash transform which generated 128 features.
 outModel1 <- rxLogisticRegression(like~reviewCatHash, data = trainReviews, l1Weight = 0, 
     mlTransforms = list(categoricalHash(vars = c(reviewCatHash = "review"), hashBits = 7)))
 summary(outModel1)

 # Apply a categorical hash transform and a count feature selection transform
 # which selects only those hash slots that has value.
 outModel2 <- rxLogisticRegression(like~reviewCatHash, data = trainReviews, l1Weight = 0, 
     mlTransforms = list(
   categoricalHash(vars = c(reviewCatHash = "review"), hashBits = 7), 
   selectFeatures("reviewCatHash", mode = minCount())))
 summary(outModel2)

 # Apply a categorical hash transform and a mutual information feature selection transform
 # which selects only 10 features with largest mutual information with the label.
 outModel3 <- rxLogisticRegression(like~reviewCatHash, data = trainReviews, l1Weight = 0, 
     mlTransforms = list(
   categoricalHash(vars = c(reviewCatHash = "review"), hashBits = 7), 
   selectFeatures(like ~ reviewCatHash, mode = mutualInformation(numFeaturesToKeep = 10))))
 summary(outModel3)