text_html_output_1.png
import math

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import seaborn as sns

train = pd.read_csv('/kaggle/input/playground-series-s3e14/train.csv')
test = pd.read_csv('/kaggle/input/playground-series-s3e14/test.csv')
original = pd.read_csv('/kaggle/input/originall/dataa.csv')

original = original.rename(columns={'Row': 'id'})

desc = train.describe().T
desc['nunique'] = train.nunique()
desc['%unique'] = desc['nunique'] / len(train) * 100
desc['null'] = train.isna().sum()
desc['type'] = train.dtypes
desc.head(60)

desc = test.describe().T
desc['nunique'] = test.nunique()
desc['%unique'] = desc['nunique'] / len(test) * 100
desc['null'] = test.isna().sum()
desc['type'] = test.dtypes
desc.head(60)

import math
train_data=train.drop(columns=['id','yield'],axis=1)
test_data=test.drop(columns='id',axis=1)
original_data=original.drop(columns=['yield','id'],axis=1)

numerical_columns = train_data.select_dtypes(include=['float64', 'int64']).columns.tolist()

# calculate number of rows and columns needed for subplots
num_plots = len(numerical_columns)
num_rows = math.ceil(num_plots/3)
num_cols = min(num_plots, 3)

# create subplots
fig, axes = plt.subplots(nrows=num_rows, ncols=num_cols, figsize=(12, 4*num_rows))

# loop over columns and plot distribution
plot_idx = 0
for i in range(num_rows):
    for j in range(num_cols):
        if plot_idx >= num_plots:
            break
        if (train[numerical_columns[plot_idx]].count() > 0) and (test[numerical_columns[plot_idx]].count() > 0):
            sns.kdeplot(train_data[numerical_columns[plot_idx]], ax=axes[i][j], color='red', label='train')
            sns.kdeplot(test_data[numerical_columns[plot_idx]], ax=axes[i][j], color='green', label='test')
            sns.kdeplot(original_data[numerical_columns[plot_idx]], ax=axes[i][j], color='yellow', label='original')
            axes[i][j].set_xlabel(numerical_columns[plot_idx])
            axes[i][j].legend()
            plot_idx += 1
        else:
            # empty plot, no data to plot
            axes[i][j].axis('off')

plt.tight_layout()
plt.show()

def heatmap(dataset, title):
    corr = dataset.corr()
    fig, axes = plt.subplots(figsize=(20, 10))
    mask = np.zeros_like(corr)
    mask[np.triu_indices_from(mask)] = True
    sns.heatmap(corr, linewidths=0.5, mask=mask, cmap='plasma', annot=True)
    plt.title(title, fontsize=30)
    plt.show()
heatmap(train_data, 'Train Dataset Correlation')
heatmap(original_data, 'original data correlation')
heatmap(test_data, 'test data correlation')