<jupyter_start><jupyter_text>Build Classification Model<jupyter_code>import pandas as pd
cuisines_df = pd.read_csv("../data/cleaned_cuisines.csv")
cuisines_df.head()
cuisines_label_df = cuisines_df['cuisine']
cuisines_label_df.head()
cuisines_feature_df = cuisines_df.drop(['Unnamed: 0', 'cuisine'], axis=1)
cuisines_feature_df.head()
from sklearn.model_selection import train_test_split, cross_val_score
from sklearn.linear_model import LinearRegression
from sklearn.neighbors import KNeighborsClassifier
from sklearn.svm import SVC
from sklearn.ensemble import RandomForestClassifier, AdaBoostClassifier
from sklearn.metrics import accuracy_score, precision_score, classification_report, confusion_matrix, precision_recall_curve
import numpy as np
X_train, X_test, y_train, y_test = train_test_split(cuisines_feature_df, cuisines_label_df, test_size= 0.3, random_state= 0)
C = 10
classifiers = {
    'Linear SVC': SVC(kernel='linear', C = C, probability=True , random_state=0),
    'K Neighbours': KNeighborsClassifier(n_neighbors=C),
    'SVC': SVC(),
    'Random Forest': RandomForestClassifier(n_estimators=100),
    'Ada Boost': AdaBoostClassifier(n_estimators=100)
}
for index, (name, classifier) in enumerate(classifiers.items()):
    classifier.fit(X_train, y_train)
    y_pred = classifier.predict(X_test)
    accuracy = accuracy_score(y_test, y_pred)
    print('Accuracy for %s model is %0.1f%%' % (name, accuracy*100))
    print('classification Report', classification_report(y_test, y_pred))<jupyter_output>Accuracy for Linear SVC model is 78.1%
classification Report               precision    recall  f1-score   support

     chinese       0.68      0.73      0.70       245
      indian       0.84      0.90      0.87       233
    japanese       0.77      0.73      0.75       249
      korean       0.84      0.74      0.78       222
        thai       0.80      0.80      0.80       250

    accuracy                           0.78      1199
   macro avg       0.78      0.78      0.78      1199
weighted avg       0.78      0.78      0.78      1199

Accuracy for K Neighbours model is 73.6%
classification Report               precision    recall  f1-score   support

     chinese       0.67      0.67      0.67       245
      indian       0.82      0.85      0.83       233
    japanese       0.65      0.83      0.73       249
      korean       0.90      0.53      0.66       222
        thai       0.75      0.80      0.77       250

    accuracy                           0.74      1199
   macr[...]
{'fraction_non_alphanumeric': 0.08205732234000786, 'fraction_numerical': 0.07341970946211229, 'mean_word_length': 2.25, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '196359', 'license': 'MIT', 'n_tokens_mistral': 953, 'n_tokens_neox': 846, 'n_words': 202, 'path': '4-Classification/3-Classifiers-2/notebook.ipynb', 'repo_name': 'RupeshRavindraDharme/ML-For-Beginners', 'size': '2547'}