adding comments

master
Davud 2022-12-22 12:30:15 +00:00
parent 037eda9a5f
commit 292f8729cd
1 changed files with 52 additions and 52 deletions

View File

@ -11,7 +11,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": 25,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -55,7 +55,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 3, "execution_count": 26,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -91,7 +91,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": 27,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -334,7 +334,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 28,
"metadata": { "metadata": {
"scrolled": false "scrolled": false
}, },
@ -374,7 +374,7 @@
" <td>3.5</td>\n", " <td>3.5</td>\n",
" <td>1.4</td>\n", " <td>1.4</td>\n",
" <td>0.2</td>\n", " <td>0.2</td>\n",
" <td>Setosa</td>\n", " <td>Iris-setosa</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
" <th>1</th>\n", " <th>1</th>\n",
@ -382,7 +382,7 @@
" <td>3.0</td>\n", " <td>3.0</td>\n",
" <td>1.4</td>\n", " <td>1.4</td>\n",
" <td>0.2</td>\n", " <td>0.2</td>\n",
" <td>Setosa</td>\n", " <td>Iris-setosa</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
" <th>2</th>\n", " <th>2</th>\n",
@ -390,7 +390,7 @@
" <td>3.2</td>\n", " <td>3.2</td>\n",
" <td>1.3</td>\n", " <td>1.3</td>\n",
" <td>0.2</td>\n", " <td>0.2</td>\n",
" <td>Setosa</td>\n", " <td>Iris-setosa</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
" <th>3</th>\n", " <th>3</th>\n",
@ -398,7 +398,7 @@
" <td>3.1</td>\n", " <td>3.1</td>\n",
" <td>1.5</td>\n", " <td>1.5</td>\n",
" <td>0.2</td>\n", " <td>0.2</td>\n",
" <td>Setosa</td>\n", " <td>Iris-setosa</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
" <th>4</th>\n", " <th>4</th>\n",
@ -406,7 +406,7 @@
" <td>3.6</td>\n", " <td>3.6</td>\n",
" <td>1.4</td>\n", " <td>1.4</td>\n",
" <td>0.2</td>\n", " <td>0.2</td>\n",
" <td>Setosa</td>\n", " <td>Iris-setosa</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
" <th>...</th>\n", " <th>...</th>\n",
@ -422,7 +422,7 @@
" <td>3.0</td>\n", " <td>3.0</td>\n",
" <td>5.2</td>\n", " <td>5.2</td>\n",
" <td>2.3</td>\n", " <td>2.3</td>\n",
" <td>Virginica</td>\n", " <td>Iris-virginica</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
" <th>146</th>\n", " <th>146</th>\n",
@ -430,7 +430,7 @@
" <td>2.5</td>\n", " <td>2.5</td>\n",
" <td>5.0</td>\n", " <td>5.0</td>\n",
" <td>1.9</td>\n", " <td>1.9</td>\n",
" <td>Virginica</td>\n", " <td>Iris-virginica</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
" <th>147</th>\n", " <th>147</th>\n",
@ -438,7 +438,7 @@
" <td>3.0</td>\n", " <td>3.0</td>\n",
" <td>5.2</td>\n", " <td>5.2</td>\n",
" <td>2.0</td>\n", " <td>2.0</td>\n",
" <td>Virginica</td>\n", " <td>Iris-virginica</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
" <th>148</th>\n", " <th>148</th>\n",
@ -446,7 +446,7 @@
" <td>3.4</td>\n", " <td>3.4</td>\n",
" <td>5.4</td>\n", " <td>5.4</td>\n",
" <td>2.3</td>\n", " <td>2.3</td>\n",
" <td>Virginica</td>\n", " <td>Iris-virginica</td>\n",
" </tr>\n", " </tr>\n",
" <tr>\n", " <tr>\n",
" <th>149</th>\n", " <th>149</th>\n",
@ -454,7 +454,7 @@
" <td>3.0</td>\n", " <td>3.0</td>\n",
" <td>5.1</td>\n", " <td>5.1</td>\n",
" <td>1.8</td>\n", " <td>1.8</td>\n",
" <td>Virginica</td>\n", " <td>Iris-virginica</td>\n",
" </tr>\n", " </tr>\n",
" </tbody>\n", " </tbody>\n",
"</table>\n", "</table>\n",
@ -462,30 +462,30 @@
"</div>" "</div>"
], ],
"text/plain": [ "text/plain": [
" sepal_length sepal_width petal_length petal_width type\n", " sepal_length sepal_width petal_length petal_width type\n",
"0 5.1 3.5 1.4 0.2 Setosa\n", "0 5.1 3.5 1.4 0.2 Iris-setosa\n",
"1 4.9 3.0 1.4 0.2 Setosa\n", "1 4.9 3.0 1.4 0.2 Iris-setosa\n",
"2 4.7 3.2 1.3 0.2 Setosa\n", "2 4.7 3.2 1.3 0.2 Iris-setosa\n",
"3 4.6 3.1 1.5 0.2 Setosa\n", "3 4.6 3.1 1.5 0.2 Iris-setosa\n",
"4 5.0 3.6 1.4 0.2 Setosa\n", "4 5.0 3.6 1.4 0.2 Iris-setosa\n",
".. ... ... ... ... ...\n", ".. ... ... ... ... ...\n",
"145 6.7 3.0 5.2 2.3 Virginica\n", "145 6.7 3.0 5.2 2.3 Iris-virginica\n",
"146 6.3 2.5 5.0 1.9 Virginica\n", "146 6.3 2.5 5.0 1.9 Iris-virginica\n",
"147 6.5 3.0 5.2 2.0 Virginica\n", "147 6.5 3.0 5.2 2.0 Iris-virginica\n",
"148 6.2 3.4 5.4 2.3 Virginica\n", "148 6.2 3.4 5.4 2.3 Iris-virginica\n",
"149 5.9 3.0 5.1 1.8 Virginica\n", "149 5.9 3.0 5.1 1.8 Iris-virginica\n",
"\n", "\n",
"[150 rows x 5 columns]" "[150 rows x 5 columns]"
] ]
}, },
"execution_count": 2, "execution_count": 28,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"col_names = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'type']\n", "col_names = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'type']\n",
"data = pd.read_csv(\"iris.csv\", skiprows=1, header=None, names=col_names)\n", "data = pd.read_csv(\"iris_data.csv\", names=col_names)\n",
"data" "data"
] ]
}, },
@ -527,7 +527,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 29,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -548,7 +548,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 6, "execution_count": 30,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -567,7 +567,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 7, "execution_count": 31,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -575,16 +575,16 @@
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"X_2 ≤ 1.9 ? 0.337\n", "X_2 ≤ 1.9 ? 0.337\n",
"1 : left: Setosa\n", "1 : left: Iris-setosa\n",
"1 : right: X_3 ≤ 1.5 ? 0.427\n", "1 : right: X_3 ≤ 1.5 ? 0.427\n",
"2 : left: X_2 ≤ 4.9 ? 0.051\n", "2 : left: X_2 ≤ 4.9 ? 0.051\n",
"3 : left: Versicolor\n", "3 : left: Iris-versicolor\n",
"3 : right: Virginica\n", "3 : right: Iris-virginica\n",
"2 : right: X_2 ≤ 5.0 ? 0.02\n", "2 : right: X_2 ≤ 5.0 ? 0.02\n",
"3 : left: X_1 ≤ 2.8 ? 0.208\n", "3 : left: X_1 ≤ 2.8 ? 0.208\n",
"4 : left: Virginica\n", "4 : left: Iris-virginica\n",
"4 : right: Versicolor\n", "4 : right: Iris-versicolor\n",
"3 : right: Virginica\n" "3 : right: Iris-virginica\n"
] ]
} }
], ],
@ -598,12 +598,12 @@
"source": [ "source": [
"## Testing the model\n", "## Testing the model\n",
"\n", "\n",
"We are using the definded method predict() to determine the classes of the Test dataset" "We are using the definded method predict() to determine the classes of the Test dataset - those will be stored in the Y_pred which we will than compare to Y_test with the help of sklearn library function called accuracy_score"
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": 32,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -612,7 +612,7 @@
"0.9333333333333333" "0.9333333333333333"
] ]
}, },
"execution_count": 8, "execution_count": 32,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -648,7 +648,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": 33,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -657,7 +657,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": 34,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -787,7 +787,7 @@
"[400 rows x 4 columns]" "[400 rows x 4 columns]"
] ]
}, },
"execution_count": 10, "execution_count": 34,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -805,7 +805,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": 35,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -947,7 +947,7 @@
"[400 rows x 5 columns]" "[400 rows x 5 columns]"
] ]
}, },
"execution_count": 11, "execution_count": 35,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -972,7 +972,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 36,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -985,7 +985,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 37,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -994,7 +994,7 @@
"(320, 80)" "(320, 80)"
] ]
}, },
"execution_count": 13, "execution_count": 37,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
@ -1012,7 +1012,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 38,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -1029,7 +1029,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 39,
"metadata": { "metadata": {
"scrolled": false "scrolled": false
}, },
@ -1143,7 +1143,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 40,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
@ -1152,7 +1152,7 @@
"0.8625" "0.8625"
] ]
}, },
"execution_count": 16, "execution_count": 40,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }