Ignore:
Timestamp:
Oct 10, 2007, 11:14:17 PM (14 years ago)
Author:
Peter
Message:

adding function to set maximal training epochs in SVM, and fixed so C and max_epochs is copied in make_classifier (rather than set to default).

File:
1 edited

Legend:

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

    r959 r964  
    3737#include <cmath>
    3838#include <limits>
     39#include <stdexcept>
    3940#include <utility>
    4041#include <vector>
     
    122123      sc = new SVM(kernel,target);
    123124      //Copy those variables possible to modify from outside
    124       // Peter, in particular C
     125      sc->set_C(this->C());
     126      sc->max_epochs(max_epochs());
    125127    }
    126128    catch (std::bad_cast& e) {
     
    137139    return max_epochs_;
    138140  }
     141
     142
     143  void SVM::max_epochs(long int n)
     144  {
     145    max_epochs_=n;
     146  }
     147
    139148
    140149  const theplu::yat::utility::vector& SVM::output(void) const
     
    275284      epochs++; 
    276285      if (epochs>max_epochs_){
    277         std::cerr << "WARNING: SVM: maximal number of epochs reached.\n";
    278         calculate_bias();
    279         calculate_margin();
    280         return false;
     286        throw std::runtime_error("SVM: maximal number of epochs reached.");
    281287      }
    282288    }
Note: See TracChangeset for help on using the changeset viewer.