Example #1
0
 def test_extract_with_confidence_output_dictionary_unsupervised(self):
     X, _ = load_xy(2)
     extractor = MFE(groups="general").fit(X.values)
     res = extractor.extract_with_confidence(
         3, arguments_extract=dict(out_type=dict))
     assert isinstance(res, dict)
     assert len(res) == 3
Example #2
0
 def test_extract_with_time_and_with_confidence_output_dictionary(self):
     X, y = load_xy(2)
     extractor = MFE(groups="general",
                     measure_time="total").fit(X.values, y.values)
     res = extractor.extract_with_confidence(
         3, arguments_extract=dict(out_type=dict))
     assert isinstance(res, dict)
     assert len(res) == 4
Example #3
0
 def test_invalid_output_type_with_confidence_unsupervised(self):
     X, _ = load_xy(2)
     extractor = MFE(groups="general").fit(X.values)
     with pytest.raises(TypeError):
         res = extractor.extract_with_confidence(
             3, arguments_extract=dict(out_type=set))
interval.
"""

# Load a dataset
import sklearn.tree
from sklearn.datasets import load_iris
from pymfe.mfe import MFE

data = load_iris()
y = data.target
X = data.data

# You can also extract your meta-features with confidence intervals using
# bootstrap. Keep in mind that this method extracts each meta-feature several
# times, and may be very expensive depending mainly on your data and the
# number of meta-feature extract methods called.

# Extract meta-features with confidence interval
mfe = MFE(features=["mean", "nr_cor_attr", "sd", "max"])
mfe.fit(X, y)

ft = mfe.extract_with_confidence(
    sample_num=256,
    confidence=0.99,
    verbose=1,
)

print("\n".join("{:50} {:30} {:30}".format(x, y[0], y[1])
                for x, y in zip(ft[0], ft[2])))

Example #5
0
 def test_bootstrap_extractor_extract_with_confidence_without_data(self):
     mfe = MFE()
     bootstrap_extractor = _bootstrap.BootstrapExtractor(extractor=mfe)
     with pytest.raises(TypeError):
         mfe.extract_with_confidence()
Example #6
0
 def test_extract_with_confidence_without_data(self):
     mfe = MFE()
     with pytest.raises(TypeError):
         mfe.extract_with_confidence()