mirror of
https://github.com/Doctorado-ML/mufs.git
synced 2025-08-16 16:15:56 +00:00
Complete iwss based implementation (#2)
This commit is contained in:
@@ -318,6 +318,7 @@ class MUFS:
|
|||||||
self._scores.append(merit_new)
|
self._scores.append(merit_new)
|
||||||
else:
|
else:
|
||||||
candidates.pop()
|
candidates.pop()
|
||||||
|
break
|
||||||
if len(candidates) == self._max_features:
|
if len(candidates) == self._max_features:
|
||||||
break
|
break
|
||||||
self._result = candidates
|
self._result = candidates
|
||||||
|
@@ -1,11 +1,14 @@
|
|||||||
import unittest
|
import unittest
|
||||||
|
import os
|
||||||
|
import pandas as pd
|
||||||
|
import numpy as np
|
||||||
from mdlp import MDLP
|
from mdlp import MDLP
|
||||||
from sklearn.datasets import load_wine, load_iris
|
from sklearn.datasets import load_wine, load_iris
|
||||||
|
|
||||||
from ..Selection import MUFS
|
from ..Selection import MUFS
|
||||||
|
|
||||||
|
|
||||||
class MUFS_test(unittest.TestCase):
|
class MUFSTest(unittest.TestCase):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
mdlp = MDLP(random_state=1)
|
mdlp = MDLP(random_state=1)
|
||||||
@@ -175,9 +178,6 @@ class MUFS_test(unittest.TestCase):
|
|||||||
mufs.iwss(self.X_w, self.y_w, -0.01)
|
mufs.iwss(self.X_w, self.y_w, -0.01)
|
||||||
|
|
||||||
def test_iwss_better_merit_condition(self):
|
def test_iwss_better_merit_condition(self):
|
||||||
import pandas as pd
|
|
||||||
import os
|
|
||||||
|
|
||||||
folder = os.path.dirname(os.path.abspath(__file__))
|
folder = os.path.dirname(os.path.abspath(__file__))
|
||||||
data = pd.read_csv(
|
data = pd.read_csv(
|
||||||
os.path.join(folder, "balloons_R.dat"),
|
os.path.join(folder, "balloons_R.dat"),
|
||||||
@@ -189,3 +189,8 @@ class MUFS_test(unittest.TestCase):
|
|||||||
mufs = MUFS()
|
mufs = MUFS()
|
||||||
expected = [0, 2, 3, 1]
|
expected = [0, 2, 3, 1]
|
||||||
self.assertListEqual(expected, mufs.iwss(X, y, 0.3).get_results())
|
self.assertListEqual(expected, mufs.iwss(X, y, 0.3).get_results())
|
||||||
|
|
||||||
|
def test_iwss_empty(self):
|
||||||
|
mufs = MUFS()
|
||||||
|
X = np.delete(self.X_i, [0, 1], 1)
|
||||||
|
self.assertListEqual(mufs.iwss(X, self.y_i, 0.3).get_results(), [1, 0])
|
||||||
|
@@ -6,7 +6,7 @@ from mdlp import MDLP
|
|||||||
from ..Selection import Metrics
|
from ..Selection import Metrics
|
||||||
|
|
||||||
|
|
||||||
class Metrics_test(unittest.TestCase):
|
class MetricsTest(unittest.TestCase):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
mdlp = MDLP(random_state=1)
|
mdlp = MDLP(random_state=1)
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
from .MUFS_test import MUFS_test
|
from .MUFS_test import MUFSTest
|
||||||
from .Metrics_test import Metrics_test
|
from .Metrics_test import MetricsTest
|
||||||
|
|
||||||
__all__ = ["MUFS_test", "Metrics_test"]
|
__all__ = ["MUFSTest", "MetricsTest"]
|
||||||
|
Reference in New Issue
Block a user