<jupyter_start><jupyter_text>Read UCR data<jupyter_code>X_train, y_train, X_test, y_test = get_ucr_dataset('../data/UCR/raw_data/', 'ItalyPowerDemand')<jupyter_output><empty_output><jupyter_text>Compute wasserstein distance matrices with subsequent length $k=10$<jupyter_code>D_train, D_test = transform_to_dist_matrix(X_train, X_test, 10)<jupyter_output><empty_output><jupyter_text>Run the grid search<jupyter_code>svm_clf = krein_svm_grid_search(D_train, D_test, y_train, y_test)<jupyter_output>INFO:root:Starting analysis
INFO:root:Accuracy = 95.34<jupyter_text>Alternatively: Get the kernel matrices computed from the distance matrices ...<jupyter_code>K_train = get_kernel_matrix(D_train, psd=True, gamma=0.2)
K_test = get_kernel_matrix(D_test, psd=False, gamma=0.2)<jupyter_output><empty_output><jupyter_text>... and train your own classifier<jupyter_code>clf = SVC(C=5, kernel='precomputed')
clf.fit(K_train, y_train)
y_pred = clf.predict(K_test)
accuracy_score(y_test, y_pred)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11834319526627218, 'fraction_numerical': 0.01282051282051282, 'mean_word_length': 11.083333333333334, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '518500', 'license': 'MIT', 'n_tokens_mistral': 420, 'n_tokens_neox': 402, 'n_words': 59, 'path': 'examples/example_notebook.ipynb', 'repo_name': 'vishalbelsare/WTK', 'size': '1014'}