<jupyter_start><jupyter_text>Select the classification model<jupyter_code>import pandas as pd
df = pd.read_csv(".csv/03_datapoints.csv")
df.shape
from sklearn.model_selection import train_test_split
from sklearn.linear_model import SGDClassifier
from sklearn.svm import SVC
from sklearn.ensemble import RandomForestClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import confusion_matrix, accuracy_score, precision_score, recall_score, f1_score
import matplotlib.pyplot as plt
import seaborn as sns

X = df.drop("label", axis=1)
X.head()
y = df["label"].astype(str).apply(lambda x: x[:-1]+"0")
y
X_train, X_test, y_train, y_test = train_test_split(X,y,random_state=42)
X_train.shape,X_test.shape,y_train.shape,y_test.shape,
def metrics(model, X=X_test, y=y_test, average="macro"):
    metrics = {}
    functions = {'accuracy': accuracy_score, 
                 'precision': lambda *args: precision_score(*args,average=average, zero_division=1), 
                 'recall': lambda *args: recall_score(*args,average=average), 
                 'f_score': lambda *args: f1_score(*args,average=average)}
    model.fit(X_train, y_train)
    y_pred = model.predict(X)
    for n,m in functions.items():
        metrics[n] = m(y,y_pred)
    return metrics
metrics(SGDClassifier(random_state=42))
metrics(RandomForestClassifier(random_state=42))
metrics(KNeighborsClassifier(20))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11576011157601115, 'fraction_numerical': 0.011157601115760111, 'mean_word_length': 5.58256880733945, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '443497', 'license': 'MIT', 'n_tokens_mistral': 507, 'n_tokens_neox': 486, 'n_words': 98, 'path': 'data/04_model_selection-Copy1.ipynb', 'repo_name': 'teresaromero/decadance', 'size': '1434'}