-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Ruby variation of the ExtraTreesClassifier estimator
- Loading branch information
Darius Morawiec
committed
Sep 26, 2017
1 parent
3775501
commit 81b9914
Showing
6 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
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
10 changes: 10 additions & 0 deletions
10
sklearn_porter/classifier/ExtraTreesClassifier/templates/ruby/class.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class {class_name} | ||
|
||
{method} | ||
|
||
end | ||
|
||
if ARGV.length == {n_features} | ||
atts = ARGV.collect {{ |i| i.to_f }} | ||
puts {class_name}.{method_name}(atts) | ||
end |
7 changes: 7 additions & 0 deletions
7
sklearn_porter/classifier/ExtraTreesClassifier/templates/ruby/method.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{methods} | ||
def self.{method_name} (atts) | ||
classes = Array.new({n_classes}, 0) | ||
{method_calls} | ||
pos_max = classes.each_with_index.select {{|e, i| e==classes.max}}.map &:last | ||
return pos_max.min | ||
end |
1 change: 1 addition & 0 deletions
1
sklearn_porter/classifier/ExtraTreesClassifier/templates/ruby/method_calls.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
idx = {class_name}.{method_name}(atts); classes[idx] = classes[idx] + 1 |
6 changes: 6 additions & 0 deletions
6
sklearn_porter/classifier/ExtraTreesClassifier/templates/ruby/single_method.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def self.{method_name}_{method_id} (atts) | ||
classes = Array.new({n_classes}, 0) | ||
{tree_branches} | ||
pos_max = classes.each_with_index.select {{|e, i| e==classes.max}}.map &:last | ||
return pos_max.min | ||
end |
26 changes: 26 additions & 0 deletions
26
tests/classifier/ExtraTreesClassifier/ExtraTreesClassifierRubyTest.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import unittest | ||
|
||
from sklearn.ensemble import ExtraTreesClassifier | ||
|
||
from ..Classifier import Classifier | ||
from ...language.Ruby import Ruby | ||
|
||
|
||
class ExtraTreesClassifierRubyTest(Ruby, Classifier, unittest.TestCase): | ||
|
||
def setUp(self): | ||
super(ExtraTreesClassifierRubyTest, self).setUp() | ||
self.mdl = ExtraTreesClassifier(random_state=0) | ||
|
||
def tearDown(self): | ||
super(ExtraTreesClassifierRubyTest, self).tearDown() | ||
|
||
# @unittest.skip('The generated code would be too large.') | ||
# def test_existing_features_w_digits_data(self): | ||
# pass | ||
# | ||
# @unittest.skip('The generated code would be too large.') | ||
# def test_random_features_w_digits_data(self): | ||
# pass |