Changeset 1049 for trunk/yat/classifier


Ignore:
Timestamp:
Feb 7, 2008, 3:50:38 PM (16 years ago)
Author:
Peter
Message:

replaced some cerr outputs with exception throws - refs #189

Location:
trunk/yat/classifier
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/classifier/SVM.cc

    r1042 r1049  
    3737#include <cmath>
    3838#include <limits>
     39#include <sstream>
    3940#include <stdexcept>
    4041#include <utility>
     
    288289    }
    289290    calculate_margin();
    290     trained_ = calculate_bias();
     291    calculate_bias();
     292    trained_ = true;
    291293  }
    292294
     
    391393  }
    392394 
    393   bool SVM::calculate_bias(void)
     395  void SVM::calculate_bias(void)
    394396  {
    395397
     
    402404
    403405    if (!sample_.nof_sv()){
    404       std::cerr << "SVM::train() error: "
    405                 << "Cannot calculate bias because there is no support vector"
    406                 << std::endl;
    407       return false;
     406      std::stringstream ss;
     407      ss << "yat::classifier::SVM::train() error: "
     408         << "Cannot calculate bias because there is no support vector";
     409      throw std::runtime_error(ss.str());
    408410    }
    409411
     
    416418    for (size_t i=0; i<output_.size(); i++)
    417419      output_(i) += bias_;
    418      
    419     return true;
    420420  }
    421421
  • trunk/yat/classifier/SVM.h

    r1042 r1049  
    208208    /// @return true if successful
    209209    ///
    210     bool calculate_bias(void);
     210    void calculate_bias(void);
    211211
    212212    ///
Note: See TracChangeset for help on using the changeset viewer.