<jupyter_start><jupyter_text>Import modules<jupyter_code>import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
from matplotlib import rcParams
from sklearn.datasets import load_boston
import kennard_stone
import numpy as np
import pandas as pd<jupyter_output><empty_output><jupyter_text>The class is called in a special way for the following reasons.> weak "internal use" indicator. E.g. `from M import *`> does not import objects whose names start with an underscore.<jupyter_code>_KennardStone = kennard_stone.kennard_stone._KennardStone<jupyter_output><empty_output><jupyter_text>For reproducibility of random number generation<jupyter_code>np.random.seed(334)<jupyter_output><empty_output><jupyter_text>Two-dimensional random number generation<jupyter_code>example = np.random.rand(2, 100)<jupyter_output><empty_output><jupyter_text>Create an instance and compute indexes.<jupyter_code>ks = _KennardStone(prior = 'train')
indexes = ks._get_indexes(example.transpose())<jupyter_output><empty_output><jupyter_text>Set layout of figure.<jupyter_code>rcParams['font.size'] = 13
rcParams['font.family'] = 'Helvetica'<jupyter_output><empty_output><jupyter_text>Showing in figuresIt can be confirmed that it is possible to take all of them.<jupyter_code># figureオブジェクトの生成
fig = plt.figure(figsize = (5, 5), facecolor = 'white')
ax = fig.add_subplot(111)

# set_trace()
def scatter_(frame):    # 最初の引数は'frame' (何コマ目か)で固定．それ以外の引数はfargsでtupleとして与える．
    # 最初以外，グラフを一旦クリア
    if frame > 0:
        plt.cla()
    
    # scatter
    ax.scatter(*example[:, indexes[:frame]], label = 'selected', s = 30, facecolor = 'None', edgecolors = 'red')
    ax.scatter(*example[:, indexes[frame:]], label = 'remaining', s = 10, c = '#022c5e')

    # 正方形
    ax.set_aspect('equal', adjustable='box')

    # set_lim
    ax.set_xlim(-0.05, 1.05)
    ax.set_ylim(-0.05, 1.05)

    # legend
    ax.legend(facecolor = '#f0f0f0', edgecolor = 'None', fontsize = 10)

# gifアニメ作成
ani = FuncAnimation(fig, scatter_, interval = 200, frames = len(indexes))

# 保存
ani.save('simulate.gif')<jupyter_output>MovieWriter ffmpeg unavailable; using Pillow instead.
{'fraction_non_alphanumeric': 0.12063344201210992, 'fraction_numerical': 0.020027945971122497, 'mean_word_length': 5.951456310679611, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 31, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '471390', 'license': 'MIT', 'n_tokens_mistral': 836, 'n_tokens_neox': 787, 'n_words': 164, 'path': 'example/simulate.ipynb', 'repo_name': 'yu9824/kennard_stone', 'size': '2147'}