Usuń 'predict.ipynb'

This commit is contained in:
Michał Dudziak 2023-05-11 13:11:22 +02:00
parent 691c134d13
commit f399011471

View File

@ -1,84 +0,0 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "47153112-da26-4dbd-a32a-1abdd8bda4fa",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2949/2949 [==============================] - 2s 498us/step\n"
]
}
],
"source": [
"import tensorflow as tf\n",
"import pandas as pd\n",
"import numpy as np\n",
"import sklearn\n",
"import sklearn.model_selection\n",
"from tensorflow.keras.models import load_model\n",
"from sklearn.metrics import accuracy_score, precision_score, f1_score\n",
"\n",
"feature_cols = ['year', 'mileage', 'vol_engine']\n",
"\n",
"model = load_model('model.h5')\n",
"test_data = pd.read_csv('test.csv')\n",
"\n",
"predictions = model.predict(test_data[feature_cols])\n",
"predicted_prices = [p[0] for p in predictions]\n",
"\n",
"\n",
"results = pd.DataFrame({'id': test_data['id'], 'year': test_data['year'], 'mileage': test_data['mileage'], 'vol_engine': test_data['vol_engine'], 'predicted_price': predicted_prices})\n",
"results.to_csv('predictions.csv', index=False)\n",
"\n",
"y_true = test_data['price']\n",
"y_pred = y_pred = [round(p[0]) for p in predictions]\n",
"\n",
"accuracy = accuracy_score(y_true, y_pred)\n",
"precision = precision_score(y_true, y_pred, average='micro')\n",
"f1 = f1_score(y_true, y_pred, average='micro')\n",
"\n",
"with open('metrics.txt', 'w') as f:\n",
" f.write(f\"Accuracy: {accuracy:.4f}\\n\")\n",
" f.write(f\"Micro-average Precision: {precision:.4f}\\n\")\n",
" f.write(f\"Micro-average F1-score: {f1:.4f}\\n\")\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bca76252-c90d-4343-8ff8-a665cd32cf26",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
}
},
"nbformat": 4,
"nbformat_minor": 5
}