Changeset 37 for trunk/src/SVM.cc


Ignore:
Timestamp:
Feb 13, 2004, 4:46:31 PM (19 years ago)
Author:
Peter
Message:

SVM.get_output added

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SVM.cc

    r36 r37  
    2020                 kernel_(kernel),
    2121                 target_(target),
    22                  alpha_(target.size(),true,true)
     22                 alpha_(target.size(),true,true),
     23                 bias_(0)
     24 
    2325{
    2426}
     
    3840  // Stop criteria 
    3941  bool stop_condition = false;
    40   while(count<100000 && !stop_condition)
     42  while(!stop_condition)
    4143    {
    4244     count++; 
     
    9092     alpha_[index2]=alpha_new;
    9193     stop_condition = stop( target_, kernel_, alpha_);
     94     if (count>10000000){
     95      cerr << "SVM): " << "more than 10,000,000 epochs reached" << endl;
     96       exit(1);
     97     }
    9298    }
     99
     100  // Calculating the bias
     101  double min_output_positive = 10000;
     102  double max_output_negative = -10000;
     103  thep_gsl_api::vector output_unbiased = kernel_ * alpha_.mul_elements(target_);
     104  for (u_int i=0; i<target_.size(); i++){
     105   if (target_[i]==1){
     106     if (output_unbiased[i] < min_output_positive)
     107       min_output_positive = output_unbiased[i];
     108   }
     109   else if( output_unbiased[i] > max_output_negative )
     110     max_output_negative = output_unbiased[i];
    93111 
     112  }
     113  cout << max_output_negative << endl;
     114  cout << min_output_positive << endl;
     115 
     116  bias_ = ( -min_output_positive - max_output_negative )/2;
     117  cout << "bias:" << bias_ << endl;
     118
    94119  trained_= true;
    95120}
     
    101126  double min_output_positive = 10000;
    102127  double max_output_negative = -10000;
    103   double epsilon = 0.001; // used twice, should perhaps be two different values
     128  double epsilon = 0.000001; // used twice, should perhaps be two different values
    104129  thep_gsl_api::vector output_unbiased = kernel_ * alpha_.mul_elements(target_);
    105130  for (u_int i=0; i<target_.size(); i++){
Note: See TracChangeset for help on using the changeset viewer.