190 {
191
192 std::string custom_weightfile = weightfile.generateFileName();
193 weightfile.getFile("FastBDT_Weightfile", custom_weightfile);
194 std::fstream file(custom_weightfile, std::ios_base::in);
195
196 int version = weightfile.getElement<int>("FastBDT_version", 0);
197 B2DEBUG(100, "FastBDT Weightfile Version " << version);
198 if (version < 2) {
199 std::stringstream s;
200 {
201 std::string t;
202 std::fstream file2(custom_weightfile, std::ios_base::in);
203 getline(file2, t);
204 s << t;
205 }
206 int dummy;
207
208 if (!(s >> dummy >> dummy)) {
209 B2DEBUG(100, "FastBDT: I read a new weightfile of FastBDT using the new FastBDT version 3. Everything fine!");
210
212 } else {
213 B2INFO("FastBDT: I read an old weightfile of FastBDT using the new FastBDT version 3."
214 "I will convert your FastBDT on-the-fly to the new version."
215 "Retrain the classifier to get rid of this message");
216
217
218 std::vector<FastBDT::FeatureBinning<float>> feature_binnings;
219 file >> feature_binnings;
220 double F0;
221 file >> F0;
222 double shrinkage;
223 file >> shrinkage;
224
225 bool transform2probability = true;
226 FastBDT::Forest<unsigned int> temp_forest(shrinkage, F0, transform2probability);
227 unsigned int size;
228 file >> size;
229 for (unsigned int i = 0; i < size; ++i) {
230 temp_forest.AddTree(FastBDT::readTreeFromStream<unsigned int>(file));
231 }
232
233 FastBDT::Forest<float> cleaned_forest(temp_forest.GetShrinkage(), temp_forest.GetF0(), temp_forest.GetTransform2Probability());
234 for (auto& tree : temp_forest.GetForest()) {
235 cleaned_forest.AddTree(FastBDT::removeFeatureBinningTransformationFromTree(tree, feature_binnings));
236 }
238 }
239 } else {
242 }
243 file.close();
244
246 }
FastBDTOptions m_specific_options
Method specific options.