2.2 KiB
2.2 KiB
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
import tensorflow as tf
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
# Wczytywanie danych
data = pd.read_csv('openpowerlifting.csv')
# Zakładając, że kolumny to 'squat', 'bench_press', 'deadlift' i 'total'
features = data[['squat', 'bench_press', 'deadlift']]
target = data['total']
# Podział na dane treningowe i testowe
X_train, X_test, y_train, y_test = train_test_split(features, target, test_size=0.2, random_state=42)
# Normalizacja danych
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test) # Używamy tego samego scaler do danych testowych
# Tworzenie modelu
model = Sequential([
Dense(64, activation='relu', input_shape=(X_train.shape[1],)),
Dense(64, activation='relu'),
Dense(1)
])
model.compile(optimizer='adam', loss='mse', metrics=['mae'])
# Trenowanie modelu
model.fit(X_train, y_train, epochs=10, validation_split=0.1) # Używam validation_split zamiast oddzielnego zbioru
# Save the model
model.save('powerlifting_model.h5')