fuzzy-rules-generator/viscosity_tree.ipynb

1770 lines
306 KiB
Plaintext
Raw Permalink Normal View History

2024-11-01 11:04:05 +04:00
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"|--- T <= 32.50\n",
"| |--- TiO2 <= 0.18\n",
"| | |--- Al2O3 <= 0.18\n",
"| | | |--- T <= 22.50\n",
"| | | | |--- TiO2 <= 0.03\n",
"| | | | | |--- Al2O3 <= 0.03\n",
"| | | | | | |--- value: [3.71]\n",
"| | | | | |--- Al2O3 > 0.03\n",
"| | | | | | |--- value: [4.66]\n",
"| | | | |--- TiO2 > 0.03\n",
"| | | | | |--- value: [4.88]\n",
"| | | |--- T > 22.50\n",
"| | | | |--- TiO2 <= 0.03\n",
"| | | | | |--- Al2O3 <= 0.03\n",
"| | | | | | |--- value: [3.18]\n",
"| | | | | |--- Al2O3 > 0.03\n",
"| | | | | | |--- value: [3.38]\n",
"| | | | |--- TiO2 > 0.03\n",
"| | | | | |--- value: [4.24]\n",
"| | |--- Al2O3 > 0.18\n",
"| | | |--- T <= 22.50\n",
"| | | | |--- value: [6.67]\n",
"| | | |--- T > 22.50\n",
"| | | | |--- T <= 27.50\n",
"| | | | | |--- value: [5.59]\n",
"| | | | |--- T > 27.50\n",
"| | | | | |--- value: [4.73]\n",
"| |--- TiO2 > 0.18\n",
"| | |--- T <= 22.50\n",
"| | | |--- value: [7.13]\n",
"| | |--- T > 22.50\n",
"| | | |--- T <= 27.50\n",
"| | | | |--- value: [5.87]\n",
"| | | |--- T > 27.50\n",
"| | | | |--- value: [4.94]\n",
"|--- T > 32.50\n",
"| |--- T <= 47.50\n",
"| | |--- TiO2 <= 0.18\n",
"| | | |--- Al2O3 <= 0.18\n",
"| | | | |--- T <= 42.50\n",
"| | | | | |--- TiO2 <= 0.03\n",
"| | | | | | |--- Al2O3 <= 0.03\n",
"| | | | | | | |--- value: [2.36]\n",
"| | | | | | |--- Al2O3 > 0.03\n",
"| | | | | | | |--- value: [2.68]\n",
"| | | | | |--- TiO2 > 0.03\n",
"| | | | | | |--- T <= 37.50\n",
"| | | | | | | |--- value: [3.12]\n",
"| | | | | | |--- T > 37.50\n",
"| | | | | | | |--- value: [2.65]\n",
"| | | | |--- T > 42.50\n",
"| | | | | |--- TiO2 <= 0.03\n",
"| | | | | | |--- value: [1.83]\n",
"| | | | | |--- TiO2 > 0.03\n",
"| | | | | | |--- value: [2.40]\n",
"| | | |--- Al2O3 > 0.18\n",
"| | | | |--- T <= 37.50\n",
"| | | | | |--- value: [4.12]\n",
"| | | | |--- T > 37.50\n",
"| | | | | |--- value: [3.56]\n",
"| | |--- TiO2 > 0.18\n",
"| | | |--- T <= 40.00\n",
"| | | | |--- value: [4.35]\n",
"| | | |--- T > 40.00\n",
"| | | | |--- value: [3.56]\n",
"| |--- T > 47.50\n",
"| | |--- TiO2 <= 0.18\n",
"| | | |--- Al2O3 <= 0.18\n",
"| | | | |--- T <= 52.50\n",
"| | | | | |--- TiO2 <= 0.03\n",
"| | | | | | |--- Al2O3 <= 0.03\n",
"| | | | | | | |--- value: [1.63]\n",
"| | | | | | |--- Al2O3 > 0.03\n",
"| | | | | | | |--- value: [1.90]\n",
"| | | | | |--- TiO2 > 0.03\n",
"| | | | | | |--- value: [2.11]\n",
"| | | | |--- T > 52.50\n",
"| | | | | |--- T <= 65.00\n",
"| | | | | | |--- TiO2 <= 0.03\n",
"| | | | | | | |--- value: [1.55]\n",
"| | | | | | |--- TiO2 > 0.03\n",
"| | | | | | | |--- value: [1.66]\n",
"| | | | | |--- T > 65.00\n",
"| | | | | | |--- TiO2 <= 0.03\n",
"| | | | | | | |--- value: [1.19]\n",
"| | | | | | |--- TiO2 > 0.03\n",
"| | | | | | | |--- value: [1.29]\n",
"| | | |--- Al2O3 > 0.18\n",
"| | | | |--- T <= 65.00\n",
"| | | | | |--- T <= 57.50\n",
"| | | | | | |--- value: [2.43]\n",
"| | | | | |--- T > 57.50\n",
"| | | | | | |--- value: [2.16]\n",
"| | | | |--- T > 65.00\n",
"| | | | | |--- value: [1.73]\n",
"| | |--- TiO2 > 0.18\n",
"| | | |--- T <= 65.00\n",
"| | | | |--- T <= 57.50\n",
"| | | | | |--- value: [2.84]\n",
"| | | | |--- T > 57.50\n",
"| | | | | |--- value: [2.54]\n",
"| | | |--- T > 65.00\n",
"| | | | |--- value: [1.91]\n",
"\n"
]
}
],
"source": [
"import pickle\n",
"import pandas as pd\n",
"from sklearn import tree\n",
"\n",
"model = pickle.load(open(\"data/vtree.model.sav\", \"rb\"))\n",
"features = (\n",
" pd.read_csv(\"data/viscosity_train.csv\", sep=\";\", decimal=\",\")\n",
" .drop([\"Viscosity\"], axis=1)\n",
" .columns.values.tolist()\n",
")\n",
"\n",
"rules = tree.export_text(model, feature_names=features)\n",
"print(rules)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"35"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"[if (T > 32.5) and (T > 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T > 52.5) and (T > 65.0) and (TiO2 <= 0.025) -> 1.194,\n",
" if (T > 32.5) and (T > 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T > 52.5) and (T > 65.0) and (TiO2 > 0.025) -> 1.289,\n",
" if (T > 32.5) and (T > 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T > 52.5) and (T <= 65.0) and (TiO2 <= 0.025) -> 1.548,\n",
" if (T > 32.5) and (T > 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T <= 52.5) and (TiO2 <= 0.025) and (Al2O3 <= 0.025) -> 1.629,\n",
" if (T > 32.5) and (T > 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T > 52.5) and (T <= 65.0) and (TiO2 > 0.025) -> 1.662,\n",
" if (T > 32.5) and (T > 47.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) and (T > 65.0) -> 1.728,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T > 42.5) and (TiO2 <= 0.025) -> 1.832,\n",
" if (T > 32.5) and (T > 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T <= 52.5) and (TiO2 <= 0.025) and (Al2O3 > 0.025) -> 1.897,\n",
" if (T > 32.5) and (T > 47.5) and (TiO2 > 0.175) and (T > 65.0) -> 1.91,\n",
" if (T > 32.5) and (T > 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T <= 52.5) and (TiO2 > 0.025) -> 2.109,\n",
" if (T > 32.5) and (T > 47.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) and (T <= 65.0) and (T > 57.5) -> 2.16,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T <= 42.5) and (TiO2 <= 0.025) and (Al2O3 <= 0.025) -> 2.361,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T > 42.5) and (TiO2 > 0.025) -> 2.402,\n",
" if (T > 32.5) and (T > 47.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) and (T <= 65.0) and (T <= 57.5) -> 2.426,\n",
" if (T > 32.5) and (T > 47.5) and (TiO2 > 0.175) and (T <= 65.0) and (T > 57.5) -> 2.538,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T <= 42.5) and (TiO2 > 0.025) and (T > 37.5) -> 2.655,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T <= 42.5) and (TiO2 <= 0.025) and (Al2O3 > 0.025) -> 2.682,\n",
" if (T > 32.5) and (T > 47.5) and (TiO2 > 0.175) and (T <= 65.0) and (T <= 57.5) -> 2.838,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T <= 42.5) and (TiO2 > 0.025) and (T <= 37.5) -> 3.121,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T > 22.5) and (TiO2 <= 0.025) and (Al2O3 <= 0.025) -> 3.18,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T > 22.5) and (TiO2 <= 0.025) and (Al2O3 > 0.025) -> 3.38,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 > 0.175) and (T > 40.0) -> 3.561,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) and (T > 37.5) -> 3.565,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T <= 22.5) and (TiO2 <= 0.025) and (Al2O3 <= 0.025) -> 3.707,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) and (T <= 37.5) -> 4.118,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T > 22.5) and (TiO2 > 0.025) -> 4.236,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 > 0.175) and (T <= 40.0) -> 4.354,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T <= 22.5) and (TiO2 <= 0.025) and (Al2O3 > 0.025) -> 4.66,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) and (T > 22.5) and (T > 27.5) -> 4.731,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (T <= 22.5) and (TiO2 > 0.025) -> 4.885,\n",
" if (T <= 32.5) and (TiO2 > 0.175) and (T > 22.5) and (T > 27.5) -> 4.944,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) and (T > 22.5) and (T <= 27.5) -> 5.594,\n",
" if (T <= 32.5) and (TiO2 > 0.175) and (T > 22.5) and (T <= 27.5) -> 5.865,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) and (T <= 22.5) -> 6.67,\n",
" if (T <= 32.5) and (TiO2 > 0.175) and (T <= 22.5) -> 7.132]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from src.rules import get_rules\n",
"\n",
"\n",
"rules = get_rules(model, features)\n",
"display(len(rules))\n",
"rules"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"35"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"[if (T > 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 1.194,\n",
" if (T > 32.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 1.289,\n",
" if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 1.548,\n",
" if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 1.629,\n",
" if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 1.662,\n",
" if (T > 32.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 1.728,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 1.832,\n",
" if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (Al2O3 > 0.025) -> 1.897,\n",
" if (T > 32.5) and (TiO2 > 0.175) -> 1.91,\n",
" if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 2.109,\n",
" if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 2.16,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 2.361,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 2.402,\n",
" if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 2.426,\n",
" if (T > 32.5) and (T <= 65.0) and (TiO2 > 0.175) -> 2.538,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 2.655,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (Al2O3 > 0.025) -> 2.682,\n",
" if (T > 32.5) and (T <= 65.0) and (TiO2 > 0.175) -> 2.838,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 3.121,\n",
" if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 3.18,\n",
" if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (Al2O3 > 0.025) -> 3.38,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 > 0.175) -> 3.561,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 3.565,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 3.707,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 4.118,\n",
" if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 4.236,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 > 0.175) -> 4.354,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (Al2O3 > 0.025) -> 4.66,\n",
" if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 4.731,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 4.885,\n",
" if (T <= 32.5) and (T > 22.5) and (TiO2 > 0.175) -> 4.944,\n",
" if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 5.594,\n",
" if (T <= 32.5) and (T > 22.5) and (TiO2 > 0.175) -> 5.865,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 6.67,\n",
" if (T <= 32.5) and (TiO2 > 0.175) -> 7.132]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from src.rules import normalise_rules\n",
"\n",
"\n",
"rules = normalise_rules(rules)\n",
"display(len(rules))\n",
"rules"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"26"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"[if (T > 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 1.194,\n",
" if (T > 32.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 1.289,\n",
" if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 1.548,\n",
" if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 1.629,\n",
" if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 1.662,\n",
" if (T > 32.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 1.728,\n",
" if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (Al2O3 > 0.025) -> 1.897,\n",
" if (T > 32.5) and (TiO2 > 0.175) -> 1.91,\n",
" if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 2.109,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 2.097,\n",
" if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 2.293,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (Al2O3 > 0.025) -> 2.682,\n",
" if (T > 32.5) and (T <= 65.0) and (TiO2 > 0.175) -> 2.688,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 2.726,\n",
" if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 3.18,\n",
" if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (Al2O3 > 0.025) -> 3.38,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 3.707,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 3.842,\n",
" if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 4.236,\n",
" if (T > 32.5) and (T <= 47.5) and (TiO2 > 0.175) -> 3.958,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (Al2O3 > 0.025) -> 4.66,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 4.885,\n",
" if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 5.162,\n",
" if (T <= 32.5) and (T > 22.5) and (TiO2 > 0.175) -> 5.405,\n",
" if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 6.67,\n",
" if (T <= 32.5) and (TiO2 > 0.175) -> 7.132]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from src.rules import delete_same_rules\n",
"\n",
"\n",
"rules = delete_same_rules(rules)\n",
"display(len(rules))\n",
"rules"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['(Al2O3 <= 0.175)', '(Al2O3 > 0.025)', '(Al2O3 > 0.175)', '(TiO2 <= 0.175)', '(TiO2 > 0.025)', '(TiO2 > 0.175)']\n"
]
},
{
"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>(Al2O3 &lt;= 0.175)</th>\n",
" <th>(Al2O3 &gt; 0.025)</th>\n",
" <th>(Al2O3 &gt; 0.175)</th>\n",
" <th>(TiO2 &lt;= 0.175)</th>\n",
" <th>(TiO2 &gt; 0.025)</th>\n",
" <th>(TiO2 &gt; 0.175)</th>\n",
" <th>consequent</th>\n",
" </tr>\n",
" <tr>\n",
" <th>rule</th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>if (T &gt; 32.5) and (TiO2 &lt;= 0.175) and (Al2O3 &lt;= 0.175) -&gt; 1.194</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1.194</td>\n",
" </tr>\n",
" <tr>\n",
" <th>if (T &gt; 32.5) and (TiO2 &lt;= 0.175) and (TiO2 &gt; 0.025) and (Al2O3 &lt;= 0.175) -&gt; 1.289</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1.289</td>\n",
" </tr>\n",
" <tr>\n",
" <th>if (T &gt; 32.5) and (T &lt;= 65.0) and (TiO2 &lt;= 0.175) and (Al2O3 &lt;= 0.175) -&gt; 1.548</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1.548</td>\n",
" </tr>\n",
" <tr>\n",
" <th>if (T &gt; 32.5) and (T &lt;= 52.5) and (TiO2 &lt;= 0.175) and (Al2O3 &lt;= 0.175) -&gt; 1.629</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1.629</td>\n",
" </tr>\n",
" <tr>\n",
" <th>if (T &gt; 32.5) and (T &lt;= 65.0) and (TiO2 &lt;= 0.175) and (TiO2 &gt; 0.025) and (Al2O3 &lt;= 0.175) -&gt; 1.662</th>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>0</td>\n",
" <td>1</td>\n",
" <td>1</td>\n",
" <td>0</td>\n",
" <td>1.662</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" (Al2O3 <= 0.175) \\\n",
"rule \n",
"if (T > 32.5) and (TiO2 <= 0.175) and (Al2O3 <=... 1 \n",
"if (T > 32.5) and (TiO2 <= 0.175) and (TiO2 > 0... 1 \n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.17... 1 \n",
"if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.17... 1 \n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.17... 1 \n",
"\n",
" (Al2O3 > 0.025) \\\n",
"rule \n",
"if (T > 32.5) and (TiO2 <= 0.175) and (Al2O3 <=... 0 \n",
"if (T > 32.5) and (TiO2 <= 0.175) and (TiO2 > 0... 0 \n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.17... 0 \n",
"if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.17... 0 \n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.17... 0 \n",
"\n",
" (Al2O3 > 0.175) \\\n",
"rule \n",
"if (T > 32.5) and (TiO2 <= 0.175) and (Al2O3 <=... 0 \n",
"if (T > 32.5) and (TiO2 <= 0.175) and (TiO2 > 0... 0 \n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.17... 0 \n",
"if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.17... 0 \n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.17... 0 \n",
"\n",
" (TiO2 <= 0.175) \\\n",
"rule \n",
"if (T > 32.5) and (TiO2 <= 0.175) and (Al2O3 <=... 1 \n",
"if (T > 32.5) and (TiO2 <= 0.175) and (TiO2 > 0... 1 \n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.17... 1 \n",
"if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.17... 1 \n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.17... 1 \n",
"\n",
" (TiO2 > 0.025) \\\n",
"rule \n",
"if (T > 32.5) and (TiO2 <= 0.175) and (Al2O3 <=... 0 \n",
"if (T > 32.5) and (TiO2 <= 0.175) and (TiO2 > 0... 1 \n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.17... 0 \n",
"if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.17... 0 \n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.17... 1 \n",
"\n",
" (TiO2 > 0.175) consequent \n",
"rule \n",
"if (T > 32.5) and (TiO2 <= 0.175) and (Al2O3 <=... 0 1.194 \n",
"if (T > 32.5) and (TiO2 <= 0.175) and (TiO2 > 0... 0 1.289 \n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.17... 0 1.548 \n",
"if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.17... 0 1.629 \n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.17... 0 1.662 "
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from src.rules import get_features, vectorize_rules\n",
"\n",
"features = get_features(rules, [\"T\"])\n",
"print(features)\n",
"\n",
"df_rules = vectorize_rules(rules, features)\n",
"df_rules.head(5)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"c:\\Users\\user\\Projects\\python\\fuzzy\\.venv\\Lib\\site-packages\\sklearn\\base.py:1473: ConvergenceWarning: Number of distinct clusters (5) found smaller than n_clusters (6). Possibly due to duplicate points in X.\n",
" return fit_method(estimator, *args, **kwargs)\n",
"c:\\Users\\user\\Projects\\python\\fuzzy\\.venv\\Lib\\site-packages\\sklearn\\base.py:1473: ConvergenceWarning: Number of distinct clusters (5) found smaller than n_clusters (7). Possibly due to duplicate points in X.\n",
" return fit_method(estimator, *args, **kwargs)\n",
"c:\\Users\\user\\Projects\\python\\fuzzy\\.venv\\Lib\\site-packages\\sklearn\\base.py:1473: ConvergenceWarning: Number of distinct clusters (5) found smaller than n_clusters (8). Possibly due to duplicate points in X.\n",
" return fit_method(estimator, *args, **kwargs)\n",
"c:\\Users\\user\\Projects\\python\\fuzzy\\.venv\\Lib\\site-packages\\sklearn\\base.py:1473: ConvergenceWarning: Number of distinct clusters (5) found smaller than n_clusters (9). Possibly due to duplicate points in X.\n",
" return fit_method(estimator, *args, **kwargs)\n",
"c:\\Users\\user\\Projects\\python\\fuzzy\\.venv\\Lib\\site-packages\\sklearn\\base.py:1473: ConvergenceWarning: Number of distinct clusters (5) found smaller than n_clusters (10). Possibly due to duplicate points in X.\n",
" return fit_method(estimator, *args, **kwargs)\n"
]
},
{
"data": {
"text/plain": [
"{2: 0.42601604060235754,\n",
" 3: 0.7018993361356377,\n",
" 4: 0.8249121250065079,\n",
" 5: 1.0,\n",
" 6: 1.0,\n",
" 7: 1.0,\n",
" 8: 1.0,\n",
" 9: 1.0,\n",
" 10: 1.0}"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXkAAAGFCAYAAAAYU4NfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAA//ElEQVR4nO3deXhMZ/8G8HuyTYIsiCwIIZZYE0JiqTdUSFG1tKUvtaSltbWIVsWu2qZepbSW2GnRplRbVeWnsZTaWktLRcQeSxJBJiSVyMzz++N0hpHFTDIzZzK5P9c1lzNnnjPnO0PuHM95znMUQggBIiKySXZyF0BERObDkCcismEMeSIiG8aQJyKyYQx5IiIbxpAnIrJhDHkiIhvGkCcismEMeSIiG8aQJ4Ps3bsXCoUCmzdvlrsUnaFDh8Lf319vnUKhwMyZM3XPZ86cCYVCgYyMDMsWR2QlGPLlmEKhMOixd+9ei9Z169YtjB07FoGBgXBxcYGXlxdCQ0Px3nvv4f79+xatxRJycnIwc+bMQr/n7du36/3SIjKWg9wFkHy+/PJLvedffPEFdu3aVWB9o0aNkJiYaJGa7ty5g1atWiErKwuvvfYaAgMDcfv2bfz1119YunQpRo4ciUqVKgEAVqxYAY1GY5G6zCknJwezZs0CAHTs2FHvte3bt2Px4sUMeioxhnw59uqrr+o9P3z4MHbt2lVgPQCLhfyqVatw9epV/Pbbb2jXrp3ea1lZWXByctI9d3R0tEhNZB7Z2dmoWLGi3GXYPHbXkFE0Gg0+/PBD1KxZE87OzujcuTPOnz9foN2RI0fw3HPPwd3dHRUqVEB4eDh+++23p77/hQsXYG9vjzZt2hR4zc3NDc7OzrrnhfXJFyUzMx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q9OvXWrVvFbn/kyBFkZ2cXWH/06FHcvn270K4BU+jevTsAYMGCBXrr58+fD0DqZ9YKCAgo0J++fPnyAkfy/fr1w6FDh7Bz584C+8vMzER+fj4A6EaZPPmLA4BuHPmTr/Xr1w9qtRqzZ88usE1+fn6h76WVk5ODBw8e6K0LCAiAq6urbrho165d4erqitjY2AJttf/7adWqFby8vBAXF6c3zPTnn39GYmKi3ndWlNJ8DjIMj+TJpOzs7LBy5Up069YNTZo0QVRUFGrUqIHr169jz549cHNzw48//ljk9l9++SU2bNiAPn36ICQkBE5OTkhMTMTq1avh7OyMyZMnm6XuoKAgDBkyBMuXL0dmZibCw8Nx9OhRrFu3Dr1790anTp10bYcNG4YRI0bgxRdfRJcuXfDnn39i586d8PT01HvPd999F1u3bsXzzz+PoUOHIiQkBNnZ2Th16hQ2b96My5cvw9PTEy4uLmjcuDHi4+PRoEEDVKlSBU2bNkXTpk0REhICAHj77bcRGRkJe3t7vPLKKwgPD8ebb76J2NhYnDx5El27doWjoyOSk5OxadMmLFy4EC+99FKhn/XcuXPo3Lkz+vXrh8aNG8PBwQHfffcd0tLS8MorrwCQ/if26aefYtiwYWjdujUGDBiAypUr488//0ROTg7WrVsHR0dHzJkzB1FRUQgPD8d///tf3RBKf39/jB8//qnfe2k+BxlI3sE9ZE0MGUK5adMmvfWXLl0SAMSaNWv01p84cUL07dtXVK1aVSiVSlG7dm3Rr18/kZCQUGwNf/31l3j33XdFy5YtRZUqVYSDg4Pw9fUVL7/8sjh+/LheW2OGUN66dUuv3Zo1awQAcenSJd26hw8filmzZok6deoIR0dH4efnJ2JiYsSDBw/0tlWr1eK9994Tnp6eokKFCiIyMlKcP3++wBBKIYS4d++eiImJEfXq1RNOTk7C09NTtGvXTnzyySciLy9P1+7gwYM
"text/plain": [
"<Figure size 400x400 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"'The best clusters count is 5'"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from src.cluster_helper import draw_best_clusters_plot, get_best_clusters_num\n",
"\n",
"random_state = 9\n",
"\n",
"X = df_rules.copy()\n",
"X = X.drop([\"consequent\"], axis=1)\n",
"\n",
"clusters_score = get_best_clusters_num(X, random_state)\n",
"display(clusters_score)\n",
"\n",
"draw_best_clusters_plot(clusters_score)\n",
"\n",
"clusters_num = sorted(clusters_score.items(), key=lambda x: x[1], reverse=True)[0][0]\n",
"display(f\"The best clusters count is {clusters_num}\")"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Кластер 1 (6):\n",
"if (T > 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 1.194;\n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 1.548;\n",
"if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 1.629;\n",
"if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 2.097;\n",
"if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 3.18;\n",
"if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) -> 3.707\n",
"--------\n",
"Кластер 2 (5):\n",
"if (T > 32.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 1.728;\n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 2.293;\n",
"if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 3.842;\n",
"if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 5.162;\n",
"if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 > 0.175) -> 6.67\n",
"--------\n",
"Кластер 3 (5):\n",
"if (T > 32.5) and (TiO2 > 0.175) -> 1.91;\n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 > 0.175) -> 2.688;\n",
"if (T > 32.5) and (T <= 47.5) and (TiO2 > 0.175) -> 3.958;\n",
"if (T <= 32.5) and (T > 22.5) and (TiO2 > 0.175) -> 5.405;\n",
"if (T <= 32.5) and (TiO2 > 0.175) -> 7.132\n",
"--------\n",
"Кластер 4 (6):\n",
"if (T > 32.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 1.289;\n",
"if (T > 32.5) and (T <= 65.0) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 1.662;\n",
"if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 2.109;\n",
"if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 2.726;\n",
"if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 4.236;\n",
"if (T <= 32.5) and (TiO2 <= 0.175) and (TiO2 > 0.025) and (Al2O3 <= 0.175) -> 4.885\n",
"--------\n",
"Кластер 5 (4):\n",
"if (T > 32.5) and (T <= 52.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (Al2O3 > 0.025) -> 1.897;\n",
"if (T > 32.5) and (T <= 47.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (Al2O3 > 0.025) -> 2.682;\n",
"if (T <= 32.5) and (T > 22.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (Al2O3 > 0.025) -> 3.38;\n",
"if (T <= 32.5) and (TiO2 <= 0.175) and (Al2O3 <= 0.175) and (Al2O3 > 0.025) -> 4.66\n",
"--------\n"
]
}
],
"source": [
"from sklearn import cluster\n",
"\n",
"from src.cluster_helper import print_cluster_result\n",
"\n",
"kmeans = cluster.KMeans(n_clusters=clusters_num, random_state=random_state)\n",
"kmeans.fit(X)\n",
"\n",
"print_cluster_result(X, clusters_num, kmeans.labels_)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"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>Viscosity</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>3.707</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>3.180</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>2.361</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" T Al2O3 TiO2 Viscosity\n",
"0 20 0.0 0.0 3.707\n",
"1 25 0.0 0.0 3.180\n",
"2 35 0.0 0.0 2.361"
]
},
"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>Viscosity</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>30</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>2.716</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>40</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>2.073</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>60</td>\n",
" <td>0.0</td>\n",
" <td>0.0</td>\n",
" <td>1.329</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" T Al2O3 TiO2 Viscosity\n",
"0 30 0.0 0.0 2.716\n",
"1 40 0.0 0.0 2.073\n",
"2 60 0.0 0.0 1.329"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"viscosity_train = pd.read_csv(\"data/viscosity_train.csv\", sep=\";\", decimal=\",\")\n",
"viscosity_test = pd.read_csv(\"data/viscosity_test.csv\", sep=\";\", decimal=\",\")\n",
"\n",
"display(viscosity_train.head(3))\n",
"display(viscosity_test.head(3))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[[if (T = 70) and (TiO2 = 0.0) and (Al2O3 = 0.0) -> 1.194,\n",
" if (T = 48.75) and (TiO2 = 0.0) and (Al2O3 = 0.0) -> 1.548,\n",
" if (T = 42.5) and (TiO2 = 0.0) and (Al2O3 = 0.0) -> 1.629,\n",
" if (T = 40.0) and (TiO2 = 0.0) and (Al2O3 = 0.0) -> 2.097,\n",
" if (T = 27.5) and (TiO2 = 0.0) and (Al2O3 = 0.0) -> 3.18,\n",
" if (T = 20) and (TiO2 = 0.0) and (Al2O3 = 0.0) -> 3.707],\n",
" [if (T = 70) and (TiO2 = 0.0) and (Al2O3 = 0.3) -> 1.728,\n",
" if (T = 48.75) and (TiO2 = 0.0) and (Al2O3 = 0.3) -> 2.293,\n",
" if (T = 40.0) and (TiO2 = 0.0) and (Al2O3 = 0.3) -> 3.842,\n",
" if (T = 27.5) and (TiO2 = 0.0) and (Al2O3 = 0.3) -> 5.162,\n",
" if (T = 20) and (TiO2 = 0.0) and (Al2O3 = 0.3) -> 6.67],\n",
" [if (T = 70) and (TiO2 = 0.3) -> 1.91,\n",
" if (T = 48.75) and (TiO2 = 0.3) -> 2.688,\n",
" if (T = 40.0) and (TiO2 = 0.3) -> 3.958,\n",
" if (T = 27.5) and (TiO2 = 0.3) -> 5.405,\n",
" if (T = 20) and (TiO2 = 0.3) -> 7.132],\n",
" [if (T = 70) and (TiO2 = 0.1) and (Al2O3 = 0.0) -> 1.289,\n",
" if (T = 48.75) and (TiO2 = 0.1) and (Al2O3 = 0.0) -> 1.662,\n",
" if (T = 42.5) and (TiO2 = 0.1) and (Al2O3 = 0.0) -> 2.109,\n",
" if (T = 40.0) and (TiO2 = 0.1) and (Al2O3 = 0.0) -> 2.726,\n",
" if (T = 27.5) and (TiO2 = 0.1) and (Al2O3 = 0.0) -> 4.236,\n",
" if (T = 20) and (TiO2 = 0.1) and (Al2O3 = 0.0) -> 4.885],\n",
" [if (T = 42.5) and (TiO2 = 0.0) and (Al2O3 = 0.1) -> 1.897,\n",
" if (T = 40.0) and (TiO2 = 0.0) and (Al2O3 = 0.1) -> 2.682,\n",
" if (T = 27.5) and (TiO2 = 0.0) and (Al2O3 = 0.1) -> 3.38,\n",
" if (T = 20) and (TiO2 = 0.0) and (Al2O3 = 0.1) -> 4.66]]"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from src.rules import simplify_and_group_rules\n",
"\n",
"clustered_rules = simplify_and_group_rules(\n",
" viscosity_train, rules, clusters_num, kmeans.labels_\n",
")\n",
"clustered_rules"
]
},
{
"cell_type": "code",
"execution_count": 10,
"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": "iVBORw0KGgoAAAANSUhEUgAAAkAAAAGyCAYAAAAMKHu5AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAC2L0lEQVR4nOzdeXxU9b3/8ddsmckyk30ne9gSElZBdpAlCQQX7rWttdXaam8Xb7Vef1qvVttatfd2vbfLtVqr7a1tbXuBKpBJAAnIIpAgWwiQCVkgJJnsM9kmk5n5/RFDDQTIMjNnlu/z8cijZZZz3uE45JPv53y/X5nD4XAgCIIgCILgR+RSBxAEQRAEQXA3UQAJgiAIguB3RAEkCIIgCILfEQWQIAiCIAh+RxRAgiAIgiD4HVEACYIgCILgd0QBJAiCIAiC3xEFkCAIgiAIfkcUQIIgCIIg+B2/K4AcDgcmkwmxALYgCIIg+C9JC6D9+/ezadMmEhISkMlkbNu27ZbvKS0tZd68eajVajIzM3nrrbfGdU6z2UxoaChms3lioQVBEARB8HqSFkA9PT3Mnj2bX/7yl2N6fU1NDRs3bmT16tWcOHGCxx9/nIcffpji4mIXJxUEQRAEwZfIPGUzVJlMxtatW7n77rtv+Jqnn36aHTt2cObMmauPfeYzn6GzsxO9Xj+m85hMJkJDQ+nq6kKn0002tiAIgiAIbmC32ZErnDdu41X3AB0+fJi1a9eOeCwvL4/Dhw/f8D0WiwWTyTTiC8Bm94i6TxAEJzrQcIAvFn8Rm90mdRRBEJys6lizU4/nVQVQU1MTsbGxIx6LjY3FZDLR19c36nteeeUVQkNDr34lJSUBUF7b4fK8giC415/O/YljTccoby6XOoogCE5mKDc69XheVQBNxDPPPENXV9fVr0uXLgGgr2iUOJkgCM7UZeni0JVDABTXivsCBcGX9PdYqT/b7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j+KTBAMe6RGCl0WjqZmTGTwcFBjhw5crWIaWtr4/z582RlZQFDCyIuX76ccx+co/ZCLQsXLyRMG4bFYuHXv/41CxYsuFrQzJs3j6amJpRKJampqVJ9a4Lg9wzlRpQqOSk5kbd+8ST4/U3QwzbkxGMZtLOnslnqKIIg3EKXpYuFOQu56667eOSRRzhw4AAnT57kc5/7HImJidx1111XX7tq1SqKtxYzZfoUWu2tyOVyVqxYwdtvv331/h+AtWvXsnjxYu6++25KSkqora3l0KFDPPvss5SVlUnxbQqCXzKUG0nJiSRA49rBCFEAfWxKeBBzk8N4T+wNJggebdA+SN9gH5lhmbz55pvMnz+fwsJCFi9ejMPhYOfOnahU/5g2u3LlSmw2G3Nun3N1UcRVq1Zhs9lYtWrV1dfJZDJ27tzJihUreOihh5g2bRqf+cxnqKurIzY21t3fpiD4pU5jLy31ZjLnu/4zJ3PcbDt2H2QymQgNDaWrqwudTjfiuTcO1PAfReco+/ZadBrXrDsgCJ7CarXS0tJCdHT0iILB05U3l3O8+ThfmPUFVPKx5z7ZcpIPr3zIF2Z9AbVC7cKEzuet10oQxqusqJZyfR1f/OEyVOOcGTpeYgToEzbmxDNgs7OrQrTBBMFTGToNpOpSx1X8AGSEZmBz2KjtqnVNMEEQJs1QZiQtJ9LlxQ+IAmiEuFANt6WGi0URBcFDdfR30NbXRkb49Xt/3UpIQAjxwfFibzBB8FAdTT20NXSTucA9LWdRAF2jMDeBD6pa6ewVe/wIgqcxdBoIUASQrE2e0PszwzK5ZL5E/2C/k5MJgjBZVWVGAjQKkrMj3HI+UQBdoyAnDrvDQYlogwmCR3E4HBg6DaTp0lDKJzY7JCMsA4fDQU1XjZPTCYIwWYZyI2mzo1GqXN/+AlEAXSdGq2FRWiTviTaYIHiU9v5
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjcAAAGyCAYAAAAYveVYAAAAOXRFWHRT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j/6drVe2EtQ4CE9nzwLbrhQ3uWRro2Neb3/iElOY9fsZ1XGEME+JN2HjKKj1MtTsqTrNf9nYai0fHsTC1hDVaYQwS7eTbzP9wHRe9H2RDr4dCnTbUtzkQXnPQozrWI3vIq4QfuGO6jhCmBeDAdYP027D7jRPdZonFasI7abAoWVwcYfqNEKYFYPBwOSIyTjYOjAhYEKBb1+Kmzwa0MSXJhWKMWb1cRJT0lXHEcJ8HP0Bzv8BXT8FFw/VaZ6u4TtaC4i1H0BKguo0QpiNsAth7L62m5AmIRR1Klrg25fiJo9sbHTM6eVHfHIaoRtOq44jhHmIj4HN46FOf6j6ouo0z2Zjo7WASImHPwr+26cQ5ujmw5vMPjSb7hW708qnlZIMUtwYgY+HC5O61GDlX9f480yc6jhCmDa9XjsT4uQGHWeqTvPP3MtBhxnamaazm1WnEcKk6Q16gvcFU8ShCGMbjVWWQ4obI+nb0IdWVYsz9tcTxCdLbxohnumvryF6F3T/XCtwzEG9AVCpHaz/EJJl+gchnmXl2ZXsv7mfKU2nUMShiLIcUtwYiU6nY9ZLfqSmZxKy7pTqOEKYprsXYWswNHgTKr6gOk326XTQ7TPISIFNH6lOI4RJupp4lY8Pf0yfKn1oWqqp0ixS3BiRt5sTU7rXZO2xG/x+4qbqOEKYFn0mrB0ChYpDu2mq0+Scayl4cS6cXA2n16pOI4RJydRnEhQehIeTB6MajFIdR4obY+tRpzT
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjcAAAGyCAYAAAAYveVYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACGqklEQVR4nOzdd1gU59rH8e/SQQFBFCwo9g52VKyxxm5iOcZETdcYY40VwYJdE2s0MckxPZZErDGWWBFLLNi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SHlsHFHarTCGFS9Ho9E8MnYmdtxzj/cfm+fSlucqlvQx8ali3MqNXHSUhKVR1HCNNx9Ec4/yd0mg9O7qrTPFu997UWEGs/hqR41WmEMBmhF0LZfW03wQ2DKeRQKN+3L8VNLllZ6ZjV3Ze4xBRCNpxWHUcI0xAXDZvHQs0+UOlV1Wmez8pKawGRFAd/5v+3TyFM0c2HN5l5aCZdynWhuXdzJRmkuDEAb3cnJnSsysq/r/HXmVjVcYQwbhkZ2pkQB1doN111mpdzKw1tp2lnms5uVp1GCKOWoc8gaF8QznbOjK4/WlkOKW4MpFc9b5pXKsLo304Qlyi9aYR4rr+/gahd0GWhVuCYgtp9oXxrWP8JJMr0D0I8z8qzK9l/cz+TGk3C2c5ZWQ4pbgxEp9Mx4zVfklPTCV53SnUcIYzT3YuwNQjqvgPlXlGdJut0Oui8ANKSYNOnqtMIYZSuJlzls8Of0bNiTxoVb6Q0ixQ3BuTl6sCkLtVYe+wGf5y4qTqOEMYlIx3WDoICRaD1FNVpss+lOLw6G06uhtNrVacRwqikZ6QTGBaIu4M7I+qOUB1HihtD61qzBG2qejI
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjcAAAGyCAYAAAAYveVYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAC/MUlEQVR4nOzdd1zb95348Zc2S2JvMw0eYOOdxBtPhIMz/OtK0qbpyl2uuaZNe0l6aZPeNU3aa3tp77rSNL2016TNXc92EscIvPCOB94Y24AR2BgQmCGxJJD0+0OBxjbYDElfSXyejwePJtJ3vMmnwFuf9/fz/sicTqcTQRAEQRCEACGXOgBBEARBEAR3EsmNIAiCIAgBRSQ3giAIgiAEFJHcCIIgCIIQUERyIwiCIAhCQ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IVC9uj/2AGuZKh6F/S2eyYuwSNKjCUEK4NZMWXFmM7TZ+g5eO0gZpsoRfoTc7EBWUgIYSvHNt66DYV079+P3SzG259Ul5tQahQTKkmBSG5ucG9eIgMOJ6UVTVKHIoxFxRaYrgf16EoUQ3IeAMcAXNjukbAEzzAYDeRPySdYGTym89alrcPusLO7freHIhM8wVxcjDY/H3nw2MZbq9fj7O/HsluMtz+pPm4iY3Y0KrViQtcRyc3HxOuCWJQexTZRmvIfLZeg+dzwe0ndiS4R0paI0pQfudx5mUvtl8ZUkhoUFxLH/Pj5YtWUH7Fevoz14sXbNu4biSo+nuAFC0Rpyo+0N3VzvaGLrAmskhokkpubbMxL5GB1K+3dNqlDEUajYjOota7+NuOR+yBcLoOeNreGJXhGibGEUFUoy6Y
"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(viscosity_train[\"T\"].sort_values().unique(), \"temp\")\n",
"al = ctrl.Antecedent(np.arange(0, 0.3, 0.005), \"al\")\n",
"ti = ctrl.Antecedent(np.arange(0, 0.3, 0.005), \"ti\")\n",
"viscosity = ctrl.Consequent(np.arange(1.18, 3.71, 0.00001), \"viscosity\")\n",
"\n",
"temp.automf(5, 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",
"viscosity.automf(5, variable_type=\"quant\")\n",
"viscosity.view()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"19"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"[IF (temp[higher] AND ti[low]) AND al[low] THEN viscosity[lower]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[average] AND ti[low]) AND al[low] THEN viscosity[low]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[low] AND ti[low]) AND al[low] THEN viscosity[high]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[lower] AND ti[low]) AND al[low] THEN viscosity[higher]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[higher] AND ti[low]) AND al[high] THEN viscosity[low]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[average] AND ti[low]) AND al[high] THEN viscosity[higher]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[low] AND ti[low]) AND al[high] THEN viscosity[higher]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[lower] AND ti[low]) AND al[high] THEN viscosity[higher]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF temp[higher] AND ti[high] THEN viscosity[low]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF temp[average] AND ti[high] THEN viscosity[higher]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF temp[low] AND ti[high] THEN viscosity[higher]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF temp[lower] AND ti[high] THEN viscosity[higher]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[higher] AND ti[average]) AND al[low] THEN viscosity[lower]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[average] AND ti[average]) AND al[low] THEN viscosity[average]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[low] AND ti[average]) AND al[low] THEN viscosity[higher]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[lower] AND ti[average]) AND al[low] THEN viscosity[higher]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[average] AND ti[low]) AND al[average] THEN viscosity[average]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[low] AND ti[low]) AND al[average] THEN viscosity[high]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax,\n",
" IF (temp[lower] AND ti[low]) AND al[average] THEN viscosity[higher]\n",
" \tAND aggregation function : fmin\n",
" \tOR aggregation function : fmax]"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from src.rules import get_fuzzy_rules\n",
"\n",
"fuzzy_variables = {\"Al2O3\": al, \"TiO2\": ti, \"T\": temp, \"consequent\": viscosity}\n",
"fuzzy_rules = get_fuzzy_rules(clustered_rules, fuzzy_variables)\n",
"\n",
"fuzzy_cntrl = ctrl.ControlSystem(fuzzy_rules)\n",
"\n",
"sim = ctrl.ControlSystemSimulation(fuzzy_cntrl, lenient=False)\n",
"\n",
"display(len(fuzzy_rules))\n",
"fuzzy_rules"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"=============\n",
" Antecedents \n",
"=============\n",
"Antecedent: temp = 20\n",
" - lower : 1.0\n",
" - low : 0.0\n",
" - average : 0.0\n",
" - high : 0.0\n",
" - higher : 0.0\n",
"Antecedent: ti = 0.0\n",
" - low : 1.0\n",
" - average : 0.0\n",
" - high : 0.0\n",
"Antecedent: al = 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[higher] AND ti[low]) AND al[low] THEN viscosity[lower]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[higher] : 0.0\n",
" - ti[low] : 1.0\n",
" - al[low] : 1.0\n",
" (temp[higher] AND ti[low]) AND al[low] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[lower] : 0.0\n",
"\n",
"RULE #1:\n",
" IF (temp[average] AND ti[low]) AND al[low] THEN viscosity[low]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[average] : 0.0\n",
" - ti[low] : 1.0\n",
" - al[low] : 1.0\n",
" (temp[average] AND ti[low]) AND al[low] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[low] : 0.0\n",
"\n",
"RULE #2:\n",
" IF (temp[low] AND ti[low]) AND al[low] THEN viscosity[high]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[low] : 0.0\n",
" - ti[low] : 1.0\n",
" - al[low] : 1.0\n",
" (temp[low] AND ti[low]) AND al[low] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[high] : 0.0\n",
"\n",
"RULE #3:\n",
" IF (temp[lower] AND ti[low]) AND al[low] THEN viscosity[higher]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[lower] : 1.0\n",
" - ti[low] : 1.0\n",
" - al[low] : 1.0\n",
" (temp[lower] AND ti[low]) AND al[low] = 1.0\n",
" Activation (THEN-clause):\n",
" viscosity[higher] : 1.0\n",
"\n",
"RULE #4:\n",
" IF (temp[higher] AND ti[low]) AND al[high] THEN viscosity[low]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[higher] : 0.0\n",
" - ti[low] : 1.0\n",
" - al[high] : 0.0\n",
" (temp[higher] AND ti[low]) AND al[high] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[low] : 0.0\n",
"\n",
"RULE #5:\n",
" IF (temp[average] AND ti[low]) AND al[high] THEN viscosity[higher]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[average] : 0.0\n",
" - ti[low] : 1.0\n",
" - al[high] : 0.0\n",
" (temp[average] AND ti[low]) AND al[high] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[higher] : 0.0\n",
"\n",
"RULE #6:\n",
" IF (temp[low] AND ti[low]) AND al[high] THEN viscosity[higher]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[low] : 0.0\n",
" - ti[low] : 1.0\n",
" - al[high] : 0.0\n",
" (temp[low] AND ti[low]) AND al[high] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[higher] : 0.0\n",
"\n",
"RULE #7:\n",
" IF (temp[lower] AND ti[low]) AND al[high] THEN viscosity[higher]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[lower] : 1.0\n",
" - ti[low] : 1.0\n",
" - al[high] : 0.0\n",
" (temp[lower] AND ti[low]) AND al[high] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[higher] : 0.0\n",
"\n",
"RULE #8:\n",
" IF temp[higher] AND ti[high] THEN viscosity[low]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[higher] : 0.0\n",
" - ti[high] : 0.0\n",
" temp[higher] AND ti[high] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[low] : 0.0\n",
"\n",
"RULE #9:\n",
" IF temp[average] AND ti[high] THEN viscosity[higher]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[average] : 0.0\n",
" - ti[high] : 0.0\n",
" temp[average] AND ti[high] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[higher] : 0.0\n",
"\n",
"RULE #10:\n",
" IF temp[low] AND ti[high] THEN viscosity[higher]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[low] : 0.0\n",
" - ti[high] : 0.0\n",
" temp[low] AND ti[high] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[higher] : 0.0\n",
"\n",
"RULE #11:\n",
" IF temp[lower] AND ti[high] THEN viscosity[higher]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[lower] : 1.0\n",
" - ti[high] : 0.0\n",
" temp[lower] AND ti[high] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[higher] : 0.0\n",
"\n",
"RULE #12:\n",
" IF (temp[higher] AND ti[average]) AND al[low] THEN viscosity[lower]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[higher] : 0.0\n",
" - ti[average] : 0.0\n",
" - al[low] : 1.0\n",
" (temp[higher] AND ti[average]) AND al[low] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[lower] : 0.0\n",
"\n",
"RULE #13:\n",
" IF (temp[average] AND ti[average]) AND al[low] THEN viscosity[average]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[average] : 0.0\n",
" - ti[average] : 0.0\n",
" - al[low] : 1.0\n",
" (temp[average] AND ti[average]) AND al[low] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[average] : 0.0\n",
"\n",
"RULE #14:\n",
" IF (temp[low] AND ti[average]) AND al[low] THEN viscosity[higher]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[low] : 0.0\n",
" - ti[average] : 0.0\n",
" - al[low] : 1.0\n",
" (temp[low] AND ti[average]) AND al[low] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[higher] : 0.0\n",
"\n",
"RULE #15:\n",
" IF (temp[lower] AND ti[average]) AND al[low] THEN viscosity[higher]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[lower] : 1.0\n",
" - ti[average] : 0.0\n",
" - al[low] : 1.0\n",
" (temp[lower] AND ti[average]) AND al[low] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[higher] : 0.0\n",
"\n",
"RULE #16:\n",
" IF (temp[average] AND ti[low]) AND al[average] THEN viscosity[average]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[average] : 0.0\n",
" - ti[low] : 1.0\n",
" - al[average] : 0.0\n",
" (temp[average] AND ti[low]) AND al[average] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[average] : 0.0\n",
"\n",
"RULE #17:\n",
" IF (temp[low] AND ti[low]) AND al[average] THEN viscosity[high]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[low] : 0.0\n",
" - ti[low] : 1.0\n",
" - al[average] : 0.0\n",
" (temp[low] AND ti[low]) AND al[average] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[high] : 0.0\n",
"\n",
"RULE #18:\n",
" IF (temp[lower] AND ti[low]) AND al[average] THEN viscosity[higher]\n",
"\tAND aggregation function : fmin\n",
"\tOR aggregation function : fmax\n",
"\n",
" Aggregation (IF-clause):\n",
" - temp[lower] : 1.0\n",
" - ti[low] : 1.0\n",
" - al[average] : 0.0\n",
" (temp[lower] AND ti[low]) AND al[average] = 0.0\n",
" Activation (THEN-clause):\n",
" viscosity[higher] : 0.0\n",
"\n",
"\n",
"==============================\n",
" Intermediaries and Conquests \n",
"==============================\n",
"Consequent: viscosity = 3.499157499995422\n",
" lower:\n",
" Accumulate using accumulation_max : 0.0\n",
" low:\n",
" Accumulate using accumulation_max : 0.0\n",
" average:\n",
" Accumulate using accumulation_max : 0.0\n",
" high:\n",
" Accumulate using accumulation_max : 0.0\n",
" higher:\n",
" Accumulate using accumulation_max : 1.0\n",
"\n"
]
},
{
"data": {
"text/plain": [
"np.float64(3.499157499995422)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sim.input[\"temp\"] = 20\n",
"sim.input[\"al\"] = 0.0\n",
"sim.input[\"ti\"] = 0.0\n",
"sim.compute()\n",
"sim.print_state()\n",
"display(sim.output[\"viscosity\"])"
]
},
{
"cell_type": "code",
"execution_count": 13,
"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>Viscosity</th>\n",
" <th>ViscosityPred</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>3.707</td>\n",
" <td>3.499157</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>3.180</td>\n",
" <td>3.188565</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>2.361</td>\n",
" <td>2.732494</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>45</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.832</td>\n",
" <td>1.812498</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>50</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.629</td>\n",
" <td>1.812498</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>55</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.465</td>\n",
" <td>1.812498</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>70</td>\n",
" <td>0.00</td>\n",
" <td>0.0</td>\n",
" <td>1.194</td>\n",
" <td>1.390833</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>20</td>\n",
" <td>0.05</td>\n",
" <td>0.0</td>\n",
" <td>4.660</td>\n",
" <td>3.481064</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>30</td>\n",
" <td>0.05</td>\n",
" <td>0.0</td>\n",
" <td>3.380</td>\n",
" <td>3.090537</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>35</td>\n",
" <td>0.05</td>\n",
" <td>0.0</td>\n",
" <td>2.874</td>\n",
" <td>2.703435</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>40</td>\n",
" <td>0.05</td>\n",
" <td>0.0</td>\n",
" <td>2.489</td>\n",
" <td>2.365680</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.897</td>\n",
" <td>2.054459</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.709</td>\n",
" <td>2.128746</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>60</td>\n",
" <td>0.05</td>\n",
" <td>0.0</td>\n",
" <td>1.470</td>\n",
" <td>1.465795</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>20</td>\n",
" <td>0.30</td>\n",
" <td>0.0</td>\n",
" <td>6.670</td>\n",
" <td>3.499157</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" T Al2O3 TiO2 Viscosity ViscosityPred\n",
"0 20 0.00 0.0 3.707 3.499157\n",
"1 25 0.00 0.0 3.180 3.188565\n",
"2 35 0.00 0.0 2.361 2.732494\n",
"3 45 0.00 0.0 1.832 1.812498\n",
"4 50 0.00 0.0 1.629 1.812498\n",
"5 55 0.00 0.0 1.465 1.812498\n",
"6 70 0.00 0.0 1.194 1.390833\n",
"7 20 0.05 0.0 4.660 3.481064\n",
"8 30 0.05 0.0 3.380 3.090537\n",
"9 35 0.05 0.0 2.874 2.703435\n",
"10 40 0.05 0.0 2.489 2.365680\n",
"11 50 0.05 0.0 1.897 2.054459\n",
"12 55 0.05 0.0 1.709 2.128746\n",
"13 60 0.05 0.0 1.470 1.465795\n",
"14 20 0.30 0.0 6.670 3.499157"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"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[\"viscosity\"]\n",
"\n",
"result_train = viscosity_train.copy()\n",
"result_train[\"ViscosityPred\"] = result_train.apply(fuzzy_pred, axis=1)\n",
"result_train.head(15)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"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>Viscosity</th>\n",
" <th>ViscosityPred</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>2.716</td>\n",
" <td>3.089540</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>40</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" <td>2.073</td>\n",
" <td>2.359522</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>60</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" <td>1.329</td>\n",
" <td>1.465795</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>65</td>\n",
" <td>0.00</td>\n",
" <td>0.00</td>\n",
" <td>1.211</td>\n",
" <td>1.414928</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>25</td>\n",
" <td>0.05</td>\n",
" <td>0.00</td>\n",
" <td>4.120</td>\n",
" <td>3.188565</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>45</td>\n",
" <td>0.05</td>\n",
" <td>0.00</td>\n",
" <td>2.217</td>\n",
" <td>2.045546</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>65</td>\n",
" <td>0.05</td>\n",
" <td>0.00</td>\n",
" <td>1.315</td>\n",
" <td>1.414928</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>70</td>\n",
" <td>0.05</td>\n",
" <td>0.00</td>\n",
" <td>1.105</td>\n",
" <td>1.408926</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>45</td>\n",
" <td>0.30</td>\n",
" <td>0.00</td>\n",
" <td>3.111</td>\n",
" <td>3.499157</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>50</td>\n",
" <td>0.30</td>\n",
" <td>0.00</td>\n",
" <td>2.735</td>\n",
" <td>3.475062</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>65</td>\n",
" <td>0.30</td>\n",
" <td>0.00</td>\n",
" <td>1.936</td>\n",
" <td>1.812498</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>30</td>\n",
" <td>0.00</td>\n",
" <td>0.05</td>\n",
" <td>3.587</td>\n",
" <td>3.111691</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>55</td>\n",
" <td>0.00</td>\n",
" <td>0.05</td>\n",
" <td>1.953</td>\n",
" <td>2.128746</td>\n",
" </tr>\n",
" <tr>\n",
" <th>13</th>\n",
" <td>65</td>\n",
" <td>0.00</td>\n",
" <td>0.05</td>\n",
" <td>1.443</td>\n",
" <td>1.414928</td>\n",
" </tr>\n",
" <tr>\n",
" <th>14</th>\n",
" <td>40</td>\n",
" <td>0.00</td>\n",
" <td>0.30</td>\n",
" <td>3.990</td>\n",
" <td>3.475062</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>50</td>\n",
" <td>0.00</td>\n",
" <td>0.30</td>\n",
" <td>3.189</td>\n",
" <td>3.475062</td>\n",
" </tr>\n",
" <tr>\n",
" <th>16</th>\n",
" <td>65</td>\n",
" <td>0.00</td>\n",
" <td>0.30</td>\n",
" <td>2.287</td>\n",
" <td>1.812498</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" T Al2O3 TiO2 Viscosity ViscosityPred\n",
"0 30 0.00 0.00 2.716 3.089540\n",
"1 40 0.00 0.00 2.073 2.359522\n",
"2 60 0.00 0.00 1.329 1.465795\n",
"3 65 0.00 0.00 1.211 1.414928\n",
"4 25 0.05 0.00 4.120 3.188565\n",
"5 45 0.05 0.00 2.217 2.045546\n",
"6 65 0.05 0.00 1.315 1.414928\n",
"7 70 0.05 0.00 1.105 1.408926\n",
"8 45 0.30 0.00 3.111 3.499157\n",
"9 50 0.30 0.00 2.735 3.475062\n",
"10 65 0.30 0.00 1.936 1.812498\n",
"11 30 0.00 0.05 3.587 3.111691\n",
"12 55 0.00 0.05 1.953 2.128746\n",
"13 65 0.00 0.05 1.443 1.414928\n",
"14 40 0.00 0.30 3.990 3.475062\n",
"15 50 0.00 0.30 3.189 3.475062\n",
"16 65 0.00 0.30 2.287 1.812498"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"result_test = viscosity_test.copy()\n",
"result_test[\"ViscosityPred\"] = result_test.apply(fuzzy_pred, axis=1)\n",
"result_test"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'RMSE_train': 1.0977710360150494,\n",
" 'RMSE_test': 0.4076186194536602,\n",
" 'RMAE_test': 0.5797504263400755,\n",
" 'R2_test': 0.813200460937507}"
]
},
"execution_count": 15,
"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[\"Viscosity\"], result_train[\"ViscosityPred\"])\n",
")\n",
"rmetrics[\"RMSE_test\"] = math.sqrt(\n",
" metrics.mean_squared_error(result_test[\"Viscosity\"], result_test[\"ViscosityPred\"])\n",
")\n",
"rmetrics[\"RMAE_test\"] = math.sqrt(\n",
" metrics.mean_absolute_error(result_test[\"Viscosity\"], result_test[\"ViscosityPred\"])\n",
")\n",
"rmetrics[\"R2_test\"] = metrics.r2_score(\n",
" result_test[\"Viscosity\"], result_test[\"ViscosityPred\"]\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
}