fuzzy-rules-generator/density_fuzzy.ipynb

1113 lines
238 KiB
Plaintext
Raw Permalink Normal View History

2024-11-01 11:04:05 +04:00
{
"cells": [
{
"cell_type": "code",
2024-11-05 10:22:38 +04:00
"execution_count": 58,
2024-11-01 11:04:05 +04:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>T</th>\n",
" <th>Al2O3</th>\n",
" <th>TiO2</th>\n",
" <th>Density</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>20</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.06250</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>25</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.05979</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>35</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.05404</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" T Al2O3 TiO2 Density\n",
"0 20 0.0 0.0 1.06250\n",
"1 25 0.0 0.0 1.05979\n",
"2 35 0.0 0.0 1.05404"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>T</th>\n",
" <th>Al2O3</th>\n",
" <th>TiO2</th>\n",
" <th>Density</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>30</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.05696</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>55</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.04158</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>25</td>\n",
" <td>0.05</td>\n",
" <td>0.0</td>\n",
" <td>1.08438</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" T Al2O3 TiO2 Density\n",
"0 30 0.00 0.0 1.05696\n",
"1 55 0.00 0.0 1.04158\n",
"2 25 0.05 0.0 1.08438"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import pandas as pd\n",
"\n",
"density_train = pd.read_csv(\"data/density_train.csv\", sep=\";\", decimal=\",\")\n",
"density_test = pd.read_csv(\"data/density_test.csv\", sep=\";\", decimal=\",\")\n",
"\n",
"display(density_train.head(3))\n",
"display(density_test.head(3))"
]
},
{
"cell_type": "code",
2024-11-05 10:22:38 +04:00
"execution_count": 59,
2024-11-01 11:04:05 +04:00
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Users\\user\\Projects\\python\\fuzzy\\.venv\\Lib\\site-packages\\skfuzzy\\control\\fuzzyvariable.py:125: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown\n",
" fig.show()\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAkAAAAGyCAYAAAAMKHu5AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYX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TMYYPUQMOih4+y87/r6u8KV4NXRsGcuXI1Um0UIM2cwGAjdG4reoCekQYhJdH39hxRAOfRR49LULOHB8CVRJKXKBGpC5NiJZXB6JXSYBfkLq06jadAffOtqy3CkyoLIQuTUusvr2HR1E8H1g/Fy9lId5wlSAOWQrY2OGd0DuJ2QzJR1Z1THEcI8JdyCNcOg6utQpavqNP9lY6utFfYwBjaNVZ1GCLMUmxRL2L4w2vq1pbVfa9VxniIF0Eso5ZWPkW0r8XPkVSIu3FUdRwjzYjDAqkHaEPR2M1SneVrBMtByAhxYBJe2q04jhFkxGAyMjxyPg60Do+qNUh3nmaQAeknv1i9Jg9IF+XzpMRKS01THEcJ8HPkFzm+Ajl+Ci6fqNM9W5yNtOY4V/bXlOYQQWRJ+IZyd13cytsFYCjgVUB3nmaQAekk2NjqmdfMn/nEaoatPqY4jhHmIi4b1I6F6T6jQVnWa57Oxgc7z4HEcbDDNT7FCmJqbj24y9cBUOpfpTDPfZqrjPJcUQEbg6+lCcPtKLD54na1nbquOI4Rp0+u1FhUnd2gzWXWaf+ZRElqHwZF/w7kNqtMIYdL0Bj0he0JwdXAlqG6Q6jgvJAWQkbxRx5dmFQoRtOw4cUmylpAQz3XwO7i8Azp/pRVB5qBmLyjbElYOhCSZ+kKI51l8djH7bu1jfMPxuDq4qo7zQlIAGYlOp2Pq6/6kpGUwduVJ1XGEME33LsK
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
2024-11-05 10:22:38 +04:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjcAAAGyCAYAAAAYveVYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACGwklEQVR4nOzdd1gU59rH8e/SQQVBFCwo9g52VKyxxm5iOcZE06MxxhorggW7JibRaDTJMd2oiVh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BwOSIyTjYOjAhYEKBb1+Kmzwa0MSXJhWKMWb1cRJT0lXHEcJ8HP0Bzv8BXT8FFw/VaZ6u4TtaC4i1H0BKguo0QpiNsAth7L62m5AmIRR1Klrg25fiJo9sbHTM6eVHfHIaoRtOq44jhHmIj4HN46FOf6j6ouo0z2Zjo7WASImHPwr+26cQ5ujmw5vMPjSb7hW708qnlZIMUtwYgY+HC5O61GDlX9f480yc6jhCmDa9XjsT4uQGHWeqTvPP3MtBhxnamaazm1WnEcKk6Q16gvcFU8ShCGMbjVWWQ4obI+nb0IdWVYsz9tcTxCdLbxohnumvryF6F3T/XCtwzEG9AVCpHaz/EJJl+gchnmXl2ZXsv7mfKU2nUMShiLIcUtwYiU6nY9ZLfqSmZxKy7pTqOEKYprsXYWswNHgTKr6gOk326XTQ7TPISIFNH6lOI4RJupp4lY8Pf0yfKn1oWqqp0ixS3BiRt5sTU7rXZO2xG/x+4qbqOEKYFn0mrB0ChYpDu2mq0+Scayl4cS6cXA2n16pOI4RJydRnEhQehIeTB6MajFIdR4obY+tRpzT
2024-11-01 11:04:05 +04:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
2024-11-05 10:22:38 +04:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjcAAAGyCAYAAAAYveVYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACGqklEQVR4nOzdd1gU59rH8e/SQQFBFCwo9g52VKyxxm5iOcZETdcYY40VwYJdE2s0MckxPZZErDGWWBFLLNiwo9jACqhI3/ePeQ/nGBtl4dlyf86114nL7MxvR2a9d56Z59bp9Xo9QgghhBBmwkp1ACGEEEIIQ5LiRgghhBBmRYobIYQQQpgVKW6EEEIIYVakuBFCCCGEWZHiRgghhBBmRYobIYQQQpgVKW6EEE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4xBRCNpxWHUcI0xAXDZvHQs0+UOlV1Wmez8pKawGRFAd/5v+3TyFM0c2HN5l5aCZdynWhuXdzJRmkuDEAb3cnJnSsysq/r/HXmVjVcYQwbhkZ2pkQB1doN111mpdzKw1tp2lnms5uVp1GCKOWoc8gaF8QznbOjK4/WlkOKW4MpFc9b5pXKsLo304Qlyi9aYR4rr+/gahd0GWhVuCYgtp9oXxrWP8JJMr0D0I8z8qzK9l/cz+TGk3C2c5ZWQ4pbgxEp9Mx4zVfklPTCV53SnUcIYzT3YuwNQjqvgPlXlGdJut0Oui8ANKSYNOnqtMIYZSuJlzls8Of0bNiTxoVb6Q0ixQ3BuTl6sCkLtVYe+wGf5y4qTqOEMYlIx3WDoICRaD1FNVpss+lOLw6G06uhtNrVacRwqikZ6QTGBaIu4M7I+qOUB1HihtD61qzBG2qejI
2024-11-01 11:04:05 +04:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
2024-11-05 10:22:38 +04:00
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjcAAAGyCAYAAAAYveVYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAADDlklEQVR4nOzdeVhb95X4/7c2xCax72Yz4AVsvNvxjleEjbP42y1Jm6ZL8munmSZNO0k6aZNuSdqZdtLOdEvSdNJ2ki7TsZ3EMQJv2LHjeME73gAjsDEgdolNCEm/PxRosMFmkXQl8Xk9D8/TiKt7j32LOfqc+zlH5nA4HAiCIAiCIPgJudQBCIIgCIIguJJIbgRBEARB8CsiuREEQRAEwa+I5EYQBEEQBL8ikhtBEARBEPyKSG4EQRAEQfArIrkRBEEQBMGviORGEARBEAS/IpIbQRAEQRD8yqRLbhwOByaTCdGYWRAEQRD8k6TJzcGDB9myZQuJiYnIZDJ27Nhxx/eU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X67g5LyBqlDEcaifBtMy4eA0S1ZD8q+F+z9zmGags/QG/SsTFpJiGps93tj2kZsdhv7asVsMV9i2lWEJi8PeVDQmN6nyc/HYbVi3ifuty+pPGEkfXYUqgDFhM4jkpuPidMGsigtkp1nRUM/n9FcCQ3nxlaSGqBNgNRlojTlQ66ZrlHeUk5++uhLUgNig2OZHzef4hpRmvIVlqoqLFeu3LZx30hU8fEELVggSlM+pK2hi5a6TjInsEtqgEhubrIlN4HDlc20dfVJHYowGuXbISAUsjaO7/0598HVUuhudWlYgnsU1xQTpAxiVdLYShQDdGk
2024-11-01 11:04:05 +04:00
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import numpy as np\n",
"from skfuzzy import control as ctrl\n",
"import skfuzzy as fuzz\n",
"\n",
"temp = ctrl.Antecedent(density_train[\"T\"].sort_values().unique(), \"temp\")\n",
2024-11-05 10:22:38 +04:00
"al = ctrl.Antecedent(np.arange(0, 0.3, 0.005), \"al\")\n",
"ti = ctrl.Antecedent(np.arange(0, 0.3, 0.005), \"ti\")\n",
"density = ctrl.Consequent(np.arange(1.03, 1.22, 0.00001), \"density\")\n",
2024-11-01 11:04:05 +04:00
"\n",
"temp.automf(3, variable_type=\"quant\")\n",
"temp.view()\n",
"al.automf(3, variable_type=\"quant\")\n",
"al.view()\n",
"ti.automf(3, variable_type=\"quant\")\n",
"ti.view()\n",
2024-11-05 10:22:38 +04:00
"density.automf(5, variable_type=\"quant\")\n",
2024-11-01 11:04:05 +04:00
"density.view()"
]
},
{
"cell_type": "code",
2024-11-05 10:22:38 +04:00
"execution_count": 60,
2024-11-01 11:04:05 +04:00
"metadata": {},
"outputs": [],
"source": [
"rule11 = ctrl.Rule(\n",
" temp[\"low\"] & al[\"low\"] & ti[\"low\"],\n",
" density[\"low\"],\n",
")\n",
"rule12 = ctrl.Rule(\n",
" temp[\"average\"] & al[\"low\"] & ti[\"low\"],\n",
2024-11-05 10:22:38 +04:00
" density[\"lower\"],\n",
2024-11-01 11:04:05 +04:00
")\n",
"rule13 = ctrl.Rule(\n",
" temp[\"high\"] & al[\"low\"] & ti[\"low\"],\n",
2024-11-05 10:22:38 +04:00
" density[\"lower\"],\n",
2024-11-01 11:04:05 +04:00
")\n",
"\n",
"rule21 = ctrl.Rule(\n",
" temp[\"low\"] & al[\"average\"] & ti[\"low\"],\n",
2024-11-05 10:22:38 +04:00
" density[\"low\"],\n",
2024-11-01 11:04:05 +04:00
")\n",
"rule22 = ctrl.Rule(\n",
" temp[\"average\"] & al[\"average\"] & ti[\"low\"],\n",
" density[\"low\"],\n",
")\n",
"rule23 = ctrl.Rule(\n",
" temp[\"high\"] & al[\"average\"] & ti[\"low\"],\n",
2024-11-05 10:22:38 +04:00
" density[\"lower\"],\n",
2024-11-01 11:04:05 +04:00
")\n",
"\n",
"rule31 = ctrl.Rule(\n",
" temp[\"low\"] & al[\"high\"] & ti[\"low\"],\n",
" density[\"high\"],\n",
")\n",
"rule32 = ctrl.Rule(\n",
" temp[\"low\"] & al[\"high\"] & ti[\"low\"],\n",
" density[\"high\"],\n",
")\n",
"rule33 = ctrl.Rule(\n",
" temp[\"high\"] & al[\"high\"] & ti[\"low\"],\n",
" density[\"average\"],\n",
")\n",
"\n",
"rule41 = ctrl.Rule(\n",
" temp[\"low\"] & al[\"low\"] & ti[\"average\"],\n",
2024-11-05 10:22:38 +04:00
" density[\"low\"],\n",
2024-11-01 11:04:05 +04:00
")\n",
"rule42 = ctrl.Rule(\n",
" temp[\"average\"] & al[\"low\"] & ti[\"average\"],\n",
2024-11-05 10:22:38 +04:00
" density[\"low\"],\n",
2024-11-01 11:04:05 +04:00
")\n",
"rule43 = ctrl.Rule(\n",
" temp[\"high\"] & al[\"low\"] & ti[\"average\"],\n",
2024-11-05 10:22:38 +04:00
" density[\"lower\"],\n",
2024-11-01 11:04:05 +04:00
")\n",
"\n",
"rule51 = ctrl.Rule(\n",
" temp[\"low\"] & al[\"low\"] & ti[\"high\"],\n",
2024-11-05 10:22:38 +04:00
" density[\"higher\"],\n",
2024-11-01 11:04:05 +04:00
")\n",
"rule52 = ctrl.Rule(\n",
" temp[\"average\"] & al[\"low\"] & ti[\"high\"],\n",
" density[\"high\"],\n",
")\n",
"rule53 = ctrl.Rule(\n",
" temp[\"high\"] & al[\"low\"] & ti[\"high\"],\n",
2024-11-05 10:22:38 +04:00
" density[\"high\"],\n",
2024-11-01 11:04:05 +04:00
")"
]
},
{
"cell_type": "code",
2024-11-05 10:22:38 +04:00
"execution_count": 61,
2024-11-01 11:04:05 +04:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[IF (temp[low] AND al[low]) AND ti[low] THEN density[low]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
2024-11-05 10:22:38 +04:00
" IF (temp[average] AND al[low]) AND ti[low] THEN density[lower]\n",
2024-11-01 11:04:05 +04:00
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
2024-11-05 10:22:38 +04:00
" IF (temp[high] AND al[low]) AND ti[low] THEN density[lower]\n",
2024-11-01 11:04:05 +04:00
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
2024-11-05 10:22:38 +04:00
" IF (temp[low] AND al[average]) AND ti[low] THEN density[low]\n",
2024-11-01 11:04:05 +04:00
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[average] AND al[average]) AND ti[low] THEN density[low]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
2024-11-05 10:22:38 +04:00
" IF (temp[high] AND al[average]) AND ti[low] THEN density[lower]\n",
2024-11-01 11:04:05 +04:00
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[low] AND al[high]) AND ti[low] THEN density[high]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[low] AND al[high]) AND ti[low] THEN density[high]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[high] AND al[high]) AND ti[low] THEN density[average]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
2024-11-05 10:22:38 +04:00
" IF (temp[low] AND al[low]) AND ti[average] THEN density[low]\n",
2024-11-01 11:04:05 +04:00
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
2024-11-05 10:22:38 +04:00
" IF (temp[average] AND al[low]) AND ti[average] THEN density[low]\n",
2024-11-01 11:04:05 +04:00
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
2024-11-05 10:22:38 +04:00
" IF (temp[high] AND al[low]) AND ti[average] THEN density[lower]\n",
2024-11-01 11:04:05 +04:00
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
2024-11-05 10:22:38 +04:00
" IF (temp[low] AND al[low]) AND ti[high] THEN density[higher]\n",
2024-11-01 11:04:05 +04:00
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[average] AND al[low]) AND ti[high] THEN density[high]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
2024-11-05 10:22:38 +04:00
" IF (temp[high] AND al[low]) AND ti[high] THEN density[high]\n",
2024-11-01 11:04:05 +04:00
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax]"
]
},
2024-11-05 10:22:38 +04:00
"execution_count": 61,
2024-11-01 11:04:05 +04:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"fuzzy_rules = [\n",
" rule11,\n",
" rule12,\n",
" rule13,\n",
" rule21,\n",
" rule22,\n",
" rule23,\n",
" rule31,\n",
" rule32,\n",
" rule33,\n",
" rule41,\n",
" rule42,\n",
" rule43,\n",
" rule51,\n",
" rule52,\n",
" rule53,\n",
"]\n",
"\n",
"density_cntrl = ctrl.ControlSystem(fuzzy_rules)\n",
"\n",
"sim = ctrl.ControlSystemSimulation(density_cntrl)\n",
"\n",
"fuzzy_rules"
]
},
{
"cell_type": "code",
2024-11-05 10:22:38 +04:00
"execution_count": 62,
2024-11-01 11:04:05 +04:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"=============\n",
" Antecedents \n",
"=============\n",
"Antecedent: temp = 20\n",
" - low : 1.0\n",
" - average : 0.0\n",
" - high : 0.0\n",
2024-11-05 10:22:38 +04:00
"Antecedent: al = 0.295\n",
2024-11-01 11:04:05 +04:00
" - low : 0.0\n",
" - average : 0.0\n",
" - high : 1.0\n",
"Antecedent: ti = 0.0\n",
" - low : 1.0\n",
" - average : 0.0\n",
" - high : 0.0\n",
"\n",
"=======\n",
" Rules \n",
"=======\n",
"RULE #0:\n",
" IF (temp[low] AND al[low]) AND ti[low] THEN density[low]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[low] : 1.0\n",
" - al[low] : 0.0\n",
" - ti[low] : 1.0\n",
" (temp[low] AND al[low]) AND ti[low] = 0.0\n",
" Activation (THEN-clause):\n",
" density[low] : 0.0\n",
"\n",
"RULE #1:\n",
2024-11-05 10:22:38 +04:00
" IF (temp[average] AND al[low]) AND ti[low] THEN density[lower]\n",
2024-11-01 11:04:05 +04:00
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[average] : 0.0\n",
" - al[low] : 0.0\n",
" - ti[low] : 1.0\n",
" (temp[average] AND al[low]) AND ti[low] = 0.0\n",
" Activation (THEN-clause):\n",
2024-11-05 10:22:38 +04:00
" density[lower] : 0.0\n",
2024-11-01 11:04:05 +04:00
"\n",
"RULE #2:\n",
2024-11-05 10:22:38 +04:00
" IF (temp[high] AND al[low]) AND ti[low] THEN density[lower]\n",
2024-11-01 11:04:05 +04:00
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[high] : 0.0\n",
" - al[low] : 0.0\n",
" - ti[low] : 1.0\n",
" (temp[high] AND al[low]) AND ti[low] = 0.0\n",
" Activation (THEN-clause):\n",
2024-11-05 10:22:38 +04:00
" density[lower] : 0.0\n",
2024-11-01 11:04:05 +04:00
"\n",
"RULE #3:\n",
2024-11-05 10:22:38 +04:00
" IF (temp[low] AND al[average]) AND ti[low] THEN density[low]\n",
2024-11-01 11:04:05 +04:00
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[low] : 1.0\n",
" - al[average] : 0.0\n",
" - ti[low] : 1.0\n",
" (temp[low] AND al[average]) AND ti[low] = 0.0\n",
" Activation (THEN-clause):\n",
2024-11-05 10:22:38 +04:00
" density[low] : 0.0\n",
2024-11-01 11:04:05 +04:00
"\n",
"RULE #4:\n",
" IF (temp[average] AND al[average]) AND ti[low] THEN density[low]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[average] : 0.0\n",
" - al[average] : 0.0\n",
" - ti[low] : 1.0\n",
" (temp[average] AND al[average]) AND ti[low] = 0.0\n",
" Activation (THEN-clause):\n",
" density[low] : 0.0\n",
"\n",
"RULE #5:\n",
2024-11-05 10:22:38 +04:00
" IF (temp[high] AND al[average]) AND ti[low] THEN density[lower]\n",
2024-11-01 11:04:05 +04:00
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[high] : 0.0\n",
" - al[average] : 0.0\n",
" - ti[low] : 1.0\n",
" (temp[high] AND al[average]) AND ti[low] = 0.0\n",
" Activation (THEN-clause):\n",
2024-11-05 10:22:38 +04:00
" density[lower] : 0.0\n",
2024-11-01 11:04:05 +04:00
"\n",
"RULE #6:\n",
" IF (temp[low] AND al[high]) AND ti[low] THEN density[high]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[low] : 1.0\n",
" - al[high] : 1.0\n",
" - ti[low] : 1.0\n",
" (temp[low] AND al[high]) AND ti[low] = 1.0\n",
" Activation (THEN-clause):\n",
" density[high] : 1.0\n",
"\n",
"RULE #7:\n",
" IF (temp[low] AND al[high]) AND ti[low] THEN density[high]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[low] : 1.0\n",
" - al[high] : 1.0\n",
" - ti[low] : 1.0\n",
" (temp[low] AND al[high]) AND ti[low] = 1.0\n",
" Activation (THEN-clause):\n",
" density[high] : 1.0\n",
"\n",
"RULE #8:\n",
" IF (temp[high] AND al[high]) AND ti[low] THEN density[average]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[high] : 0.0\n",
" - al[high] : 1.0\n",
" - ti[low] : 1.0\n",
" (temp[high] AND al[high]) AND ti[low] = 0.0\n",
" Activation (THEN-clause):\n",
" density[average] : 0.0\n",
"\n",
"RULE #9:\n",
2024-11-05 10:22:38 +04:00
" IF (temp[low] AND al[low]) AND ti[average] THEN density[low]\n",
2024-11-01 11:04:05 +04:00
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[low] : 1.0\n",
" - al[low] : 0.0\n",
" - ti[average] : 0.0\n",
" (temp[low] AND al[low]) AND ti[average] = 0.0\n",
" Activation (THEN-clause):\n",
2024-11-05 10:22:38 +04:00
" density[low] : 0.0\n",
2024-11-01 11:04:05 +04:00
"\n",
"RULE #10:\n",
2024-11-05 10:22:38 +04:00
" IF (temp[average] AND al[low]) AND ti[average] THEN density[low]\n",
2024-11-01 11:04:05 +04:00
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[average] : 0.0\n",
" - al[low] : 0.0\n",
" - ti[average] : 0.0\n",
" (temp[average] AND al[low]) AND ti[average] = 0.0\n",
" Activation (THEN-clause):\n",
2024-11-05 10:22:38 +04:00
" density[low] : 0.0\n",
2024-11-01 11:04:05 +04:00
"\n",
"RULE #11:\n",
2024-11-05 10:22:38 +04:00
" IF (temp[high] AND al[low]) AND ti[average] THEN density[lower]\n",
2024-11-01 11:04:05 +04:00
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[high] : 0.0\n",
" - al[low] : 0.0\n",
" - ti[average] : 0.0\n",
" (temp[high] AND al[low]) AND ti[average] = 0.0\n",
" Activation (THEN-clause):\n",
2024-11-05 10:22:38 +04:00
" density[lower] : 0.0\n",
2024-11-01 11:04:05 +04:00
"\n",
"RULE #12:\n",
2024-11-05 10:22:38 +04:00
" IF (temp[low] AND al[low]) AND ti[high] THEN density[higher]\n",
2024-11-01 11:04:05 +04:00
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[low] : 1.0\n",
" - al[low] : 0.0\n",
" - ti[high] : 0.0\n",
" (temp[low] AND al[low]) AND ti[high] = 0.0\n",
" Activation (THEN-clause):\n",
2024-11-05 10:22:38 +04:00
" density[higher] : 0.0\n",
2024-11-01 11:04:05 +04:00
"\n",
"RULE #13:\n",
" IF (temp[average] AND al[low]) AND ti[high] THEN density[high]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[average] : 0.0\n",
" - al[low] : 0.0\n",
" - ti[high] : 0.0\n",
" (temp[average] AND al[low]) AND ti[high] = 0.0\n",
" Activation (THEN-clause):\n",
" density[high] : 0.0\n",
"\n",
"RULE #14:\n",
2024-11-05 10:22:38 +04:00
" IF (temp[high] AND al[low]) AND ti[high] THEN density[high]\n",
2024-11-01 11:04:05 +04:00
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[high] : 0.0\n",
" - al[low] : 0.0\n",
" - ti[high] : 0.0\n",
" (temp[high] AND al[low]) AND ti[high] = 0.0\n",
" Activation (THEN-clause):\n",
2024-11-05 10:22:38 +04:00
" density[high] : 0.0\n",
2024-11-01 11:04:05 +04:00
"\n",
"\n",
"==============================\n",
" Intermediaries and Conquests \n",
"==============================\n",
2024-11-05 10:22:38 +04:00
"Consequent: density = 1.1724924997377486\n",
" lower:\n",
" Accumulate using accumulation_max : 0.0\n",
2024-11-01 11:04:05 +04:00
" low:\n",
" Accumulate using accumulation_max : 0.0\n",
" average:\n",
" Accumulate using accumulation_max : 0.0\n",
" high:\n",
" Accumulate using accumulation_max : 1.0\n",
2024-11-05 10:22:38 +04:00
" higher:\n",
" Accumulate using accumulation_max : 0.0\n",
2024-11-01 11:04:05 +04:00
"\n"
]
},
{
"data": {
"text/plain": [
2024-11-05 10:22:38 +04:00
"np.float64(1.1724924997377486)"
2024-11-01 11:04:05 +04:00
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sim.input[\"temp\"] = 20\n",
"sim.input[\"al\"] = 0.3\n",
"sim.input[\"ti\"] = 0.0\n",
"sim.compute()\n",
"sim.print_state()\n",
"display(sim.output[\"density\"])"
]
},
{
"cell_type": "code",
2024-11-05 10:22:38 +04:00
"execution_count": 63,
2024-11-01 11:04:05 +04:00
"metadata": {},
"outputs": [],
"source": [
"def fuzzy_pred(row):\n",
" sim.input[\"temp\"] = row[\"T\"]\n",
" sim.input[\"al\"] = row[\"Al2O3\"]\n",
" sim.input[\"ti\"] = row[\"TiO2\"]\n",
" sim.compute()\n",
" return sim.output[\"density\"]"
]
},
{
"cell_type": "code",
2024-11-05 10:22:38 +04:00
"execution_count": 65,
2024-11-01 11:04:05 +04:00
"metadata": {},
"outputs": [
{
2024-11-05 10:22:38 +04:00
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>T</th>\n",
" <th>Al2O3</th>\n",
" <th>TiO2</th>\n",
" <th>Density</th>\n",
" <th>DensityPred</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>20</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.06250</td>\n",
" <td>1.077498</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>25</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.05979</td>\n",
" <td>1.076593</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>35</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.05404</td>\n",
" <td>1.069156</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>40</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.05103</td>\n",
" <td>1.061106</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>45</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.04794</td>\n",
" <td>1.045833</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>50</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.04477</td>\n",
" <td>1.046360</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>60</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.03826</td>\n",
" <td>1.047642</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>65</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.03484</td>\n",
" <td>1.046360</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>70</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.03182</td>\n",
" <td>1.045833</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>20</td>\n",
" <td>0.05</td>\n",
" <td>0.0</td>\n",
" <td>1.08755</td>\n",
" <td>1.077498</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>45</td>\n",
" <td>0.05</td>\n",
" <td>0.0</td>\n",
" <td>1.07105</td>\n",
" <td>1.067145</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>50</td>\n",
" <td>0.05</td>\n",
" <td>0.0</td>\n",
" <td>1.06760</td>\n",
" <td>1.067145</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>55</td>\n",
" <td>0.05</td>\n",
" <td>0.0</td>\n",
" <td>1.06409</td>\n",
" <td>1.067988</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>65</td>\n",
" <td>0.05</td>\n",
" <td>0.0</td>\n",
" <td>1.05691</td>\n",
" <td>1.062538</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>70</td>\n",
" <td>0.05</td>\n",
" <td>0.0</td>\n",
" <td>1.05291</td>\n",
" <td>1.047191</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" T Al2O3 TiO2 Density DensityPred\n",
"0 20 0.00 0.0 1.06250 1.077498\n",
"1 25 0.00 0.0 1.05979 1.076593\n",
"2 35 0.00 0.0 1.05404 1.069156\n",
"3 40 0.00 0.0 1.05103 1.061106\n",
"4 45 0.00 0.0 1.04794 1.045833\n",
"5 50 0.00 0.0 1.04477 1.046360\n",
"6 60 0.00 0.0 1.03826 1.047642\n",
"7 65 0.00 0.0 1.03484 1.046360\n",
"8 70 0.00 0.0 1.03182 1.045833\n",
"9 20 0.05 0.0 1.08755 1.077498\n",
"10 45 0.05 0.0 1.07105 1.067145\n",
"11 50 0.05 0.0 1.06760 1.067145\n",
"12 55 0.05 0.0 1.06409 1.067988\n",
"13 65 0.05 0.0 1.05691 1.062538\n",
"14 70 0.05 0.0 1.05291 1.047191"
]
},
"execution_count": 65,
"metadata": {},
"output_type": "execute_result"
2024-11-01 11:04:05 +04:00
}
],
"source": [
"result_train = density_train.copy()\n",
"\n",
"result_train[\"DensityPred\"] = result_train.apply(fuzzy_pred, axis=1)\n",
"\n",
"result_train.head(15)"
]
},
{
"cell_type": "code",
2024-11-05 10:22:38 +04:00
"execution_count": 66,
2024-11-01 11:04:05 +04:00
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>T</th>\n",
" <th>Al2O3</th>\n",
" <th>TiO2</th>\n",
" <th>Density</th>\n",
" <th>DensityPred</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>30</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" <td>1.05696</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.073918</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>55</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" <td>1.04158</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.047642</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>25</td>\n",
" <td>0.05</td>\n",
" <td>0.00</td>\n",
" <td>1.08438</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.076518</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>30</td>\n",
" <td>0.05</td>\n",
" <td>0.00</td>\n",
" <td>1.08112</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.073918</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>35</td>\n",
" <td>0.05</td>\n",
" <td>0.00</td>\n",
" <td>1.07781</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.069156</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>40</td>\n",
" <td>0.05</td>\n",
" <td>0.00</td>\n",
" <td>1.07446</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.067145</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>60</td>\n",
" <td>0.05</td>\n",
" <td>0.00</td>\n",
" <td>1.06053</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.067988</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>35</td>\n",
" <td>0.30</td>\n",
" <td>0.00</td>\n",
" <td>1.17459</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.172492</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>65</td>\n",
" <td>0.30</td>\n",
" <td>0.00</td>\n",
" <td>1.14812</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.124995</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>45</td>\n",
" <td>0.00</td>\n",
" <td>0.05</td>\n",
" <td>1.07424</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.067145</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>50</td>\n",
" <td>0.00</td>\n",
" <td>0.05</td>\n",
" <td>1.07075</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.067145</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>55</td>\n",
" <td>0.00</td>\n",
" <td>0.05</td>\n",
" <td>1.06721</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.067988</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>20</td>\n",
" <td>0.00</td>\n",
" <td>0.30</td>\n",
" <td>1.22417</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.204157</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>30</td>\n",
" <td>0.00</td>\n",
" <td>0.30</td>\n",
" <td>1.21310</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.180834</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>40</td>\n",
" <td>0.00</td>\n",
" <td>0.30</td>\n",
" <td>1.20265</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.173397</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>60</td>\n",
" <td>0.00</td>\n",
" <td>0.30</td>\n",
" <td>1.18265</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.172492</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>70</td>\n",
" <td>0.00</td>\n",
" <td>0.30</td>\n",
" <td>1.17261</td>\n",
2024-11-05 10:22:38 +04:00
" <td>1.172492</td>\n",
2024-11-01 11:04:05 +04:00
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" T Al2O3 TiO2 Density DensityPred\n",
2024-11-05 10:22:38 +04:00
"0 30 0.00 0.00 1.05696 1.073918\n",
"1 55 0.00 0.00 1.04158 1.047642\n",
"2 25 0.05 0.00 1.08438 1.076518\n",
"3 30 0.05 0.00 1.08112 1.073918\n",
"4 35 0.05 0.00 1.07781 1.069156\n",
"5 40 0.05 0.00 1.07446 1.067145\n",
"6 60 0.05 0.00 1.06053 1.067988\n",
"7 35 0.30 0.00 1.17459 1.172492\n",
"8 65 0.30 0.00 1.14812 1.124995\n",
"9 45 0.00 0.05 1.07424 1.067145\n",
"10 50 0.00 0.05 1.07075 1.067145\n",
"11 55 0.00 0.05 1.06721 1.067988\n",
"12 20 0.00 0.30 1.22417 1.204157\n",
"13 30 0.00 0.30 1.21310 1.180834\n",
"14 40 0.00 0.30 1.20265 1.173397\n",
"15 60 0.00 0.30 1.18265 1.172492\n",
"16 70 0.00 0.30 1.17261 1.172492"
2024-11-01 11:04:05 +04:00
]
},
2024-11-05 10:22:38 +04:00
"execution_count": 66,
2024-11-01 11:04:05 +04:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"result_test = density_test.copy()\n",
"\n",
"result_test[\"DensityPred\"] = result_test.apply(fuzzy_pred, axis=1)\n",
"\n",
"result_test"
]
},
{
"cell_type": "code",
2024-11-05 10:22:38 +04:00
"execution_count": 67,
2024-11-01 11:04:05 +04:00
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
2024-11-05 10:22:38 +04:00
"{'RMSE_train': 0.0156766544822719,\n",
" 'RMSE_test': 0.014603864614526584,\n",
" 'RMAE_test': 0.1057231829134674,\n",
" 'R2_test': 0.9436578668511394}"
2024-11-01 11:04:05 +04:00
]
},
2024-11-05 10:22:38 +04:00
"execution_count": 67,
2024-11-01 11:04:05 +04:00
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import math\n",
"from sklearn import metrics\n",
"\n",
"\n",
"rmetrics = {}\n",
"rmetrics[\"RMSE_train\"] = math.sqrt(\n",
" metrics.mean_squared_error(result_train[\"Density\"], result_train[\"DensityPred\"])\n",
")\n",
"rmetrics[\"RMSE_test\"] = math.sqrt(\n",
" metrics.mean_squared_error(result_test[\"Density\"], result_test[\"DensityPred\"])\n",
")\n",
"rmetrics[\"RMAE_test\"] = math.sqrt(\n",
" metrics.mean_absolute_error(result_test[\"Density\"], result_test[\"DensityPred\"])\n",
")\n",
"rmetrics[\"R2_test\"] = metrics.r2_score(\n",
" result_test[\"Density\"], result_test[\"DensityPred\"]\n",
")\n",
"\n",
"rmetrics"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"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.12.7"
}
},
"nbformat": 4,
"nbformat_minor": 2
}