text_html_output_1.png
from sklearn.preprocessing import StandardScaler

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

df = pd.read_csv('/kaggle/input/uci-breast-cancer-wisconsin-original/breast-cancer-wisconsin.data.txt')

df.shape

col_names = ['Id', 'Clump_thickness', 'Uniformity_Cell_Size', 'Uniformity_Cell_Shape', 'Marginal_Adhesion', 'Single_Epithelial_Cell_Size', 'Bare_Nuclei', 'Bland_Chromatin', 'Normal_Nucleoli', 'Mitoses', 'Class']
df.columns = col_names
df.columns

df.drop('Id', axis=1, inplace=True)

df['Bare_Nuclei'] = pd.to_numeric(df['Bare_Nuclei'], errors='coerce')

(X_train.shape, X_test.shape)

X_train.dtypes

X_train.isnull().sum()

X_test.isnull().sum()

for df1 in [X_train, X_test]:
    for col in X_train.columns:
        col_median = X_train[col].median()
        df1[col].fillna(col_median, inplace=True)

X_train.isnull().sum()

X_test.isnull().sum()

cols = X_train.columns

from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)

X_train = pd.DataFrame(X_train, columns=[cols])

X_train.head()