<jupyter_start><jupyter_text>Generate an imbalanced datasetAn illustration of using the :func:`~imbalanced_ensemble.datasets.generate_imbalance_data` function to create an imbalanced dataset.<jupyter_code># Authors: <NAME> <<EMAIL>>
# License: MIT
print(__doc__)

from imbalanced_ensemble.datasets import generate_imbalance_data
from imbalanced_ensemble.utils._plot import plot_2Dprojection_and_cardinality
from collections import Counter<jupyter_output><empty_output><jupyter_text>Generate the dataset<jupyter_code>X_train, X_test, y_train, y_test = generate_imbalance_data(
    n_samples=1000, weights=[.7,.2,.1], test_size=.5,
    kwargs={'n_informative': 3},
)

print ("Train class distribution: ", Counter(y_train))
print ("Test class distribution:  ", Counter(y_test))<jupyter_output><empty_output><jupyter_text>Plot the generated (training) data<jupyter_code>plot_2Dprojection_and_cardinality(X_train, y_train)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10242872228088701, 'fraction_numerical': 0.011615628299894404, 'mean_word_length': 10.152941176470588, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '342801', 'license': 'MIT', 'n_tokens_mistral': 334, 'n_tokens_neox': 320, 'n_words': 59, 'path': 'docs/source/auto_examples/datasets/plot_generate_imbalance.ipynb', 'repo_name': 'ZhiningLiu1998/imbalanced-ensemble', 'size': '968'}