<jupyter_start><jupyter_text>numpy test<jupyter_code>import numpy as np
a = np.array([
    [0.1, 0.2, 0.6],
    [0.8, 0.2, 0.0],
    [0.1, 0.2, 0.0],
])
label = np.array([
    [1, 0, 1],
    [1, 0, 1],
    [0, 0, 0],
])
print(f"a > 0.5: {(a > 0.5)}")
print(f"a: {a}")
print(f"label: {label}")
(a > 0.5) == label
np.sum((a > 0.5) == label, axis=1)
np.shape(label)[1]
np.average(
    np.sum((a > 0.5) == label, axis=1) / np.shape(label)[1]
)
import numpy as np
from sklearn.metrics import (
    label_ranking_average_precision_score, 
    roc_auc_score, 
    accuracy_score,
    average_precision_score,
    f1_score,
    recall_score,
    precision_score,
)
accuracy_score(label, a > 0.5)
average_precision_score(label, a)
# recall
np.sum(label)
np.sum((a > 0.5) * label)
np.average(
    np.sum((a > 0.5) * label) / np.sum(label)
)
f1_score(label, a > 0.5, average='samples')
precision_score(label, a > 0.5, average='samples')
recall_score(label, a > 0.5, average='samples')
import matplotlib.pyplot as plt
import numpy as np
import japanize_matplotlib

fig = plt.figure(figsize=(8, 4))
ax = fig.add_subplot(1, 1, 1)

x = np.linspace(500, 5000, 10)

ax.plot(x, [0.0971, 0.1007, 0.1530, 0.1832, 0.1714, 0.1759, 0.1792, 0.1972, 0.2051, 0.2021], label="パターン1", marker="o")
ax.plot(x, [0.4817, 0.4995, 0.5375, 0.5604, 0.5672, 0.5812, 0.5808, 0.5911, 0.5890, 0.5929], label="パターン2", marker="*")

ax.grid()
ax.set_xlabel('イテレーション回数', fontsize=18)
ax.set_ylabel('F1値', fontsize=18)
ax.set_xlim(0, 5500)

plt.show()
x = np.linspace(500, 5000, 10)
x<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20395156150414276, 'fraction_numerical': 0.12109623964308477, 'mean_word_length': 3.984126984126984, 'pattern_counts': {'":': 0, '<': 5, '<?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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '605274', 'license': 'MIT', 'n_tokens_mistral': 854, 'n_tokens_neox': 739, 'n_words': 150, 'path': 'chapter_6/dimentionality_reduction.ipynb', 'repo_name': 'kami9811/scikit-learn-study', 'size': '1569'}