Skip to content

Commit

Permalink
fix prob_predict on cmd #149
Browse files Browse the repository at this point in the history
  • Loading branch information
QinbinLi committed May 26, 2019
1 parent c7f6882 commit 6a62fdd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions include/thundersvm/model/svmmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class SvmModel {

//return sv_indices
const vector<int> &get_sv_ind() const;

//return label
const vector<int> &get_label() const;
protected:

/**
Expand Down
4 changes: 4 additions & 0 deletions src/thundersvm/model/svmmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,7 @@ void SvmModel::compute_linear_coef_single_model(size_t n_feature, const bool zer
int SvmModel::get_sv_max_index() const{
return sv_max_index;
}

const vector<int> &SvmModel::get_label() const{
return label;
}
17 changes: 15 additions & 2 deletions src/thundersvm/thundersvm-predict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,21 @@ int main(int argc, char **argv) {

vector<float_type> predict_y;
predict_y = model->predict(predict_dataset.instances(), -1);
for (int i = 0; i < predict_y.size(); ++i) {
file << predict_y[i] << std::endl;
vector<int> label;
label = model->get_label();
vector<float> prob_predict;
prob_predict = model->get_prob_predict();
file<<"labels ";
for (int i = 0; i < label.size(); i++){
file<<label[i]<<" ";
}
file<<std::endl;
for (int i = 0; i < predict_y.size(); i++) {
file << predict_y[i]<<" ";
for(int j = 0; j < label.size(); j++){
file<<prob_predict[label.size() * i + j]<<" ";
}
file << std::endl;
}
file.close();

Expand Down

0 comments on commit 6a62fdd

Please sign in to comment.