ium_464937/05.ipynb
Szymon Bartanowicz bfc6feba86 ium 5
2024-04-23 22:10:38 +02:00

82 lines
2.2 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"is_executing": true
},
"outputs": [],
"source": [
"import pandas as pd\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn.preprocessing import StandardScaler\n",
"import tensorflow as tf\n",
"from tensorflow.keras.models import Sequential\n",
"from tensorflow.keras.layers import Dense\n",
"\n",
"# Wczytywanie danych\n",
"data = pd.read_csv('openpowerlifting.csv')\n",
"\n",
"# Zakładając, że kolumny to 'squat', 'bench_press', 'deadlift' i 'total'\n",
"features = data[['squat', 'bench_press', 'deadlift']]\n",
"target = data['total']\n",
"\n",
"# Podział na dane treningowe i testowe\n",
"X_train, X_test, y_train, y_test = train_test_split(features, target, test_size=0.2, random_state=42)\n",
"\n",
"# Normalizacja danych\n",
"scaler = StandardScaler()\n",
"X_train = scaler.fit_transform(X_train)\n",
"X_test = scaler.transform(X_test) # Używamy tego samego scaler do danych testowych\n",
"\n",
"# Tworzenie modelu\n",
"model = Sequential([\n",
" Dense(64, activation='relu', input_shape=(X_train.shape[1],)),\n",
" Dense(64, activation='relu'),\n",
" Dense(1)\n",
"])\n",
"\n",
"model.compile(optimizer='adam', loss='mse', metrics=['mae'])\n",
"\n",
"# Trenowanie modelu\n",
"model.fit(X_train, y_train, epochs=10, validation_split=0.1) # Używam validation_split zamiast oddzielnego zbioru\n",
"\n",
"# Save the model\n",
"model.save('powerlifting_model.h5')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
}
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}