This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
n = 10000 | |
df = Daru::DataFrame.new({ | |
a: Statsample::Shorthand.rnorm(n), | |
b: Statsample::Shorthand.rnorm(n), | |
c: Statsample::Shorthand.rnorm(n), | |
d: Statsample::Shorthand.rnorm(n), | |
}) | |
df[:y] = df.a * 3 + df.b * 5 + df.c * -2 + df.d * 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ruby-prof' | |
n = 100000 | |
dv = Daru::Vector.new 1..n | |
RubyProf.start | |
100.times { dv.reject_values nil } | |
result = RubyProf.stop | |
printer = RubyProf::GraphHtmlPrinter.new(result) | |
printer.print(File.open('cache.html', 'w')) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'statsample' | |
require 'benchmark' | |
n = 10000 | |
df = Daru::DataFrame.new({ | |
a: Statsample::Shorthand.rnorm(n), | |
b: Statsample::Shorthand.rnorm(n), | |
c: Statsample::Shorthand.rnorm(n), | |
d: Statsample::Shorthand.rnorm(n), | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Failures: | |
1) Daru::DataFrame#summary produces a summary of data frame | |
Failure/Error: | |
tuple.flatten.each_with_index | |
.all? { |tup, i| @levels[i][tup] } | |
NoMethodError: | |
undefined method `flatten' for :report_building_text:Symbol | |
# ./lib/daru/index.rb:501:in `include?' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1] pry(main)> ds = Daru::DataFrame.new({ | |
[1] pry(main)* a: [1.2, 2.3, 3.1], | |
[1] pry(main)* b: [4.20, 5.6, 1.1], | |
[1] pry(main)* c: [1.1, 2.2, 6.6]}) | |
=> #<Daru::DataFrame(3x3)> | |
a b c | |
0 1.2 4.2 1.1 | |
1 2.3 5.6 2.2 | |
2 3.1 1.1 6.6 | |
[2] pry(main)> x = Statsample::Regression.multiple ds, :c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> try = Daru::DataFrame.from_csv 'try.csv' | |
> Statsample::GLM.compute try, 'y', :logistic | |
ExceptionForMatrix::ErrNotRegular: Not Regular Matrix | |
from /home/ubuntu/.rvm/gems/ruby-2.2.3/gems/backports-3.6.8/lib/backports/1.9.2/stdlib/matrix.rb:933:in `block in inverse_from' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[16] pry(main)> k | |
=> #<Daru::DataFrame(14x4)> | |
b c_no c_yes y | |
0 62.1 1 0 0 | |
1 74.7 0 1 1 | |
2 69.7 1 0 1 | |
3 71 1 0 0 | |
4 56.9 1 0 1 | |
5 58.7 1 0 0 | |
6 63.3 1 0 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> model = glm(y ~ a + e + c:d + e:d, data=data, family='binomial') | |
> summary(model) | |
Call: | |
glm(formula = y ~ a + e + c:d + e:d, family = "binomial", data = data) | |
Deviance Residuals: | |
Min 1Q Median 3Q Max | |
-1.4049 -0.7803 -0.1191 0.9512 1.6154 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
y a b c d e | |
0 6 62.1 no male A | |
1 18 74.7 yes female B | |
1 16 69.7 no female A | |
0 14 71 no male C | |
1 5 56.9 no male B | |
0 11 58.7 no female B | |
0 8 63.3 no male B | |
1 11 70.4 no male A | |
1 15 70.5 no male C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'daru' | |
require 'memory_profiler' | |
report = MemoryProfiler.report do | |
@a = ['a'*1000]*1000 | |
end | |
report.pretty_print | |
# Total allocated: 9161 bytes (4 objects) | |
# Total retained: 9081 bytes (2 objects) |