Skip to content

Commit

Permalink
Changed Dataset to use column names for feature names with Rover and …
Browse files Browse the repository at this point in the history
…Daru
  • Loading branch information
ankane committed Nov 12, 2024
1 parent 211c205 commit 3792f19
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## 0.4.0 (unreleased)

- Added support for hashes to `predict` method
- Added support for `feature_names: "auto"` to `Dataset`
- Changed `Dataset` to use column names for feature names with Rover and Daru
- Dropped support for Ruby < 3.1

## 0.3.4 (2024-07-28)
Expand Down
4 changes: 2 additions & 2 deletions lib/lightgbm/dataset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def initialize(data, label: nil, weight: nil, group: nil, params: nil, reference
@reference = reference
@used_indices = used_indices
@categorical_feature = categorical_feature
@feature_name = feature_name || feature_names
@feature_name = feature_name || feature_names || "auto"

construct
end
Expand Down Expand Up @@ -178,7 +178,7 @@ def construct
self.label = @label if @label
self.weight = @weight if @weight
self.group = @group if @group
self.feature_name = @feature_name if @feature_name
self.feature_name = @feature_name if @feature_name && @feature_name != "auto"
end

def dump_text(filename)
Expand Down
8 changes: 1 addition & 7 deletions test/dataset_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ def test_daru
label = data["y"]
data = data.delete_vector("y")
dataset = LightGBM::Dataset.new(data, label: label)
assert_equal ["Column_0", "Column_1", "Column_2", "Column_3"], dataset.feature_name

dataset = LightGBM::Dataset.new(data, label: label, feature_name: "auto")
assert_equal ["x0", "x1", "x2", "x3"], dataset.feature_names
assert_equal ["x0", "x1", "x2", "x3"], dataset.feature_name
end

def test_numo
Expand All @@ -84,9 +81,6 @@ def test_rover
data = Rover.read_csv(data_path)
label = data.delete("y")
dataset = LightGBM::Dataset.new(data, label: label)
assert_equal ["Column_0", "Column_1", "Column_2", "Column_3"], dataset.feature_name

dataset = LightGBM::Dataset.new(data, label: label, feature_name: "auto")
assert_equal ["x0", "x1", "x2", "x3"], dataset.feature_name
end

Expand Down

0 comments on commit 3792f19

Please sign in to comment.