ium_452662/predict.ipynb

71 lines
1.7 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"id": "47153112-da26-4dbd-a32a-1abdd8bda4fa",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2949/2949 [==============================] - 1s 462us/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",
"\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)"
]
},
{
"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
}