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

import matplotlib.pyplot as plt

import numpy as np # linear algebra

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

train_data = pd.read_csv('/kaggle/input/Kannada-MNIST/train.csv')

train_data.isnull().sum().sum()

fig, ax = plt.subplots(5,5,figsize = (8,8))
for i in range(5):
    for j in range(5):
        ax[i][j].axis('off')
        ax[i][j].imshow(train_data.iloc[[i+(j*5)], 1:].to_numpy().astype(np.uint8).reshape(28, 28), cmap='gray')

plt.show()
#temp = train_data.iloc[:1, 1:].to_numpy().reshape(28,28)
#plt.imshow(temp, cmap='gray')

yX = train_data.copy()
y = yX.pop('label')
X = yX.copy()
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.9, random_state=42)
(X_train.shape, X_test.shape, y_train.shape, y_test.shape)

yX2 = train_data.copy()
y2 = yX2.pop('label')
X2 = yX2.copy()
X2_train, X2_test, y2_train, y2_test = train_test_split(X2, y2, test_size=0.4, random_state=42)
(X2_train.shape, X2_test.shape, y2_train.shape, y2_test.shape)