Skip to content

Commit

Permalink
renamed xvalidation to cross-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lambday committed Jul 13, 2016
1 parent af7ecc3 commit d45d3a5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/shogun/statistical_testing/MMD.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace internal

class KernelManager;
class MaxTestPower;
class MaxXValidation;
class MaxCrossValidation;
class WeightedMaxTestPower;

}
Expand Down Expand Up @@ -80,7 +80,7 @@ class CMMD : public CTwoSampleTest
{
friend class internal::MaxTestPower;
friend class internal::WeightedMaxTestPower;
friend class internal::MaxXValidation;
friend class internal::MaxCrossValidation;
public:
typedef std::function<float32_t(SGMatrix<float32_t>)> operation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <shogun/statistical_testing/kernelselection/internals/KernelSelection.h>
#include <shogun/statistical_testing/kernelselection/internals/MaxMeasure.h>
#include <shogun/statistical_testing/kernelselection/internals/MaxTestPower.h>
#include <shogun/statistical_testing/kernelselection/internals/MaxXValidation.h>
#include <shogun/statistical_testing/kernelselection/internals/MaxCrossValidation.h>
#include <shogun/statistical_testing/kernelselection/internals/MedianHeuristic.h>
#include <shogun/statistical_testing/kernelselection/internals/WeightedMaxMeasure.h>
#include <shogun/statistical_testing/kernelselection/internals/WeightedMaxTestPower.h>
Expand Down Expand Up @@ -87,10 +87,10 @@ void CKernelSelectionStrategy::Self::init_policy(CMMD* estimator)
policy=std::unique_ptr<MedianHeuristic>(new MedianHeuristic(kernel_mgr, estimator));
}
break;
case KSM_MAXIMIZE_XVALIDATION:
case KSM_MAXIMIZE_CROSS_VALIDATION:
{
REQUIRE(!weighted, "Weighted kernel selection is not possible with MAXIMIZE_XVALIDATION!\n");
policy=std::unique_ptr<MaxXValidation>(new MaxXValidation(kernel_mgr, estimator,
REQUIRE(!weighted, "Weighted kernel selection is not possible with MAXIMIZE_CROSS_VALIDATION!\n");
policy=std::unique_ptr<MaxCrossValidation>(new MaxCrossValidation(kernel_mgr, estimator,
num_runs, alpha));
}
break;
Expand All @@ -115,7 +115,7 @@ void CKernelSelectionStrategy::Self::init_policy(CMMD* estimator)
SG_SERROR("Unsupported kernel selection method specified! Accepted strategies are "
"MAXIMIZE_MMD (single, weighted), "
"MAXIMIZE_POWER (single, weighted), "
"MAXIMIZE_XVALIDATION (single) and "
"MAXIMIZE_CROSS_VALIDATION (single) and "
"MEDIAN_HEURISTIC (single)!\n");
}
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum EKernelSelectionMethod : uint32_t
KSM_MEDIAN_HEURISTIC,
KSM_MAXIMIZE_MMD,
KSM_MAXIMIZE_POWER,
KSM_MAXIMIZE_XVALIDATION,
KSM_MAXIMIZE_CROSS_VALIDATION,
KSM_AUTO=KSM_MAXIMIZE_POWER
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,33 @@
#include <shogun/statistical_testing/MMD.h>
#include <shogun/statistical_testing/internals/KernelManager.h>
#include <shogun/statistical_testing/internals/DataManager.h>
#include <shogun/statistical_testing/kernelselection/internals/MaxXValidation.h>
#include <shogun/statistical_testing/kernelselection/internals/MaxCrossValidation.h>

using namespace shogun;
using namespace internal;

MaxXValidation::MaxXValidation(KernelManager& km, CMMD* est, const index_t& M, const float64_t& alp)
MaxCrossValidation::MaxCrossValidation(KernelManager& km, CMMD* est, const index_t& M, const float64_t& alp)
: KernelSelection(km, est), num_run(M), alpha(alp)
{
REQUIRE(num_run>0, "Number of runs is %d!\n", num_run);
REQUIRE(alpha>=0.0 && alpha<=1.0, "Threshold is %f!\n", alpha);
}

MaxXValidation::~MaxXValidation()
MaxCrossValidation::~MaxCrossValidation()
{
}

SGVector<float64_t> MaxXValidation::get_measure_vector()
SGVector<float64_t> MaxCrossValidation::get_measure_vector()
{
return measures;
}

SGMatrix<float64_t> MaxXValidation::get_measure_matrix()
SGMatrix<float64_t> MaxCrossValidation::get_measure_matrix()
{
return rejections;
}

void MaxXValidation::init_measures()
void MaxCrossValidation::init_measures()
{
const index_t num_kernels=kernel_mgr.num_kernels();
auto& data_mgr=estimator->get_data_mgr();
Expand All @@ -76,7 +76,7 @@ void MaxXValidation::init_measures()
std::fill(measures.data(), measures.data()+measures.size(), 0);
}

void MaxXValidation::compute_measures()
void MaxCrossValidation::compute_measures()
{
auto& data_mgr=estimator->get_data_mgr();
data_mgr.set_cross_validation_mode(true);
Expand Down Expand Up @@ -115,7 +115,7 @@ void MaxXValidation::compute_measures()
}
}

CKernel* MaxXValidation::select_kernel()
CKernel* MaxCrossValidation::select_kernel()
{
init_measures();
compute_measures();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
* either expressed or implied, of the Shogun Development Team.
*/

#ifndef MAX_XVALIDATIN_H__
#define MAX_XVALIDATIN_H__
#ifndef MAX_CROSS_VALIDATION_H__
#define MAX_CROSS_VALIDATION_H__

#include <shogun/lib/common.h>
#include <shogun/statistical_testing/kernelselection/internals/KernelSelection.h>
Expand All @@ -45,13 +45,13 @@ template <typename T> class SGVector;
namespace internal
{

class MaxXValidation : public KernelSelection
class MaxCrossValidation : public KernelSelection
{
public:
MaxXValidation(KernelManager&, CMMD*, const index_t&, const float64_t&);
MaxXValidation(const MaxXValidation& other)=delete;
~MaxXValidation();
MaxXValidation& operator=(const MaxXValidation& other)=delete;
MaxCrossValidation(KernelManager&, CMMD*, const index_t&, const float64_t&);
MaxCrossValidation(const MaxCrossValidation& other)=delete;
~MaxCrossValidation();
MaxCrossValidation& operator=(const MaxCrossValidation& other)=delete;
virtual CKernel* select_kernel() override;
virtual SGVector<float64_t> get_measure_vector();
virtual SGMatrix<float64_t> get_measure_matrix();
Expand All @@ -68,4 +68,4 @@ class MaxXValidation : public KernelSelection

}

#endif // MAX_XVALIDATIN_H__
#endif // MAX_CROSS_VALIDATION_H__
8 changes: 4 additions & 4 deletions tests/unit/statistical_testing/KernelSelection_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ TEST(KernelSelectionMaxTestPower, linear_time_weighted_kernel_streaming)
EXPECT_NEAR(weights[i], 0.1, 1E-10);
}

TEST(KernelSelectionMaxXValidation, quadratic_time_single_kernel_dense)
TEST(KernelSelectionMaxCrossValidation, quadratic_time_single_kernel_dense)
{
const index_t m=5;
const index_t n=10;
Expand All @@ -241,7 +241,7 @@ TEST(KernelSelectionMaxXValidation, quadratic_time_single_kernel_dense)
float64_t tau=pow(2, sigma);
mmd->add_kernel(new CGaussianKernel(10, tau));
}
mmd->set_kernel_selection_strategy(KSM_MAXIMIZE_XVALIDATION, num_runs, alpha);
mmd->set_kernel_selection_strategy(KSM_MAXIMIZE_CROSS_VALIDATION, num_runs, alpha);

mmd->set_train_test_mode(true);
mmd->set_train_test_ratio(num_folds-1);
Expand All @@ -252,7 +252,7 @@ TEST(KernelSelectionMaxXValidation, quadratic_time_single_kernel_dense)
EXPECT_NEAR(selected_kernel->get_width(), 0.03125, 1E-10);
}

TEST(KernelSelectionMaxXValidation, linear_time_single_kernel_dense)
TEST(KernelSelectionMaxCrossValidation, linear_time_single_kernel_dense)
{
const index_t m=5;
const index_t n=10;
Expand All @@ -277,7 +277,7 @@ TEST(KernelSelectionMaxXValidation, linear_time_single_kernel_dense)
float64_t tau=pow(2, sigma);
mmd->add_kernel(new CGaussianKernel(10, tau));
}
mmd->set_kernel_selection_strategy(KSM_MAXIMIZE_XVALIDATION, num_runs, alpha);
mmd->set_kernel_selection_strategy(KSM_MAXIMIZE_CROSS_VALIDATION, num_runs, alpha);

mmd->set_train_test_mode(true);
mmd->set_train_test_ratio(num_folds-1);
Expand Down

0 comments on commit d45d3a5

Please sign in to comment.