<jupyter_start><jupyter_text>make dataset<jupyter_code># get training dataset and target dataset
x = list(meta_data.loc[:,"filename"])
y = list(meta_data.loc[:, "target"])

x_train, x_test, y_train, y_test = model_selection.train_test_split(x, y, test_size=0.25, stratify=y, )
print(x_train[0], class_dict[y_train[0]])<jupyter_output>3-111102-A-46.wav church_bells<jupyter_text>wavデータをメルスペクトラムに変換し、npz形式で保存。<jupyter_code>import os
os.makedirs("data", exist_ok=True)
len(x)
if SAVE_DATA:
    for i in range(len(x)):
        try:
            # load wave
            x, fs = load_wave_data(audio_dir, meta_data.loc[i,"filename"])

            # cvt 2 melsp
            melsp = calculate_melsp(x)

            # save mel spectrum
            np.savez_compressed("data/{}".format(meta_data.loc[i,"filename"]), melsp)
        except:
            print("oops, failed!")

# test load
data = np.load("data/{}.npz".format(meta_data.loc[0,"filename"]))["arr_0"]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1510204081632653, 'fraction_numerical': 0.017346938775510204, 'mean_word_length': 4.005102040816326, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '453805', 'license': 'MIT', 'n_tokens_mistral': 394, 'n_tokens_neox': 390, 'n_words': 58, 'path': 'dataset_setup.ipynb', 'repo_name': 'kentaroy47/ESC-50.pytorch', 'size': '980'}