Changeset 950


Ignore:
Timestamp:
Oct 9, 2007, 1:09:58 AM (14 years ago)
Author:
Peter
Message:

SVM::make_classifier is now throwing if KernelLookup? is not passed.

Location:
trunk/yat/classifier
Files:
2 edited

Legend:

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

    r948 r950  
    7373    }
    7474    catch (std::bad_cast) {
    75       std::string str = "Error in NBC::make_classifier: DataLookup2D of unexpected class.";
     75      std::string str =
     76        "Error in NBC::make_classifier: DataLookup2D of unexpected class.";
    7677      throw std::runtime_error(str);
    7778    }
     
    121122    const MatrixLookupWeighted* w =
    122123      dynamic_cast<const MatrixLookupWeighted*>(&x);
    123 
     124   
    124125    // each row in prediction corresponds to a sample label (class)
    125126    prediction.resize(centroids_.columns(), x.columns(), 0);
  • trunk/yat/classifier/SVM.cc

    r865 r950  
    116116  {
    117117    SVM* sc=0;
    118     try {
    119       const KernelLookup& kernel = dynamic_cast<const KernelLookup&>(data);
    120       assert(data.rows()==data.columns());
    121       assert(data.columns()==target.size());
    122       sc = new SVM(kernel,target);
    123 
     118    const KernelLookup& kernel = dynamic_cast<const KernelLookup&>(data);
     119    assert(data.rows()==data.columns());
     120    assert(data.columns()==target.size());
     121    sc = new SVM(kernel,target);
     122   
    124123    //Copy those variables possible to modify from outside
    125124    // Peter, in particular C
    126     }
    127     catch (std::bad_cast) {
    128       std::cerr << "Warning: SVM::make_classifier only takes KernelLookup"
    129                 << std::endl;
    130     }
     125 
    131126    return sc;
    132127  }
     
    144139  void SVM::predict(const DataLookup2D& input, utility::matrix& prediction) const
    145140  {
    146     // Peter, should check success of dynamic_cast
    147141    const KernelLookup& input_kernel = dynamic_cast<const KernelLookup&>(input);
    148142
Note: See TracChangeset for help on using the changeset viewer.