diff --git a/demo/DemoClassification.ipynb b/demo/DemoClassification.ipynb index 26bac02c..f36ddeff 100644 --- a/demo/DemoClassification.ipynb +++ b/demo/DemoClassification.ipynb @@ -13,7 +13,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 16, "id": "6b710e7c", "metadata": {}, "outputs": [], @@ -46,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 17, "id": "f8e46c49", "metadata": {}, "outputs": [], @@ -65,7 +65,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 18, "id": "38d5afb0", "metadata": {}, "outputs": [], @@ -84,7 +84,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 19, "id": "4f807185", "metadata": {}, "outputs": [ @@ -93,7 +93,7 @@ "text/plain": " target\n0 setosa\n1 setosa\n2 setosa\n3 setosa\n4 setosa\n.. ...\n145 virginica\n146 virginica\n147 virginica\n148 virginica\n149 virginica\n\n[150 rows x 1 columns]", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
target
0setosa
1setosa
2setosa
3setosa
4setosa
......
145virginica
146virginica
147virginica
148virginica
149virginica
\n

150 rows × 1 columns

\n
" }, - "execution_count": 4, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -114,7 +114,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 20, "id": "7ac49b4e", "metadata": {}, "outputs": [ @@ -123,7 +123,7 @@ "text/plain": " SepalLength SepalWidth PetalLength PetalWidth iris\n0 5.1 3.5 1.4 0.2 setosa\n1 4.9 3.0 1.4 0.2 setosa\n2 4.7 3.2 1.3 0.2 setosa\n3 4.6 3.1 1.5 0.2 setosa\n4 5.0 3.6 1.4 0.2 setosa\n.. ... ... ... ... ...\n145 6.7 3.0 5.2 2.3 virginica\n146 6.3 2.5 5.0 1.9 virginica\n147 6.5 3.0 5.2 2.0 virginica\n148 6.2 3.4 5.4 2.3 virginica\n149 5.9 3.0 5.1 1.8 virginica\n\n[150 rows x 5 columns]", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
SepalLengthSepalWidthPetalLengthPetalWidthiris
05.13.51.40.2setosa
14.93.01.40.2setosa
24.73.21.30.2setosa
34.63.11.50.2setosa
45.03.61.40.2setosa
..................
1456.73.05.22.3virginica
1466.32.55.01.9virginica
1476.53.05.22.0virginica
1486.23.45.42.3virginica
1495.93.05.11.8virginica
\n

150 rows × 5 columns

\n
" }, - "execution_count": 5, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -145,7 +145,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 21, "id": "03fc5e2c", "metadata": {}, "outputs": [], @@ -164,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 22, "id": "aa8a3128", "metadata": {}, "outputs": [ @@ -172,7 +172,7 @@ "data": { "text/plain": "0.96" }, - "execution_count": 7, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -185,7 +185,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 23, "outputs": [ { "name": "stdout", @@ -231,24 +231,64 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 24, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CART performance (3 rules):\n", - "Accuracy = 0.95\n", - "Fidelity = 0.96\n", + "Accuracy = 0.40\n", + "Fidelity = 0.39\n", "\n", "\n", "CART extracted rules:\n", "\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, virginica) :-\n", + " PetalWidth =< 0.45, SepalLength =< 4.65, SepalWidth =< 2.65.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, setosa) :-\n", + " PetalWidth =< 0.45, SepalLength =< 4.65, SepalWidth =< 3.15.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, versicolor) :-\n", + " PetalWidth =< 0.45, SepalLength =< 4.65, PetalWidth =< 0.25, SepalLength =< 4.5.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, setosa) :-\n", + " PetalWidth =< 0.45, SepalLength =< 4.65, PetalWidth =< 0.25.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, versicolor) :-\n", + " PetalWidth =< 0.45, SepalLength =< 4.65.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, setosa) :-\n", + " PetalWidth =< 0.45, SepalWidth =< 4.05, SepalWidth =< 3.75, PetalWidth =< 0.35, PetalLength =< 1.35.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, setosa) :-\n", + " PetalWidth =< 0.45, SepalWidth =< 4.05, SepalWidth =< 3.75, PetalWidth =< 0.35, SepalWidth =< 3.55, SepalWidth =< 3.05, SepalLength =< 4.85.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, virginica) :-\n", + " PetalWidth =< 0.45, SepalWidth =< 4.05, SepalWidth =< 3.75, PetalWidth =< 0.35, SepalWidth =< 3.55, SepalWidth =< 3.05, SepalLength =< 4.95.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, setosa) :-\n", + " PetalWidth =< 0.45, SepalWidth =< 4.05, SepalWidth =< 3.75, PetalWidth =< 0.35, SepalWidth =< 3.55, SepalWidth =< 3.05.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, virginica) :-\n", + " PetalWidth =< 0.45, SepalWidth =< 4.05, SepalWidth =< 3.75, PetalWidth =< 0.35, SepalWidth =< 3.55, SepalWidth =< 3.15, PetalWidth =< 0.15.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, versicolor) :-\n", + " PetalWidth =< 0.45, SepalWidth =< 4.05, SepalWidth =< 3.75, PetalWidth =< 0.35, SepalWidth =< 3.55, SepalWidth =< 3.15.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, virginica) :-\n", + " PetalWidth =< 0.45, SepalWidth =< 4.05, SepalWidth =< 3.75, PetalWidth =< 0.35, SepalWidth =< 3.55, SepalWidth =< 3.45.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, setosa) :-\n", + " PetalWidth =< 0.45, SepalWidth =< 4.05, SepalWidth =< 3.75, PetalWidth =< 0.35, SepalWidth =< 3.55, PetalWidth =< 0.25.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, virginica) :-\n", + " PetalWidth =< 0.45, SepalWidth =< 4.05, SepalWidth =< 3.75, PetalWidth =< 0.35, SepalWidth =< 3.55.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, versicolor) :-\n", + " PetalWidth =< 0.45, SepalWidth =< 4.05, SepalWidth =< 3.75, PetalWidth =< 0.35.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, setosa) :-\n", + " PetalWidth =< 0.45, SepalWidth =< 4.05, SepalWidth =< 3.75.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, virginica) :-\n", + " PetalWidth =< 0.45, SepalWidth =< 4.05.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, setosa) :-\n", + " PetalWidth =< 0.45.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, versicolor) :-\n", + " PetalLength =< 4.2.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, virginica) :-\n", + " SepalLength =< 6.5, SepalLength =< 5.8.\n", "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, setosa) :-\n", - " PetalLength =< 2.35.\n", + " SepalLength =< 6.5, PetalLength =< 4.85.\n", "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, versicolor) :-\n", - " PetalWidth =< 1.75.\n", - "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, virginica).\n" + " SepalLength =< 6.5.\n", + "iris(PetalLength, PetalWidth, SepalLength, SepalWidth, versicolor).\n" ] } ], @@ -279,7 +319,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 25, "outputs": [ { "name": "stdout", @@ -317,7 +357,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 26, "outputs": [ { "name": "stdout", @@ -392,7 +432,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 27, "outputs": [ { "name": "stdout", @@ -429,7 +469,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 28, "outputs": [ { "name": "stdout", @@ -466,7 +506,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 28, "outputs": [], "source": [], "metadata": {