Skip to content

Commit

Permalink
add test for regression
Browse files Browse the repository at this point in the history
  • Loading branch information
lokeshh committed Sep 6, 2016
1 parent 5e12ec6 commit c77c190
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
source "https://www.rubygems.org"
gem 'daru', git: '[email protected]:v0dro/daru.git'
gemspec
3 changes: 2 additions & 1 deletion statsample.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }

s.add_runtime_dependency 'daru', '~> 0.1'
# TODO: Uncomment later after Daru release contains category data
# s.add_runtime_dependency 'daru', '~> 0.1'
s.add_runtime_dependency 'spreadsheet', '~> 1.1'
s.add_runtime_dependency 'reportbuilder', '~> 1.4'
s.add_runtime_dependency 'minimization', '~> 0.2'
Expand Down
15 changes: 15 additions & 0 deletions test/fixtures/df.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
y,a,b,c,d,e
0,6,62.1,no,female,A
1,18,34.7,yes,male,B
1,6,29.7,no,female,C
0,4,71,no,male,C
1,5,36.9,yes,male,B
0,11,58.7,no,female,B
0,8,63.3,no,male,B
1,21,20.4,yes,male,A
1,2,20.5,yes,male,C
0,11,59.2,no,male,B
0,1,76.4,yes,female,A
0,8,71.7,no,female,B
1,2,77.5,no,male,C
1,3,31.1,no,male,B
19 changes: 19 additions & 0 deletions test/test_fit_model.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require(File.expand_path(File.dirname(__FILE__) + '/helpers_tests.rb'))
require 'minitest/autorun'

describe Statsample::FitModel do
before do
@df = Daru::DataFrame.from_csv 'test/fixtures/df.csv'
@df.to_category 'c', 'd', 'e'
end
context '#df_for_regression' do
it 'gives correct dataframe when no interaction' do
@formula = 'y~a+e'
@vectors = %w[a e_B e_C y]

@model = Statsample::FitModel.new @formula, @df

@model.df_for_regression.vectors.to_a.sort.must_equal @vectors.sort
end
end
end

0 comments on commit c77c190

Please sign in to comment.