Changeset 964 for trunk/yat/classifier


Ignore:
Timestamp:
Oct 10, 2007, 11:14:17 PM (16 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).

Location:
trunk/yat/classifier
Files:
2 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    }
  • trunk/yat/classifier/SVM.h

    r963 r964  
    105105    ///
    106106    long int max_epochs(void) const;
     107   
     108    /*
     109      \brief set maximal number of epochs in training
     110    */
     111    void max_epochs(long int);
    107112   
    108113    /**
Note: See TracChangeset for help on using the changeset viewer.