我正在寻找做对数回归(曲线拟合对数方程)的红宝石或库。我试过statsample(http://ruby-statsample.rubyforge.org/),但它似乎没有我正在寻找的东西。任何人有任何建议?红宝石曲线拟合(对数回归)包
8
A
回答
4
我正在寻找类似的东西,并且遇到了这个answer。
三颗宝石从红宝石其中R交互:
- RinRuby(https://sites.google.com/a/ddahl.org/rinruby-users/)
- RSRuby(https://github.com/alexgutteridge/rsruby)
- Rserve通过Rserve-Ruby的客户端(https://github.com/clbustos/Rserve-Ruby-client)
在Ruby中另一颗宝石为LR:
我还没有尝试过任何东西,但我调查哪些选项有做MLR在Ruby中。
11
尝试使用'statsample'宝石。您可以使用类似的方法执行指数,对数,功率,正弦曲线或任何其他转换。我希望这有帮助。
require 'statsample'
# Independent Variable
x_data = [Math.exp(1), Math.exp(2), Math.exp(3), Math.exp(4), Math.exp(5)]
# Dependent Variable
y_data = [3, 5, 7, 9, 11]
# Logarithmic Transformation of X data
# Math.log in Ruby has the base of Euler's number 'e' ~= '2.71828',
# instead of the base '10'. Just a note.
log_x_data = x_data.map { |x| Math.log(x) }
# Linear Regression using the Logarithmic Transformation
x_vector = log_x_data.to_vector(:scale)
y_vector = y_data.to_vector(:scale)
ds = {'x'=>x_vector,'y'=>y_vector}.to_dataset
mlr = Statsample::Regression.multiple(ds,'y')
# Prints a statistical summary of the regression
print mlr.summary
# Lists the value of the y-intercept
p mlr.constant
# Lists the coefficients of each casual variable. In this case, we have only one--'x'.
p mlr.coeffs
# The regression output produces the line y = 1 + 2*x, but
# considering that we transformed x earlier, it really produces
# y = 1 + 2*ln(x).
# Bonus: The command below lists the methods contained in the instance variable, so that
# you can get the R^2, SSE, coefficients, and t-values. I'll leave it commented out for now.
# p mlr.methods
+0
我想知道如果这是一个“对数转换”的情况下代码的样子。我试图计算对数趋势线,但似乎statsample的文档已过时。有任何想法吗? – 2016-03-17 22:28:26
相关问题
- 1. 红宝石递归函数
- 2. 红宝石:递归
- 3. ROC曲线的红宝石实现
- 4. 红宝石:阶乘递归
- 5. 包括红宝石
- 6. 红宝石数组对象
- 7. 红宝石包括返回false和nil
- 8. 合并两个红宝石对象
- 9. 曲线拟合
- 10. 多线程红宝石
- 11. 删除“”从线红宝石
- 12. 红宝石线程块?
- 13. 红宝石重复线程
- 14. 印刷线红宝石
- 15. Watir的红宝石线程
- 16. 红宝石线程池
- 17. 红宝石:在“ATTR”有回调对象
- 18. 红宝石包含问题
- 19. 包括使用红宝石
- 20. 词包括红宝石
- 21. 合并红宝石阵列
- 22. 结合HTML和红宝石
- 23. 合并和红宝石
- 24. 红宝石散列组合
- 25. 拼合红宝石阵列
- 26. 最好的红宝石绑定/宝石卷曲/ libcurl
- 27. 红宝石轨道:回形针和红宝石Mp3Info
- 28. 红宝石,等待回调
- 29. 返回范围红宝石
- 30. 红宝石GSUB返回值
我不确定您是否熟悉ruby-toolbox.com,但它帮助我找到适合我的大部分项目的库/插件。 – Maran 2010-10-08 20:50:52