简体   繁体   English

用于生成模型矩阵的Java库

[英]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. 我正在寻找一个Java库,它可以使用公式将输入数据转换为模型矩阵。 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 . 例如,R具有以下model.matrix函数,它允许您通过描述高级formula变量之间的交互来转换输入数据。

Simple example in R 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: 例如,在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 请参阅R文档: 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. 如果您正在寻找看似Matlab的Java版本,那么您可以简单地复制和粘贴它是不可能的....我怀疑有任何软件包会采用您提到的公式。

Nevertheless, look at http://code.google.com/p/efficient-java-matrix-library/ . 不过,请查看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. 请参阅http://code.google.com/p/efficient-java-matrix-library/wiki/MatrixInputOutput,以了解如何制作或可视化以及一般概念。 You should read through the wiki there. 你应该在那里阅读维基。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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