Note
Click here to download the full example code
Meta-feature confidence interval
In this example, we will show you how to extract meta-features with confidence interval.
Began the metafeature extraction with confidence intervals process.
Now extracting metafeatures from original sample.
Done extracting metafeatures from original sample (total of 7 metafeatures).
Started data resampling with bootstrap with the following configurations:
| Total data resamples: 256
| Confidence levels used: [0.99] (total of 1).
. Random seeds:
| For extractor model: 1234
. For bootstrapping: None
Now extracting metafeatures from resampled data.
0%| | 0/256 [00:00<?, ?it/s]
8%|8 | 21/256 [00:00<00:01, 202.40it/s]
16%|#6 | 42/256 [00:00<00:01, 202.64it/s]
25%|##4 | 63/256 [00:00<00:00, 202.53it/s]
33%|###2 | 84/256 [00:00<00:00, 202.04it/s]/home/docs/checkouts/readthedocs.org/user_builds/pymfe/envs/latest/lib/python3.7/site-packages/pymfe/_internal.py:1568: UserWarning: It is not possible make equal discretization
warnings.warn("It is not possible make equal discretization")
41%|####1 | 105/256 [00:00<00:00, 200.95it/s]
49%|####9 | 126/256 [00:00<00:00, 201.55it/s]
57%|#####7 | 147/256 [00:00<00:00, 201.21it/s]/home/docs/checkouts/readthedocs.org/user_builds/pymfe/envs/latest/lib/python3.7/site-packages/pymfe/_internal.py:1568: UserWarning: It is not possible make equal discretization
warnings.warn("It is not possible make equal discretization")
/home/docs/checkouts/readthedocs.org/user_builds/pymfe/envs/latest/lib/python3.7/site-packages/pymfe/_internal.py:1568: UserWarning: It is not possible make equal discretization
warnings.warn("It is not possible make equal discretization")
66%|######5 | 168/256 [00:00<00:00, 201.27it/s]/home/docs/checkouts/readthedocs.org/user_builds/pymfe/envs/latest/lib/python3.7/site-packages/pymfe/_internal.py:1568: UserWarning: It is not possible make equal discretization
warnings.warn("It is not possible make equal discretization")
74%|#######3 | 189/256 [00:00<00:00, 201.36it/s]
82%|########2 | 210/256 [00:01<00:00, 201.49it/s]
90%|######### | 231/256 [00:01<00:00, 201.45it/s]
98%|#########8| 252/256 [00:01<00:00, 201.70it/s]
100%|##########| 256/256 [00:01<00:00, 201.50it/s]
Done extracting metafeatures from resampled data.
Finished data resampling with bootstrap.
Now calculating confidence intervals... Done.
max.mean 5.425000000000001 5.600000000000001
max.sd 2.3630154293776005 2.5506030820292405
mean.mean 3.3116583333333347 3.601854166666668
mean.sd 1.8734800708370076 1.9621468909848063
nr_cor_attr 0.16666666666666674 0.5
sd.mean 0.8874615748303925 1.012106432730215
sd.sd 0.5227226500340972 0.6299378732590926
# 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])))
Total running time of the script: ( 0 minutes 1.285 seconds)