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

all_train_data = pd.read_csv('/kaggle/input/titanic/train.csv')
val_data = all_train_data[:int(0.2 * len(all_train_data))]
train_data = all_train_data[int(0.2 * len(all_train_data)):].reset_index()
test_data = pd.read_csv('/kaggle/input/titanic/test.csv')

survived_ratio = sum(train_data['Survived']) / len(train_data)
scale_pos_weight = (1 - survived_ratio) / survived_ratio
print(f'survival ratio = {survived_ratio}')
print(f'unbalance ratio = {scale_pos_weight}')