Class: Rover::DataFrame
- Inherits:
-
Object
- Object
- Rover::DataFrame
- Defined in:
- lib/hybridforest/utilities/utils.rb
Instance Method Summary collapse
- #class_labels ⇒ Object
- #column_by_index(index) ⇒ Object
- #count_labels ⇒ Object
- #disconnect_labels ⇒ Object
- #equal_or_greater_split(feature, value) ⇒ Object
- #equal_split(feature, value) ⇒ Object
- #feature_count(without_label: true) ⇒ Object
- #features ⇒ Object
- #label ⇒ Object
- #multiway_equal_split(feature) ⇒ Object
- #pure? ⇒ Boolean
Instance Method Details
#class_labels ⇒ Object
160 161 162 |
# File 'lib/hybridforest/utilities/utils.rb', line 160 def class_labels self[label].to_a end |
#column_by_index(index) ⇒ Object
135 136 137 138 |
# File 'lib/hybridforest/utilities/utils.rb', line 135 def column_by_index(index) where = @vectors.keys[index] @vectors[where] end |
#count_labels ⇒ Object
152 153 154 |
# File 'lib/hybridforest/utilities/utils.rb', line 152 def count_labels self[label].tally end |
#disconnect_labels ⇒ Object
164 165 166 167 168 |
# File 'lib/hybridforest/utilities/utils.rb', line 164 def disconnect_labels labels = class_labels except!(label) [self, labels] end |
#equal_or_greater_split(feature, value) ⇒ Object
121 122 123 124 125 |
# File 'lib/hybridforest/utilities/utils.rb', line 121 def equal_or_greater_split(feature, value) equal_or_greater = self[self[feature] >= value] less = self[self[feature] < value] [equal_or_greater, less] end |
#equal_split(feature, value) ⇒ Object
115 116 117 118 119 |
# File 'lib/hybridforest/utilities/utils.rb', line 115 def equal_split(feature, value) equal = self[self[feature] == value] not_equal = self[!self[feature].in?([value])] [equal, not_equal] end |
#feature_count(without_label: true) ⇒ Object
140 141 142 |
# File 'lib/hybridforest/utilities/utils.rb', line 140 def feature_count(without_label: true) without_label ? features.count : names.count end |
#features ⇒ Object
148 149 150 |
# File 'lib/hybridforest/utilities/utils.rb', line 148 def features names[0...-1] end |
#label ⇒ Object
156 157 158 |
# File 'lib/hybridforest/utilities/utils.rb', line 156 def label names[-1] end |
#multiway_equal_split(feature) ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/hybridforest/utilities/utils.rb', line 127 def multiway_equal_split(feature) subsets = [] self[feature].uniq.each do |value| subsets << self[self[feature] == value] end subsets end |
#pure? ⇒ Boolean
144 145 146 |
# File 'lib/hybridforest/utilities/utils.rb', line 144 def pure? self[label].uniq.size == 1 end |