Skip to content

Commit

Permalink
returns zeros when predicting on bad models
Browse files Browse the repository at this point in the history
Former-commit-id: 2e029c9
  • Loading branch information
lacava committed Mar 26, 2019
1 parent 9f85cc2 commit e4ba0a4
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions src/model/ml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,44 +397,35 @@ namespace FT{
// make sure the model fit() method passed
if (get_weights().empty())
{
cout << "weight empty; returning zeros\n";
HANDLE_ERROR_NO_THROW("weight empty; returning zeros");
if (this->prob_type==PT_BINARY)
{
CBinaryLabels dlabels(X.cols());
labels = std::shared_ptr<CLabels>(new CBinaryLabels(X.cols()));
for (unsigned i = 0; i < X.cols() ; ++i)
{
dlabels.set_value(0,i);
dlabels.set_label(0,i);
dynamic_pointer_cast<CBinaryLabels>(labels)->set_value(0,i);
dynamic_pointer_cast<CBinaryLabels>(labels)->set_label(i,0);
}
cout << "setting labels\n";
labels =shared_ptr<CLabels>(&dlabels);
cout << "returning\n";
return labels;
}
else if (this->prob_type == PT_MULTICLASS)
{
CMulticlassLabels dlabels(X.cols());
labels = std::shared_ptr<CLabels>(new CMulticlassLabels(X.cols()));
for (unsigned i = 0; i < X.cols() ; ++i)
{
dlabels.set_value(0,i);
dlabels.set_label(0,i);
dynamic_pointer_cast<CMulticlassLabels>(labels)->set_value(0,i);
dynamic_pointer_cast<CMulticlassLabels>(labels)->set_label(i,0);
}
cout << "setting labels\n";
labels =shared_ptr<CLabels>(&dlabels);
cout << "returning\n";
return labels;
}
else
{
CRegressionLabels dlabels(X.cols());
labels = std::shared_ptr<CLabels>(new CRegressionLabels(X.cols()));
for (unsigned i = 0; i < X.cols() ; ++i)
{
dlabels.set_value(0,i);
dlabels.set_label(0,i);
dynamic_pointer_cast<CRegressionLabels>(labels)->set_value(0,i);
dynamic_pointer_cast<CRegressionLabels>(labels)->set_label(i,0);
}
cout << "setting labels\n";
labels =shared_ptr<CLabels>(&dlabels);
cout << "returning\n";
return labels;
}
}
Expand Down

0 comments on commit e4ba0a4

Please sign in to comment.