Skip to content

Commit

Permalink
Merge pull request #553 from karlnapf/master
Browse files Browse the repository at this point in the history
debug messages for x-val
  • Loading branch information
karlnapf committed May 25, 2012
2 parents 19ddc93 + f377998 commit a4fd65a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/shogun/base/Parameter.cpp
Expand Up @@ -1580,7 +1580,7 @@ TParameter::TParameter(const TSGDataType* datatype, void* parameter,

TParameter::~TParameter()
{
SG_SDEBUG("entering ~TParameter for \"%s\"\n", m_name);
// SG_SDEBUG("entering ~TParameter for \"%s\"\n", m_name);
SG_FREE(m_description);
SG_FREE(m_name);

Expand Down Expand Up @@ -1616,7 +1616,7 @@ TParameter::~TParameter()
SG_FREE(m_datatype.m_length_y);
}

SG_SDEBUG("leaving ~TParameter\n");
// SG_SDEBUG("leaving ~TParameter\n");
}

char*
Expand Down
27 changes: 27 additions & 0 deletions src/shogun/evaluation/CrossValidation.cpp
Expand Up @@ -126,6 +126,8 @@ CMachine* CCrossValidation::get_machine() const

CrossValidationResult CCrossValidation::evaluate()
{
SG_DEBUG("entering %s::evaluate()\n", get_name());

/* if for some reason the do_unlock_frag is set, unlock */
if (m_do_unlock)
{
Expand Down Expand Up @@ -159,8 +161,13 @@ CrossValidationResult CCrossValidation::evaluate()
SGVector<float64_t> results(m_num_runs);

/* perform all the x-val runs */
SG_DEBUG("starting %d runs of cross-validation\n", m_num_runs);
for (index_t i=0; i <m_num_runs; ++i)
{
SG_DEBUG("entering cross-validation run %d \n", i);
results[i]=evaluate_one_run();
SG_DEBUG("result of cross-validation run %d is %f\n", i, results[i]);
}

/* construct evaluation result */
CrossValidationResult result;
Expand All @@ -187,6 +194,7 @@ CrossValidationResult CCrossValidation::evaluate()
m_do_unlock=false;
}

SG_DEBUG("leaving %s::evaluate()\n", get_name());
return result;
}

Expand Down Expand Up @@ -216,8 +224,11 @@ void CCrossValidation::set_num_runs(int32_t num_runs)

float64_t CCrossValidation::evaluate_one_run()
{
SG_DEBUG("entering %s::evaluate_one_run()\n", get_name());
index_t num_subsets=m_splitting_strategy->get_num_subsets();

SG_DEBUG("building index sets for %d-fold cross-validation\n", num_subsets);

/* build index sets */
m_splitting_strategy->build_subsets();

Expand Down Expand Up @@ -275,6 +286,13 @@ float64_t CCrossValidation::evaluate_one_run()
/* set label subset for training */
m_labels->add_subset(inverse_subset_indices);

SG_DEBUG("training set %d:\n", i);
if (io->get_loglevel()==MSG_DEBUG)
{
CMath::display_vector(inverse_subset_indices.vector,
inverse_subset_indices.vlen, "indices");
}

/* train machine on training features and remove subset */
m_machine->train(m_features);
m_features->remove_subset();
Expand All @@ -288,13 +306,21 @@ float64_t CCrossValidation::evaluate_one_run()
/* set label subset for testing */
m_labels->add_subset(subset_indices);

SG_DEBUG("test set %d:\n", i);
if (io->get_loglevel()==MSG_DEBUG)
{
CMath::display_vector(inverse_subset_indices.vector,
inverse_subset_indices.vlen, "indices");
}

/* apply machine to test features and remove subset */
CLabels* result_labels=m_machine->apply(m_features);
m_features->remove_subset();
SG_REF(result_labels);

/* evaluate */
results[i]=m_evaluation_criterion->evaluate(result_labels, m_labels);
SG_DEBUG("result on fold %d is %f\n", i, results[i]);

/* clean up, remove subsets */
SG_UNREF(result_labels);
Expand All @@ -305,5 +331,6 @@ float64_t CCrossValidation::evaluate_one_run()
/* build arithmetic mean of results */
float64_t mean=CStatistics::mean(results);

SG_DEBUG("leaving %s::evaluate_one_run()\n", get_name());
return mean;
}

0 comments on commit a4fd65a

Please sign in to comment.