Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update project structure

  • Loading branch information...
commit bb9327b54b8d953d1959fa44abece372f43aa884 1 parent d1dce9b
@igrigorik authored
View
19 ..gemspec
@@ -1,19 +0,0 @@
-# -*- encoding: utf-8 -*-
-lib = File.expand_path('../lib', __FILE__)
-$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
-require './version'
-
-Gem::Specification.new do |gem|
- gem.name = "."
- gem.version = .::VERSION
- gem.authors = ["Chris Nelson"]
- gem.email = ["chris@gaslightsoftware.com"]
- gem.description = %q{TODO: Write a gem description}
- gem.summary = %q{TODO: Write a gem summary}
- gem.homepage = ""
-
- gem.files = `git ls-files`.split($/)
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
- gem.require_paths = ["lib"]
-end
View
17 CHANGELOG.txt
@@ -1,17 +0,0 @@
-0.1.0 - Apr. 04/07
- * ID3 algorithms for continuous and discrete cases
- * Graphviz component to visualize the learned tree
-
-0.2.0 - Jul. 07/07
- * Modified and improved by Jose Ignacio (joseignacio.fernandez@gmail.com)
- * Added support for multiple, and symbolic outputs and graphing of continuos trees.
- * Modified to return the default value when no branches are suitable for the input.
- * Refactored entropy code.
-
-0.3.0 - Sept. 15/07
- * ID3Tree can now handle inconsistent datasets.
- * Ruleset is a new class that trains an ID3Tree with 2/3 of the training data,
- converts it into a set of rules and prunes the rules with the remaining 1/3
- of the training data (in a C4.5 way).
- * Bagging is a bagging-based trainer (quite obvious), which trains 10 Ruleset
- trainers and when predicting chooses the best output based on voting.
View
22 Rakefile
@@ -1,19 +1,7 @@
-require 'rake'
+require 'bundler'
+Bundler::GemHelper.install_tasks
-begin
- require 'jeweler'
- Jeweler::Tasks.new do |gemspec|
- gemspec.name = "decisiontree"
- gemspec.summary = "ID3-based implementation of the M.L. Decision Tree algorithm"
- gemspec.description = gemspec.summary
- gemspec.email = "ilya@igvita.com"
- gemspec.homepage = "http://github.com/igrigorik/decisiontree"
- gemspec.authors = ["Ilya Grigorik"]
- gemspec.rubyforge_project = "decisiontree"
- end
-
- Jeweler::GemcutterTasks.new
-rescue LoadError
- puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
-end
+require 'rspec/core/rake_task'
+RSpec::Core::RakeTask.new
+task :default => :spec
View
71 decisiontree.gemspec
@@ -1,64 +1,25 @@
-# Generated by jeweler
-# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
Gem::Specification.new do |s|
- s.name = %q{decisiontree}
- s.version = "0.3.2"
+ s.name = "decisiontree"
+ s.version = "0.4.0"
+ s.platform = Gem::Platform::RUBY
+ s.authors = ["Ilya Grigorik"]
+ s.email = ["ilya@igvita.com"]
+ s.homepage = "https://github.com/igrigorik/decisiontree"
+ s.summary = %q{ID3-based implementation of the M.L. Decision Tree algorithm}
+ s.description = s.summary
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Ilya Grigorik"]
- s.date = %q{2010-10-03}
- s.description = %q{ID3-based implementation of the M.L. Decision Tree algorithm}
- s.email = %q{ilya@igvita.com}
- s.extra_rdoc_files = [
- "README.rdoc"
- ]
- s.files = [
- "CHANGELOG.txt",
- "README.rdoc",
- "Rakefile",
- "VERSION",
- "decisiontree.gemspec",
- "examples/continuous-id3.rb",
- "examples/data/continuous-test.txt",
- "examples/data/continuous-training.txt",
- "examples/data/discrete-test.txt",
- "examples/data/discrete-training.txt",
- "examples/discrete-id3.rb",
- "examples/simple.rb",
- "lib/decisiontree.rb",
- "lib/decisiontree/id3_tree.rb",
- "test/helper.rb",
- "test/test_decisiontree.rb"
- ]
- s.homepage = %q{http://github.com/igrigorik/decisiontree}
- s.rdoc_options = ["--charset=UTF-8"]
- s.require_paths = ["lib"]
- s.rubyforge_project = %q{decisiontree}
- s.rubygems_version = %q{1.3.7}
- s.summary = %q{ID3-based implementation of the M.L. Decision Tree algorithm}
- s.test_files = [
- "test/helper.rb",
- "test/test_decisiontree.rb",
- "examples/continuous-id3.rb",
- "examples/discrete-id3.rb",
- "examples/simple.rb"
- ]
- s.add_runtime_dependency "graphr"
+ s.rubyforge_project = "decisiontree"
+
+ s.add_development_dependency "graphr"
s.add_development_dependency "rspec"
s.add_development_dependency "rspec-given"
s.add_development_dependency "pry"
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- else
- end
- else
- end
+ s.files = `git ls-files`.split("\n")
+ 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.require_paths = ["lib"]
end
-
View
15 spec/id3_spec.rb
@@ -2,6 +2,20 @@
describe describe DecisionTree::ID3Tree do
+ describe "simple discrete case" do
+ 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 }
+ Then { tree.predict([1,0]).should == 1 }
+ Then { tree.predict([0,1]).should == 0 }
+ end
+
describe "discrete attributes" do
Given(:labels) { ["hungry", "color"] }
Given(:data) do
@@ -60,5 +74,4 @@
Then { tree.predict([2, "blue"]).should == "not angry" }
end
-
end
View
3  test/helper.rb
@@ -1,3 +0,0 @@
-require 'rubygems'
-require 'spec'
-require 'lib/decisiontree'
View
22 test/test_decisiontree.rb
@@ -1,22 +0,0 @@
-require 'test/helper.rb'
-
-describe DecisionTree::ID3Tree do
-
- it "should work with a discrete dataset" do
- labels = %w(sun rain)
- data = [
- [1,0,1],
- [0,1,0]
- ]
-
- dec_tree = DecisionTree::ID3Tree.new(labels, data, 1, :discrete)
- dec_tree.train
-
- dec_tree.predict([1,0]).should == 1
- dec_tree.predict([0,1]).should == 0
- end
-
- it "should work with continuous dataset"
-
-end
-

0 comments on commit bb9327b

Please sign in to comment.
Something went wrong with that request. Please try again.