<jupyter_start><jupyter_text>Best channel searchRealizando 20 rodadas de classificação com `SVC` no dataset `chb01dwt` para determinar com qual canal se obtém os melhores resultados. Importando biblioteca<jupyter_code>import numpy as np
import pandas as pd

from sklearn.svm import SVC
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split<jupyter_output><empty_output><jupyter_text>Carregando dados<jupyter_code>chb_dwt_df = pd.read_csv('./chb01dwt.csv')

target_dwt_s = chb_dwt_df.pop('target')

random_seeds = np.random.randint(0, 9000, 20)

random_seeds<jupyter_output><empty_output><jupyter_text>Realizando classificação por canal<jupyter_code>channels_df = pd.DataFrame(columns=range(18))

for channel in range(18):

    channel_acc = []

    # X recebe apenas as colunas relacionadas ao canal da iteração
    X = chb_dwt_df[
        [column for column in chb_dwt_df.columns if (f'{channel}' in column.split('-'))]
    ].values
    y = target_dwt_s.values

    for seed in random_seeds:
        # Separando dados
        X_pre_train, X_pre_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=seed)

        # Pré-processando dados
        std_scaler = StandardScaler().fit(X_pre_train)

        X_train = std_scaler.transform(X_pre_train)
        X_test = std_scaler.transform(X_pre_test)

        # Instanciando classificador
        classifier = SVC(cache_size=500).fit(X_train, y_train)

        # Salvando acurácia da classificação
        channel_acc.append(classifier.score(X_test, y_test))
    
    channels_df[channel] = channel_acc

channels_df
channels_df.boxplot(figsize=(10, 6))
channels_df.describe().transpose().sort_values(by='mean', ascending=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09142212189616253, 'fraction_numerical': 0.014108352144469526, 'mean_word_length': 4.7752442996742674, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '90607', 'license': 'MIT', 'n_tokens_mistral': 657, 'n_tokens_neox': 628, 'n_words': 125, 'path': 'ML/f02-chb/chb01/05-svc-best-channel.ipynb', 'repo_name': 'newtmagalhaes/Machine-Learning', 'size': '1772'}