Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: SergioFierens/ai4r
base: cef546c35f
...
head fork: SergioFierens/ai4r
compare: 6259ee3e1b
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 28 files changed
  • 0 commit comments
  • 2 contributors
Showing with 49 additions and 44 deletions.
  1. +7 −1 lib/ai4r/classifiers/naive_bayes.rb
  2. +2 −2 test/classifiers/hyperpipes_test.rb
  3. +2 −2 test/classifiers/ib1_test.rb
  4. +2 −2 test/classifiers/id3_test.rb
  5. +2 −2 test/classifiers/multilayer_perceptron_test.rb
  6. +3 −3 test/classifiers/naive_bayes_test.rb
  7. +1 −1  test/classifiers/one_r_test.rb
  8. +1 −1  test/classifiers/prism_test.rb
  9. +2 −2 test/classifiers/zero_r_test.rb
  10. +1 −1  test/clusterers/average_linkage_test.rb
  11. +1 −1  test/clusterers/bisecting_k_means_test.rb
  12. +1 −1  test/clusterers/centroid_linkage_test.rb
  13. +1 −1  test/clusterers/complete_linkage_test.rb
  14. +2 −2 test/clusterers/diana_test.rb
  15. +1 −1  test/clusterers/k_means_test.rb
  16. +1 −1  test/clusterers/median_linkage_test.rb
  17. +1 −1  test/clusterers/single_linkage_test.rb
  18. +1 −1  test/clusterers/ward_linkage_test.rb
  19. +1 −1  test/clusterers/weighted_average_linkage_test.rb
  20. +1 −1  test/data/data_set_test.rb
  21. +2 −2 test/data/proximity_test.rb
  22. +2 −2 test/data/statistics_test.rb
  23. +2 −2 test/experiment/classifier_evaluator_test.rb
  24. +1 −2  test/genetic_algorithm/chromosome_test.rb
  25. +2 −2 test/genetic_algorithm/genetic_algorithm_test.rb
  26. +2 −2 test/neural_network/backpropagation_test.rb
  27. +2 −2 test/neural_network/hopfield_test.rb
  28. +2 −2 test/som/som_test.rb
View
8 lib/ai4r/classifiers/naive_bayes.rb
@@ -54,6 +54,7 @@ module Classifiers
# build data
# b.eval(["Red", "SUV", "Domestic"])
#
+
class NaiveBayes < Classifier
parameters_info :m => "Default value is set to 0. It may be set to a value greater than " +
@@ -150,7 +151,7 @@ def sum(array)
# returns the name of the class when the index is found
def index_to_klass(index)
- @klass_index.has_value?(index) ? @klass_index.index(index) : nil
+ @klass_index.has_value?(index) ? @klass_index.key(index) : nil
end
# initializes @values and @klass_index; maps a certain value to a uniq index
@@ -257,3 +258,8 @@ def [](index)
end
end
end
+
+# Monkeypatch to support both ruby 1.8 and 1.9 (key vs index method)
+class Hash
+ alias_method(:key, :index) unless method_defined?(:key)
+end
View
4 test/classifiers/hyperpipes_test.rb
@@ -7,7 +7,7 @@
# the Mozilla Public License version 1.1 as published by the
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
-require File.dirname(__FILE__) + '/../../lib/ai4r/classifiers/hyperpipes'
+require 'ai4r/classifiers/hyperpipes'
require 'test/unit'
class Ai4r::Classifiers::Hyperpipes
@@ -81,4 +81,4 @@ def test_get_rules
end
end
-
+
View
4 test/classifiers/ib1_test.rb
@@ -7,7 +7,7 @@
# the Mozilla Public License version 1.1 as published by the
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
-require File.dirname(__FILE__) + '/../../lib/ai4r/classifiers/ib1'
+require 'ai4r/classifiers/ib1'
require 'test/unit'
class Ai4r::Classifiers::IB1
@@ -75,4 +75,4 @@ def test_eval
end
-
+
View
4 test/classifiers/id3_test.rb
@@ -12,7 +12,7 @@
# the Mozilla Public License version 1.1 as published by the
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
-require File.dirname(__FILE__) + '/../../lib/ai4r/classifiers/id3'
+require 'ai4r/classifiers/id3'
require 'test/unit'
DATA_LABELS = [ 'city', 'age_range', 'gender', 'marketing_target' ]
@@ -205,4 +205,4 @@ def test_rules_eval
end
end
-
+
View
4 test/classifiers/multilayer_perceptron_test.rb
@@ -1,6 +1,6 @@
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/classifiers/multilayer_perceptron'
-require File.dirname(__FILE__) + '/../../lib/ai4r/data/data_set'
+require 'ai4r/classifiers/multilayer_perceptron'
+require 'ai4r/data/data_set'
# Make all accessors and methods public
class Ai4r::Classifiers::MultilayerPerceptron
View
6 test/classifiers/naive_bayes_test.rb
@@ -1,5 +1,5 @@
-require File.dirname(__FILE__) + '/../../lib/ai4r/classifiers/naive_bayes'
-require File.dirname(__FILE__) + '/../../lib/ai4r/data/data_set'
+require 'ai4r/classifiers/naive_bayes'
+require 'ai4r/data/data_set'
require 'test/unit'
include Ai4r::Classifiers
@@ -40,4 +40,4 @@ def test_get_probability_map
assert_in_delta 0.58, map["No"], 0.1
end
-end
+end
View
2  test/classifiers/one_r_test.rb
@@ -1,5 +1,5 @@
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/classifiers/one_r'
+require 'ai4r/classifiers/one_r'
class OneRTest < Test::Unit::TestCase
View
2  test/classifiers/prism_test.rb
@@ -1,5 +1,5 @@
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/classifiers/prism'
+require 'ai4r/classifiers/prism'
class PrismTest < Test::Unit::TestCase
View
4 test/classifiers/zero_r_test.rb
@@ -1,6 +1,6 @@
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/classifiers/zero_r'
-require File.dirname(__FILE__) + '/../../lib/ai4r/data/data_set'
+require 'ai4r/classifiers/zero_r'
+require 'ai4r/data/data_set'
class ZeroRTest < Test::Unit::TestCase
View
2  test/clusterers/average_linkage_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/clusterers/average_linkage'
+require 'ai4r/clusterers/average_linkage'
class Ai4r::Clusterers::AverageLinkage < Ai4r::Clusterers::SingleLinkage
attr_accessor :data_set, :number_of_clusters, :clusters, :distance_matrix
View
2  test/clusterers/bisecting_k_means_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/clusterers/bisecting_k_means'
+require 'ai4r/clusterers/bisecting_k_means'
class BisectingKMeansTest < Test::Unit::TestCase
View
2  test/clusterers/centroid_linkage_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/clusterers/centroid_linkage'
+require 'ai4r/clusterers/centroid_linkage'
class Ai4r::Clusterers::CentroidLinkage
attr_accessor :data_set, :number_of_clusters, :clusters, :distance_matrix, :index_clusters
View
2  test/clusterers/complete_linkage_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/clusterers/complete_linkage'
+require 'ai4r/clusterers/complete_linkage'
class Ai4r::Clusterers::CompleteLinkage
attr_accessor :data_set, :number_of_clusters, :clusters, :distance_matrix
View
4 test/clusterers/diana_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/clusterers/diana'
+require 'ai4r/clusterers/diana'
class Ai4r::Clusterers::Diana
attr_accessor :data_set, :number_of_clusters, :clusters
@@ -66,4 +66,4 @@ def test_max_distance_difference
max_distance_difference(data_set_a, data_set_b)
end
-end
+end
View
2  test/clusterers/k_means_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/clusterers/k_means'
+require 'ai4r/clusterers/k_means'
class KMeansTest < Test::Unit::TestCase
View
2  test/clusterers/median_linkage_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/clusterers/median_linkage'
+require 'ai4r/clusterers/median_linkage'
class Ai4r::Clusterers::MedianLinkage
attr_accessor :data_set, :number_of_clusters, :clusters, :distance_matrix, :index_clusters
View
2  test/clusterers/single_linkage_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/clusterers/single_linkage'
+require 'ai4r/clusterers/single_linkage'
class Ai4r::Clusterers::SingleLinkage
attr_accessor :data_set, :number_of_clusters, :clusters, :distance_matrix
View
2  test/clusterers/ward_linkage_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/clusterers/ward_linkage'
+require 'ai4r/clusterers/ward_linkage'
class Ai4r::Clusterers::WardLinkage
attr_accessor :data_set, :number_of_clusters, :clusters, :distance_matrix, :index_clusters
View
2  test/clusterers/weighted_average_linkage_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/clusterers/weighted_average_linkage'
+require 'ai4r/clusterers/weighted_average_linkage'
class Ai4r::Clusterers::WeightedAverageLinkage
attr_accessor :data_set, :number_of_clusters, :clusters, :distance_matrix, :index_clusters
View
2  test/data/data_set_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/data/data_set'
+require 'ai4r/data/data_set'
module Ai4r
module Data
View
4 test/data/proximity_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/data/proximity'
+require 'ai4r/data/proximity'
module Ai4r
module Data
@@ -78,4 +78,4 @@ def test_simple_matching_distance
end
end
-end
+end
View
4 test/data/statistics_test.rb
@@ -8,7 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/data/statistics'
+require 'ai4r/data/statistics'
module Ai4r
module Data
@@ -62,4 +62,4 @@ def test_max
end
end
-end
+end
View
4 test/experiment/classifier_evaluator_test.rb
@@ -8,8 +8,8 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
require 'test/unit'
-require File.dirname(__FILE__) + '/../../lib/ai4r/experiment/classifier_evaluator'
-require File.dirname(__FILE__) + '/../../lib/ai4r/classifiers/classifier'
+require 'ai4r/experiment/classifier_evaluator'
+require 'ai4r/classifiers/classifier'
class MockClassifier < Ai4r::Classifiers::Classifier
View
3  test/genetic_algorithm/chromosome_test.rb
@@ -8,8 +8,7 @@
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
-require File.dirname(__FILE__) + '/../../lib/ai4r/genetic_algorithm/genetic_algorithm'
-
+require 'ai4r/genetic_algorithm/genetic_algorithm'
require 'test/unit'
module Ai4r
View
4 test/genetic_algorithm/genetic_algorithm_test.rb
@@ -7,7 +7,7 @@
# the Mozilla Public License version 1.1 as published by the
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
-require File.dirname(__FILE__) + '/../../lib/ai4r/genetic_algorithm/genetic_algorithm'
+require 'ai4r/genetic_algorithm/genetic_algorithm'
require 'test/unit'
module Ai4r
@@ -78,4 +78,4 @@ def test_replace_worst_ranked
end
-end
+end
View
4 test/neural_network/backpropagation_test.rb
@@ -15,7 +15,7 @@
#
-require File.dirname(__FILE__) + '/../../lib/ai4r/neural_network/backpropagation'
+require 'ai4r/neural_network/backpropagation'
require 'test/unit'
Ai4r::NeuralNetwork::Backpropagation.send(:public, *Ai4r::NeuralNetwork::Backpropagation.protected_instance_methods)
@@ -79,4 +79,4 @@ def test_dump
end
-end
+end
View
4 test/neural_network/hopfield_test.rb
@@ -9,7 +9,7 @@
# the Mozilla Public License version 1.1 as published by the
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
-require File.dirname(__FILE__) + '/../../lib/ai4r'
+require 'ai4r'
require 'test/unit'
Ai4r::NeuralNetwork::Hopfield.send(:public, *Ai4r::NeuralNetwork::Hopfield.protected_instance_methods)
@@ -69,4 +69,4 @@ def test_eval
end
end
-end
+end
View
4 test/som/som_test.rb
@@ -10,7 +10,7 @@
# the Mozilla Public License version 1.1 as published by the
# Mozilla Foundation at http://www.mozilla.org/MPL/MPL-1.1.txt
-require File.dirname(__FILE__) + '/../../lib/ai4r/som/som'
+require 'ai4r/som/som'
require 'test/unit'
module Ai4r
@@ -94,4 +94,4 @@ def distancer(x1, y1, x2, y2)
end
-end
+end

No commit comments for this range

Something went wrong with that request. Please try again.