# Plotting elapsed time in a meta-feature extraction

In this example, we will show you how the default value max_attr_num of meta-feature attr_conc was defined based on the total elapsed time of Iris dataset. ```0. Number of attributes: 4 ...
1. Number of attributes: 8 ...
2. Number of attributes: 12 ...
3. Number of attributes: 16 ...
4. Number of attributes: 20 ...
5. Number of attributes: 24 ...
6. Number of attributes: 28 ...
7. Number of attributes: 32 ...
8. Number of attributes: 36 ...
9. Number of attributes: 40 ...
```

```# Load a dataset
import numpy as np
import pymfe.mfe
import matplotlib.pyplot as plt

# Added a default value for `max_attr_num` parameter of the `attr_conc`
# meta-feature extraction method, which is the most expensive meta-feature
# extraction method by far.

# The default parameter was determined by a simple inspection at the feature
# extraction time growing rate to the number of attributes on the fitted data.
# The threshold accepted for the time extraction is a value less than 2
# seconds.

# The test dataset was the iris dataset. The test code used is reproduced
# below.
np.random.seed(0)

arrsize = np.zeros(10)
time = np.zeros(10)

X = np.empty((iris.target.size, 0))

for i in np.arange(10):
X = np.hstack((X, iris.data))
print(f"{i}. Number of attributes: {X.shape} ...")
model = pymfe.mfe.MFE(features="attr_conc",
summary="mean",
measure_time="total").fit(X)
res = model.extract(suppress_warnings=True)

arrsize[i] = model._custom_args_ft["C"].shape
time[i] = res

plt.plot(arrsize, time, label="time elapsed")
plt.hlines(y=np.arange(1, 1 + int(np.ceil(np.max(time)))),
xmin=0,
xmax=arrsize[-1],
linestyle="dotted",
color="red")
plt.legend()
plt.show()

# The time cost of extraction for the attr_conc meta-feature does not grow
# significantly with the number of instance and, hence, it is not necessary to
# sample in the instance axis.
```

Total running time of the script: ( 0 minutes 9.215 seconds)

Gallery generated by Sphinx-Gallery
{"ft_lang_label":"__label__en","ft_lang_prob":0.64909893,"math_prob":0.9795953,"size":2055,"snap":"2023-14-2023-23","text_gpt3_token_len":534,"char_repetition_ratio":0.1789371,"word_repetition_ratio":0.0,"special_character_ratio":0.29148418,"punctuation_ratio":0.24044944,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9926428,"pos_list":[0,1,2],"im_url_duplicate_count":[null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-03-24T09:00:27Z\",\"WARC-Record-ID\":\"<urn:uuid:5e48f48e-7533-4557-938b-7d865dce918b>\",\"Content-Length\":\"30119\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8190fff0-acb9-480f-9dd8-6b1b060a296c>\",\"WARC-Concurrent-To\":\"<urn:uuid:106c7547-f336-44ae-abf8-3d957339b679>\",\"WARC-IP-Address\":\"104.17.32.82\",\"WARC-Target-URI\":\"https://pymfe.readthedocs.io/en/latest/auto_examples/03_miscellaneous_examples/plot_extraction_total_elapsed_time.html\",\"WARC-Payload-Digest\":\"sha1:M2EEAUWY5JYYRDURM45DWYEFYHEBBEMC\",\"WARC-Block-Digest\":\"sha1:VK46A6KQGLUXEYRMSAHCNENUZC35XBKH\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296945279.63_warc_CC-MAIN-20230324082226-20230324112226-00301.warc.gz\"}"}