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