Select attributes by their score/rank/weights, depending on the cutoff that may be specified by the percentage of the highest ranked attributes or by the number of the highest ranked attributes.

cut_attrs(attrs, k = 0.5)

Arguments

attrs

A data.frame with attributes' importance.

k

A numeric. For k >= 1 it takes floor(k) and then it indicates how many attributes to take with the highest attribute rank (chooses k best attributes). For 0 < k < 1 it stands for the percent of top attributes to take (chooses best k * 100% of attributes).

Examples

x <- information_gain(Species ~ ., iris) cut_attrs(attrs = x)
#> [1] "Petal.Width" "Petal.Length"
to_formula(cut_attrs(attrs = x), "Species")
#> Species ~ Petal.Width + Petal.Length #> <environment: 0x5611e779d2b8>
cut_attrs(attrs = x, k = 1)
#> [1] "Petal.Width"