I am looking for a Java library that can convert input to a model matrix using a formula. The formula is not a simple arithmetic equation, but rather describes the interactions between variables, displays categorical variables in the corresponding numerical ranges and generates transformations on the input vector / matrix.
For example, R has the following model.matrix function, which allows you to transform input by describing the interactions between variables in a high-level formula .
A simple example in R
Input data:
electric_usage,temperature,time_of_day 30,85,morning 35,80,evening
Formula:
electric_usage ~ temperature * time_of_day
This is an abbreviated formula:
electric_usage ~ temperature + time_of_day + (temperature : time_of_day)
For example, in R:
> model.matrix( electric_usage ~ temperature * time_of_day, data.frame( electric_usage=c(30,35), temperature=c(85,80), time_of_day=c("morning", "evening") ) ) (Intercept) temperature time_of_daymorning temperature:time_of_daymorning 1 85 1 85 1 80 0 0
See R Documentation: http://stat.ethz.ch/R-manual/R-patched/library/stats/html/model.matrix.html
source share