mirror of
https://github.com/dkam/decisiontree.git
synced 2025-12-27 22:54:52 +00:00
Merge pull request #16 from agarie/cleanup_specs
Removes continuous.png file after specs
This commit is contained in:
@@ -48,7 +48,6 @@ describe describe DecisionTree::ID3Tree do
|
|||||||
end
|
end
|
||||||
Given(:tree) { DecisionTree::ID3Tree.new(labels, data, "not angry", :continuous) }
|
Given(:tree) { DecisionTree::ID3Tree.new(labels, data, "not angry", :continuous) }
|
||||||
When { tree.train }
|
When { tree.train }
|
||||||
Then { tree.graph("continuous") }
|
|
||||||
Then { tree.predict([7, 7]).should == "angry" }
|
Then { tree.predict([7, 7]).should == "angry" }
|
||||||
Then { tree.predict([2, 3]).should == "not angry" }
|
Then { tree.predict([2, 3]).should == "not angry" }
|
||||||
end
|
end
|
||||||
@@ -69,7 +68,6 @@ describe describe DecisionTree::ID3Tree do
|
|||||||
end
|
end
|
||||||
Given(:tree) { DecisionTree::ID3Tree.new(labels, data, "not angry", color: :discrete, hunger: :continuous) }
|
Given(:tree) { DecisionTree::ID3Tree.new(labels, data, "not angry", color: :discrete, hunger: :continuous) }
|
||||||
When { tree.train }
|
When { tree.train }
|
||||||
Then { tree.graph("continuous") }
|
|
||||||
Then { tree.predict([7, "red"]).should == "angry" }
|
Then { tree.predict([7, "red"]).should == "angry" }
|
||||||
Then { tree.predict([2, "blue"]).should == "not angry" }
|
Then { tree.predict([2, "blue"]).should == "not angry" }
|
||||||
end
|
end
|
||||||
@@ -105,4 +103,23 @@ describe describe DecisionTree::ID3Tree do
|
|||||||
lambda { tree.predict([1, 1]) }.should_not raise_error
|
lambda { tree.predict([1, 1]) }.should_not raise_error
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "create a figure" do
|
||||||
|
after(:all) do
|
||||||
|
File.delete("#{FIGURE_FILENAME}.png") if File.file?("#{FIGURE_FILENAME}.png")
|
||||||
|
end
|
||||||
|
|
||||||
|
Given(:labels) { ["sun", "rain"]}
|
||||||
|
Given(:data) do
|
||||||
|
[
|
||||||
|
[1,0,1],
|
||||||
|
[0,1,0]
|
||||||
|
]
|
||||||
|
end
|
||||||
|
Given(:tree) { DecisionTree::ID3Tree.new(labels, data, 1, :discrete) }
|
||||||
|
When { tree.train }
|
||||||
|
When(:result) { tree.graph(FIGURE_FILENAME) }
|
||||||
|
Then { expect(result).to_not have_failed }
|
||||||
|
And { File.file?("#{FIGURE_FILENAME}.png") }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
require 'rspec/given'
|
require 'rspec/given'
|
||||||
require 'decisiontree'
|
require 'decisiontree'
|
||||||
require 'pry'
|
require 'pry'
|
||||||
|
|
||||||
|
FIGURE_FILENAME = "just_a_spec"
|
||||||
|
|||||||
Reference in New Issue
Block a user