| 1044 | } |
| 1045 | |
| 1046 | void Dataset::addFeaturesFrom(Dataset* other) { |
| 1047 | if (other->num_data_ != num_data_) { |
| 1048 | throw std::runtime_error("Cannot add features from other Dataset with a different number of rows"); |
| 1049 | } |
| 1050 | PushVector(&feature_names_, other->feature_names_); |
| 1051 | PushVector(&feature2subfeature_, other->feature2subfeature_); |
| 1052 | PushVector(&group_feature_cnt_, other->group_feature_cnt_); |
| 1053 | PushVector(&forced_bin_bounds_, other->forced_bin_bounds_); |
| 1054 | feature_groups_.reserve(other->feature_groups_.size()); |
| 1055 | for (auto& fg : other->feature_groups_) { |
| 1056 | feature_groups_.emplace_back(new FeatureGroup(*fg)); |
| 1057 | } |
| 1058 | for (auto feature_idx : other->used_feature_map_) { |
| 1059 | if (feature_idx >= 0) { |
| 1060 | used_feature_map_.push_back(feature_idx + num_features_); |
| 1061 | } else { |
| 1062 | used_feature_map_.push_back(-1); // Unused feature. |
| 1063 | } |
| 1064 | } |
| 1065 | PushOffset(&real_feature_idx_, other->real_feature_idx_, num_total_features_); |
| 1066 | PushOffset(&feature2group_, other->feature2group_, num_groups_); |
| 1067 | auto bin_offset = group_bin_boundaries_.back(); |
| 1068 | // Skip the leading 0 when copying group_bin_boundaries. |
| 1069 | for (auto i = other->group_bin_boundaries_.begin()+1; i < other->group_bin_boundaries_.end(); ++i) { |
| 1070 | group_bin_boundaries_.push_back(*i + bin_offset); |
| 1071 | } |
| 1072 | PushOffset(&group_feature_start_, other->group_feature_start_, num_features_); |
| 1073 | |
| 1074 | PushClearIfEmpty(&monotone_types_, num_total_features_, other->monotone_types_, other->num_total_features_, (int8_t)0); |
| 1075 | PushClearIfEmpty(&feature_penalty_, num_total_features_, other->feature_penalty_, other->num_total_features_, 1.0); |
| 1076 | PushClearIfEmpty(&max_bin_by_feature_, num_total_features_, other->max_bin_by_feature_, other->num_total_features_, -1); |
| 1077 | |
| 1078 | num_features_ += other->num_features_; |
| 1079 | num_total_features_ += other->num_total_features_; |
| 1080 | num_groups_ += other->num_groups_; |
| 1081 | } |
| 1082 | |
| 1083 | } // namespace LightGBM |
no test coverage detected