python scripts

This commit is contained in:
Natalia Szymczyk 2023-04-21 10:34:30 +02:00
parent 840b9526b3
commit 99bb6baaa8
2 changed files with 2167 additions and 0 deletions

2145
lab_02.ipynb Normal file

File diff suppressed because it is too large Load Diff

22
main.py Normal file
View File

@ -0,0 +1,22 @@
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from datasets import load_dataset
dataset = load_dataset("mstz/liver")['train']
dataset = dataset.to_pandas()
train, test = train_test_split(dataset, test_size=0.2, random_state=42)
train, val = train_test_split(train, test_size=0.2, random_state=42)
numerical_features = ['age', 'total_bilirubin', 'direct_ribilubin', 'alkaline_phosphotase',
'alamine_aminotransferasi', 'aspartate_aminotransferase', 'total_proteins', 'albumin',
'albumin_to_globulin_ratio']
scaler = MinMaxScaler()
train[numerical_features] = scaler.fit_transform(train[numerical_features])
test[numerical_features] = scaler.fit_transform(test[numerical_features])
val[numerical_features] = scaler.fit_transform(val[numerical_features])
train.dropna(inplace=True)
test.dropna(inplace=True)
val.dropna(inplace=True)