nimbus 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -76,7 +76,7 @@ The `config.yml` has the following structure and parameters:
76
76
  training: training_regression.data
77
77
  testing: testing_regression.data
78
78
  forest: my_forest.yml
79
- classes: [0,1]
79
+ classes: [0, 1]
80
80
 
81
81
  #Forest parameters
82
82
  forest:
@@ -90,7 +90,7 @@ Under the input chapter:
90
90
  * `training`: specify the path to the training data file (optional, if specified `nimbus` will create a random forest).
91
91
  * `testing`: specify the path to the testing data file (optional, if specified `nimbus` will traverse this dat through a random forest).
92
92
  * `forest`: specify the path to a file containing a random forest structure (optional, if there is also testing file, this will be the forest used for the testing).
93
- * `classes`: **optional (needed only for classification problems)**. Specify the list of classes in the input files as a comma separated list between squared brackets, e.g.:`[A,B]`.
93
+ * `classes`: **optional (needed only for classification problems)**. Specify the list of classes in the input files as a comma separated list between squared brackets, e.g.:`[A, B]`.
94
94
 
95
95
  Under the forest chapter:
96
96
 
@@ -110,7 +110,7 @@ The three input files you can use with Nimbus should have proper format:
110
110
  1. A column with the ID of the individual
111
111
  1. M columns (where M = SNP_total_count in `config.yml`) with values 0, 1 or 2, representing the genotype of the individual.
112
112
 
113
- **The training file** has any number of rows, each representing data for an individual, similar to the training file but without the fenotype column:
113
+ **The testing file** has any number of rows, each representing data for an individual, similar to the training file but without the fenotype column:
114
114
 
115
115
  1. A column with the ID of the individual
116
116
  1. M columns (where M = SNP_total_count in `config.yml`) with values 0, 1 or 2, representing the genotype of the individual.
data/bin/nimbus CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #--
4
- # Copyright (c) 2011 Juanjo Bazan
4
+ # Copyright (c) 2011-2013 Juanjo Bazan
5
5
  #
6
6
  # Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  # of this software and associated documentation files (the "Software"), to
@@ -1,4 +1,4 @@
1
- require 'yaml'
1
+ require 'psych'
2
2
  require 'nimbus/exceptions'
3
3
  require 'nimbus/training_set'
4
4
  require 'nimbus/configuration'
@@ -106,7 +106,7 @@ module Nimbus
106
106
  if File.exists?(File.expand_path(config_file, Dir.pwd))
107
107
  begin
108
108
  config_file_path = File.expand_path config_file, Dir.pwd
109
- user_config_params = YAML.load(File.open(config_file_path))
109
+ user_config_params = Psych.load(File.open(config_file_path))
110
110
  dirname = File.dirname config_file_path
111
111
  rescue ArgumentError => e
112
112
  raise Nimbus::WrongFormatFileError, "It was not posible to parse the config file (#{config_file}): \r\n#{e.message} "
@@ -184,10 +184,12 @@ module Nimbus
184
184
  trees = []
185
185
  if File.exists?(@forest_file)
186
186
  begin
187
- trees = YAML.load(File.open @forest_file)
187
+ trees = Psych.load(File.open @forest_file)
188
188
  rescue ArgumentError => e
189
189
  raise Nimbus::WrongFormatFileError, "It was not posible to parse the random forest file (#{@forest_file}): \r\n#{e.message} "
190
190
  end
191
+ else
192
+ raise Nimbus::InputFileError, "Forest file not found (#{@forest_file})"
191
193
  end
192
194
  forest = Nimbus::Forest.new self
193
195
  forest.trees = trees
@@ -1,3 +1,3 @@
1
1
  module Nimbus
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
  end
@@ -116,7 +116,7 @@ describe Nimbus::ClassificationTree do
116
116
  end
117
117
 
118
118
  it 'get prediction for an individual pushing it down a tree structure' do
119
- tree_structure = YAML.load(File.open fixture_file('classification_random_forest.yml')).first
119
+ tree_structure = Psych.load(File.open fixture_file('classification_random_forest.yml')).first
120
120
  individual_data = [0]*100
121
121
  prediction = Nimbus::Tree.traverse tree_structure, individual_data
122
122
  prediction.should == '1'
@@ -105,7 +105,7 @@ describe Nimbus::Configuration do
105
105
  config = Nimbus::Configuration.new
106
106
  config.load fixture_file('regression_config.yml')
107
107
 
108
- trees = YAML.load(File.open fixture_file('regression_random_forest.yml'))
108
+ trees = Psych.load(File.open fixture_file('regression_random_forest.yml'))
109
109
  trees.first.keys.first.should == 189
110
110
  trees.size.should == 3
111
111
 
@@ -38,7 +38,7 @@ describe Nimbus::Forest do
38
38
  @forest = @config.load_forest
39
39
  @forest.predictions.should == {}
40
40
 
41
- tree_structure = YAML.load(File.open fixture_file('regression_random_forest.yml'))
41
+ tree_structure = Psych.load(File.open fixture_file('regression_random_forest.yml'))
42
42
  expected_predictions = {}
43
43
  @config.read_testing_data{|individual|
44
44
  individual_prediction = 0.0
@@ -54,7 +54,7 @@ describe Nimbus::Forest do
54
54
 
55
55
  it 'can output forest structure in YAML format' do
56
56
  @forest = @config.load_forest
57
- YAML.load(File.open fixture_file('regression_random_forest.yml')) == YAML.load(@forest.to_yaml)
57
+ Psych.load(File.open fixture_file('regression_random_forest.yml')) == Psych.load(@forest.to_yaml)
58
58
  end
59
59
  end
60
60
 
@@ -94,7 +94,7 @@ describe Nimbus::Forest do
94
94
  @forest = @config.load_forest
95
95
  @forest.predictions.should == {}
96
96
 
97
- tree_structure = YAML.load(File.open fixture_file('classification_random_forest.yml'))
97
+ tree_structure = Psych.load(File.open fixture_file('classification_random_forest.yml'))
98
98
  expected_predictions = {}
99
99
  @config.read_testing_data{|individual|
100
100
  individual_prediction = []
@@ -110,7 +110,7 @@ describe Nimbus::Forest do
110
110
 
111
111
  it 'can output forest structure in YAML format' do
112
112
  @forest = @config.load_forest
113
- YAML.load(File.open fixture_file('classification_random_forest.yml')) == YAML.load(@forest.to_yaml)
113
+ Psych.load(File.open fixture_file('classification_random_forest.yml')) == Psych.load(@forest.to_yaml)
114
114
  end
115
115
  end
116
116
  end
@@ -113,7 +113,7 @@ describe Nimbus::RegressionTree do
113
113
  end
114
114
 
115
115
  it 'get prediction for an individual pushing it down a tree structure' do
116
- tree_structure = YAML.load(File.open fixture_file('regression_random_forest.yml')).first
116
+ tree_structure = Psych.load(File.open fixture_file('regression_random_forest.yml')).first
117
117
  individual_data = [0]*200
118
118
  prediction = Nimbus::Tree.traverse tree_structure, individual_data
119
119
  prediction.should == 0.25043
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nimbus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-07-26 00:00:00.000000000 Z
13
+ date: 2012-07-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &2156549180 !ruby/object:Gem::Requirement
17
+ requirement: &2160657580 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,7 +22,7 @@ dependencies:
22
22
  version: 2.11.0
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2156549180
25
+ version_requirements: *2160657580
26
26
  description: Nimbus is a Ruby gem to implement Random Forest in a genomic selection
27
27
  context.
28
28
  email: