Skip to content

Commit

Permalink
code cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
karlnapf committed May 14, 2012
1 parent ea2e2f2 commit 2639838
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/shogun/evaluation/CrossValidation.cpp
Expand Up @@ -160,7 +160,7 @@ CrossValidationResult CCrossValidation::evaluate()

/* perform all the x-val runs */
for (index_t i=0; i <m_num_runs; ++i)
results.vector[i]=evaluate_one_run();
results[i]=evaluate_one_run();

/* construct evaluation result */
CrossValidationResult result;
Expand Down Expand Up @@ -222,7 +222,7 @@ float64_t CCrossValidation::evaluate_one_run()
m_splitting_strategy->build_subsets();

/* results array */
float64_t* results=SG_MALLOC(float64_t, num_subsets);
SGVector<float64_t> results(num_subsets);

/* different behavior whether data is locked or not */
if (m_machine->is_data_locked())
Expand All @@ -237,21 +237,19 @@ float64_t CCrossValidation::evaluate_one_run()
/* train machine on training features */
m_machine->train_locked(inverse_subset_indices);

/* feature subset for testing, will be implicitly freed by CSubset */
/* feature subset for testing */
SGVector<index_t> subset_indices =
m_splitting_strategy->generate_subset_indices(i);

/* produce output for desired indices */
CLabels* result_labels=m_machine->apply_locked(subset_indices);
SG_REF(result_labels);

/* set subset for training labels, note that this will (later) free
* the subset_indices vector */
/* set subset for training labels */
m_labels->add_subset(subset_indices);

/* evaluate against own labels */
results[i]=m_evaluation_criterion->evaluate(result_labels,
m_labels);
results[i]=m_evaluation_criterion->evaluate(result_labels, m_labels);

/* remove subset to prevent side efects */
m_labels->remove_subset();
Expand Down Expand Up @@ -305,8 +303,7 @@ float64_t CCrossValidation::evaluate_one_run()
}

/* build arithmetic mean of results */
float64_t mean=CStatistics::mean(
SGVector <float64_t> (results, num_subsets));
float64_t mean=CStatistics::mean(results);

return mean;
}

0 comments on commit 2639838

Please sign in to comment.