简体   繁体   中英

Java library for generating a model matrix

I'm looking for a Java library which can transform input data into a model matrix using a formula. The formula is not a simple arithmetic equation, rather it describes interactions between variables, maps categorical variables into the appropriate numerical ranges, and generates the transformations on an input vector/matrix.

For example, R has the following model.matrix function, which allows you to transform input data by describing interactions between variables in a high-level formula .

Simple example in R

The input Data:

electric_usage,temperature,time_of_day
30,85,morning
35,80,evening

The formula:

electric_usage ~ temperature * time_of_day

Which is shorthand for the 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

If your looking for a Java version of what appears like Matlab so you can simply copy and paste it is unlikely.... I doubt there are any packages that will take a formula as you mentioned.

Nevertheless, look at http://code.google.com/p/efficient-java-matrix-library/ . Your matrix operations seem extremely simple at first glance and can be programmed using that library.

Nevertheless you will need to create your matrix through code so that it is framed appropriately. See http://code.google.com/p/efficient-java-matrix-library/wiki/MatrixInputOutput to help how to make or visualize and the general idea. You should read through the wiki there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM