Java library to create a model matrix

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

+4
source share
1 answer

If you are looking for a version of Java that looks like Matlab, so you can simply copy and paste it unlikely .... I doubt there are packages that will accept the formula, as you mentioned.

However, check out http://code.google.com/p/efficient-java-matrix-library/ . Your matrix operations seem extremely simple at a glance and can be programmed using this library.

However, you will need to create your matrix using code so that it is framed accordingly. See http://code.google.com/p/efficient-java-matrix-library/wiki/MatrixInputOutput to help make or visualize the general idea. You must read through the wiki.

0
source

Source: https://habr.com/ru/post/1440612/


All Articles