diff --git a/src/shogun/statistical_testing/MMD.cpp b/src/shogun/statistical_testing/MMD.cpp index 1882f8f7169..205d109e2e6 100644 --- a/src/shogun/statistical_testing/MMD.cpp +++ b/src/shogun/statistical_testing/MMD.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include @@ -154,7 +154,6 @@ void CMMD::Self::compute_kernel(ComputationManager& cm, std::vector& { REQUIRE(kernel->get_kernel_type()!=K_CUSTOM, "Underlying kernel cannot be custom!\n"); cm.num_data(blocks.size()); - const auto& dm=owner.get_data_manager(); #pragma omp parallel for for (size_t i=0; ikernel_selection_mgr, this); + MaxTestPower policy(self->kernel_selection_mgr, this); get_kernel_manager().kernel_at(0)=policy.select_kernel(); break; } diff --git a/src/shogun/statistical_testing/MMD.h b/src/shogun/statistical_testing/MMD.h index 5282e5b4fa6..0a90d12b6f1 100644 --- a/src/shogun/statistical_testing/MMD.h +++ b/src/shogun/statistical_testing/MMD.h @@ -46,7 +46,7 @@ template class SGMatrix; namespace internal { -class OptMeasure; +class MaxTestPower; } @@ -75,14 +75,13 @@ enum class EKernelSelectionMethod { MEDIAN_HEURISRIC, MAXIMIZE_MMD, - OPTIMIZE_MMD, MAXIMIZE_POWER }; class CMMD : public CTwoSampleTest { using operation=std::function)>; - friend class internal::OptMeasure; + friend class internal::MaxTestPower; public: CMMD(); virtual ~CMMD(); diff --git a/src/shogun/statistical_testing/internals/KernelSelection.cpp b/src/shogun/statistical_testing/internals/KernelSelection.cpp index b453883f2df..90d90f5e1bf 100644 --- a/src/shogun/statistical_testing/internals/KernelSelection.cpp +++ b/src/shogun/statistical_testing/internals/KernelSelection.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include namespace shogun { @@ -55,7 +55,7 @@ CKernel* KernelSelection::select_kernel() } template class KernelSelection; -template class KernelSelection; +template class KernelSelection; } diff --git a/src/shogun/statistical_testing/internals/OptMeasure.cpp b/src/shogun/statistical_testing/internals/MaxTestPower.cpp similarity index 90% rename from src/shogun/statistical_testing/internals/OptMeasure.cpp rename to src/shogun/statistical_testing/internals/MaxTestPower.cpp index 6bd1af0f28a..df4562777f4 100644 --- a/src/shogun/statistical_testing/internals/OptMeasure.cpp +++ b/src/shogun/statistical_testing/internals/MaxTestPower.cpp @@ -34,18 +34,18 @@ #include #include #include -#include +#include #include using namespace shogun; using namespace internal; -OptMeasure::OptMeasure(KernelManager& km, CMMD* est) -: KernelSelection(km), estimator(est), lambda(1E-5) +MaxTestPower::MaxTestPower(KernelManager& km, CMMD* est) +: KernelSelection(km), estimator(est), lambda(1E-5) { } -SGVector OptMeasure::compute_measures() +SGVector MaxTestPower::compute_measures() { SGVector result(kernel_mgr.num_kernels()); for (size_t i=0; i OptMeasure::compute_measures() return result; } -CKernel* OptMeasure::select_kernel() +CKernel* MaxTestPower::select_kernel() { REQUIRE(estimator!=nullptr, "Estimator is not set!\n"); REQUIRE(kernel_mgr.num_kernels()>0, "Number of kernels is %d!\n", kernel_mgr.num_kernels()); diff --git a/src/shogun/statistical_testing/internals/OptMeasure.h b/src/shogun/statistical_testing/internals/MaxTestPower.h similarity index 87% rename from src/shogun/statistical_testing/internals/OptMeasure.h rename to src/shogun/statistical_testing/internals/MaxTestPower.h index d6cde667f5b..1c894f8b401 100644 --- a/src/shogun/statistical_testing/internals/OptMeasure.h +++ b/src/shogun/statistical_testing/internals/MaxTestPower.h @@ -29,8 +29,8 @@ * either expressed or implied, of the Shogun Development Team. */ -#ifndef OPT_MEASURE_H__ -#define OPT_MEASURE_H__ +#ifndef MAX_TEST_POWER_H__ +#define MAX_TEST_POWER_H__ #include #include @@ -45,12 +45,12 @@ template class SGVector; namespace internal { -class OptMeasure : public KernelSelection +class MaxTestPower : public KernelSelection { public: - OptMeasure(KernelManager&, CMMD*); - OptMeasure(const OptMeasure& other)=delete; - OptMeasure& operator=(const OptMeasure& other)=delete; + MaxTestPower(KernelManager&, CMMD*); + MaxTestPower(const MaxTestPower& other)=delete; + MaxTestPower& operator=(const MaxTestPower& other)=delete; CKernel* select_kernel(); protected: SGVector compute_measures(); @@ -62,4 +62,4 @@ class OptMeasure : public KernelSelection } -#endif // OPT_MEASURE_H__ +#endif // MAX_TEST_POWER_H__ diff --git a/tests/unit/statistical_testing/KernelSelectionOptMMD_unittest.cc b/tests/unit/statistical_testing/KernelSelectionMaxPower_unittest.cc similarity index 97% rename from tests/unit/statistical_testing/KernelSelectionOptMMD_unittest.cc rename to tests/unit/statistical_testing/KernelSelectionMaxPower_unittest.cc index 7b22f53905e..af50f810a32 100644 --- a/tests/unit/statistical_testing/KernelSelectionOptMMD_unittest.cc +++ b/tests/unit/statistical_testing/KernelSelectionMaxPower_unittest.cc @@ -72,7 +72,7 @@ TEST(KernelSelectionOptMMD, perform_test_permutation_biased_full) mmd->add_kernel(new CGaussianKernel(10, sq_sigma_twice)); } - mmd->select_kernel(EKernelSelectionMethod::OPTIMIZE_MMD); + mmd->select_kernel(EKernelSelectionMethod::MAXIMIZE_POWER); auto selected_kernel=static_cast(mmd->get_kernel()); EXPECT_NEAR(selected_kernel->get_width(), 0.5, 1E-10); @@ -118,7 +118,7 @@ TEST(KernelSelectionOptMMD, perform_test_permutation_unbiased_full) mmd->add_kernel(new CGaussianKernel(10, sq_sigma_twice)); } - mmd->select_kernel(EKernelSelectionMethod::OPTIMIZE_MMD); + mmd->select_kernel(EKernelSelectionMethod::MAXIMIZE_POWER); auto selected_kernel=static_cast(mmd->get_kernel()); EXPECT_NEAR(selected_kernel->get_width(), 0.5, 1E-10); @@ -164,7 +164,7 @@ TEST(KernelSelectionOptMMD, perform_test_permutation_unbiased_incomplete) mmd->add_kernel(new CGaussianKernel(10, sq_sigma_twice)); } - mmd->select_kernel(EKernelSelectionMethod::OPTIMIZE_MMD); + mmd->select_kernel(EKernelSelectionMethod::MAXIMIZE_POWER); auto selected_kernel=static_cast(mmd->get_kernel()); EXPECT_NEAR(selected_kernel->get_width(), 0.5, 1E-10);