predict.omisvm {mildsvm} | R Documentation |
Predict method for omisvm
object
Description
Predict method for omisvm
object
Usage
## S3 method for class 'omisvm'
predict(
object,
new_data,
type = c("class", "raw"),
layer = c("bag", "instance"),
new_bags = "bag_name",
...
)
Arguments
object |
An object of class |
new_data |
A data frame to predict from. This needs to have all of the features that the data was originally fitted with. |
type |
If |
layer |
If |
new_bags |
A character or character vector. Can specify a singular
character that provides the column name for the bag names in |
... |
Arguments passed to or from other methods. |
Details
When the object was fitted using the formula
method, then the parameters
new_bags
and new_instances
are not necessary, as long as the names match
the original function call.
Value
A tibble with nrow(new_data)
rows. If type = 'class'
, the tibble
will have a column .pred_class
. If type = 'raw'
, the tibble will have
a column .pred
.
Author(s)
Sean Kent
See Also
omisvm()
for fitting the omisvm
object.
Examples
if (require(gurobi)) {
data("ordmvnorm")
x <- ordmvnorm[, 3:7]
y <- ordmvnorm$bag_label
bags <- ordmvnorm$bag_name
mdl1 <- omisvm(x, y, bags, weights = NULL)
# summarize predictions at the bag layer
library(dplyr)
df1 <- bind_cols(y = y, bags = bags, as.data.frame(x))
df1 %>%
bind_cols(predict(mdl1, df1, new_bags = bags, type = "class")) %>%
bind_cols(predict(mdl1, df1, new_bags = bags, type = "raw")) %>%
distinct(y, bags, .pred_class, .pred)
}