box <- read.csv("BlackBoxtrainApril22.csv")
#Change the 2 categorical variables into factors
box$SOUND <- as.factor(box$SOUND)
box$SWITCH <- as.factor(box$SWITCH)
#divide training and testing data
train <- box[1:12000,]
test <- box[12001:18048,]
library(nnet)
require(nnet)
multinom_model <- multinom(SOUND ~ ., data=box)
summary(multinom_model)
Here's some output from dput(head(box))
to see what the data looks like:
structure(list(ID = c(86623L, 57936L, 54301L, 2678L, 65827L, 22420L), INPUT1 = c(30L, 87L, 16L, 64L, 33L, 5L), INPUT2 = c(31L, 76L, 33L, 77L, 72L, 50L), INPUT3 = c(72L, 31L, 87L, 91L, 53L, 26L), INPUT4 = c(29L, 79L, 41L, 59L, 66L, 50L), SWITCH = c("Low", "Low", "Low", "Minimum", "High", "High"), SOUND = c("Gargle", "Tick", "Tick", "Beep", "Beep", "Gargle")), row.names = c(NA, 6L), class = "data.frame")
In essence, I'm trying to predict a categorical variable using a combination of numeric and categorical data.
This is my code. When I do a summary, I lose one of the SWITCH
categories and one of SOUND
categories.
I think it has something to do with reference variables, but I'm not exactly sure.