text_html_output_1.png text_plain_output_1.png
from sklearn.model_selection import train_test_split

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.model_selection import GridSearchCV
from sklearn.neighbors import KNeighborsClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
from sklearn.metrics import f1_score
from sklearn.metrics import roc_auc_score
pd.options.display.max_rows = None
pd.options.display.max_columns = None
SEED = 581

data = pd.read_csv('/kaggle/input/mushroom-classification/mushrooms.csv')

data.isna().any()

mapping = {'e': 1, 'p': 0}
data.rename({'class': 'edible'}, axis=1, inplace=True)
data['edible'] = data['edible'].replace(mapping)
data = data.astype('category')
data.dtypes

sum = 0
for n in data.nunique():
    sum += n
sum = sum - data.shape[1]

data = pd.get_dummies(data, drop_first=True)

data.rename({'edible_1': 'edible'}, axis=1, inplace=True)

X = data.iloc[:, 1:].values
y = data.iloc[:, 0].values
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=SEED)
print(X_train.shape)
print(X_test.shape)
print(y_train.shape)
print(y_test.shape)