NNW/Übung 2/flower_training.ipynb

1534 lines
66 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"id": "initial_id",
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2026-10-01T14:23:10.794715300Z",
"start_time": "2026-10-01T14:23:10.677571100Z"
}
},
"source": [
"from sklearn.svm import LinearSVC\n",
"import numpy as np"
],
"outputs": [],
"execution_count": 27
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-10-01T14:23:10.901047600Z",
"start_time": "2026-10-01T14:23:10.847255400Z"
}
},
"cell_type": "code",
"source": [
"flower_data = np.loadtxt('data/iris.csv', delimiter=',')\n",
"inverse = flower_data.T\n",
"X = inverse[:-1]\n",
"T = inverse[-1]"
],
"id": "b4e863de5bc956",
"outputs": [],
"execution_count": 28
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-10-01T14:23:11.054318400Z",
"start_time": "2026-10-01T14:23:10.907043600Z"
}
},
"cell_type": "code",
"source": [
"two_features = X[:2].T\n",
"print(two_features.shape)"
],
"id": "bcd23c414c49a88e",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(150, 2)\n"
]
}
],
"execution_count": 29
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-10-01T14:23:11.153029400Z",
"start_time": "2026-10-01T14:23:11.085339100Z"
}
},
"cell_type": "code",
"source": [
"clf = LinearSVC()\n",
"\n",
"clf.fit(two_features,T.T)"
],
"id": "dcb75df28cbf865f",
"outputs": [
{
"data": {
"text/plain": [
"LinearSVC()"
],
"text/html": [
"<style>.sk-global {\n",
" /* Definition of color scheme common for light and dark mode */\n",
" --sklearn-color-text: #000;\n",
" --sklearn-color-text-muted: #666;\n",
" --sklearn-color-line: gray;\n",
" /* Definition of color scheme for unfitted estimators */\n",
" --sklearn-color-unfitted-level-0: #fff5e6;\n",
" --sklearn-color-unfitted-level-1: #f6e4d2;\n",
" --sklearn-color-unfitted-level-2: #ffe0b3;\n",
" --sklearn-color-unfitted-level-3: chocolate;\n",
" /* Definition of color scheme for fitted estimators */\n",
" --sklearn-color-fitted-level-0: #f0f8ff;\n",
" --sklearn-color-fitted-level-1: #d4ebff;\n",
" --sklearn-color-fitted-level-2: #b3dbfd;\n",
" --sklearn-color-fitted-level-3: cornflowerblue;\n",
"}\n",
"\n",
".sk-global.light {\n",
" /* Specific color for light theme */\n",
" --sklearn-color-text-on-default-background: black;\n",
" --sklearn-color-background: white;\n",
" --sklearn-color-border-box: black;\n",
" --sklearn-color-icon: #696969;\n",
"}\n",
"\n",
".sk-global.dark {\n",
" --sklearn-color-text-on-default-background: white;\n",
" --sklearn-color-background: #111;\n",
" --sklearn-color-border-box: white;\n",
" --sklearn-color-icon: #878787;\n",
"}\n",
"\n",
".sk-global {\n",
" color: var(--sklearn-color-text);\n",
"}\n",
"\n",
".sk-global pre {\n",
" padding: 0;\n",
"}\n",
"\n",
".sk-global input.sk-hidden--visually {\n",
" border: 0;\n",
" clip-path: inset(100%);\n",
" height: 1px;\n",
" margin: -1px;\n",
" overflow: hidden;\n",
" padding: 0;\n",
" position: absolute;\n",
" width: 1px;\n",
"}\n",
"\n",
".sk-global div.sk-dashed-wrapped {\n",
" border: 1px dashed var(--sklearn-color-line);\n",
" margin: 0 0.4em 0.5em 0.4em;\n",
" box-sizing: border-box;\n",
" padding-bottom: 0.4em;\n",
" background-color: var(--sklearn-color-background);\n",
"}\n",
"\n",
".sk-global div.sk-container {\n",
" /* jupyter's `normalize.less` sets `[hidden] { display: none; }`\n",
" but bootstrap.min.css set `[hidden] { display: none !important; }`\n",
" so we also need the `!important` here to be able to override the\n",
" default hidden behavior on the sphinx rendered scikit-learn.org.\n",
" See: https://github.com/scikit-learn/scikit-learn/issues/21755 */\n",
" display: inline-block !important;\n",
" position: relative;\n",
"}\n",
"\n",
".sk-global div.sk-text-repr-fallback {\n",
" display: none;\n",
"}\n",
"\n",
"div.sk-parallel-item,\n",
"div.sk-serial,\n",
"div.sk-item {\n",
" /* draw centered vertical line to link estimators */\n",
" background-image: linear-gradient(var(--sklearn-color-text-on-default-background), var(--sklearn-color-text-on-default-background));\n",
" background-size: 2px 100%;\n",
" background-repeat: no-repeat;\n",
" background-position: center center;\n",
"}\n",
"\n",
"/* Parallel-specific style estimator block */\n",
"\n",
".sk-global div.sk-parallel-item::after {\n",
" content: \"\";\n",
" width: 100%;\n",
" border-bottom: 2px solid var(--sklearn-color-text-on-default-background);\n",
" flex-grow: 1;\n",
"}\n",
"\n",
".sk-global div.sk-parallel {\n",
" display: flex;\n",
" align-items: stretch;\n",
" justify-content: center;\n",
" background-color: var(--sklearn-color-background);\n",
" position: relative;\n",
"}\n",
"\n",
".sk-global div.sk-parallel-item {\n",
" display: flex;\n",
" flex-direction: column;\n",
"}\n",
"\n",
".sk-global div.sk-parallel-item:first-child::after {\n",
" align-self: flex-end;\n",
" width: 50%;\n",
"}\n",
"\n",
".sk-global div.sk-parallel-item:last-child::after {\n",
" align-self: flex-start;\n",
" width: 50%;\n",
"}\n",
"\n",
".sk-global div.sk-parallel-item:only-child::after {\n",
" width: 0;\n",
"}\n",
"\n",
"/* Serial-specific style estimator block */\n",
"\n",
".sk-global div.sk-serial {\n",
" display: flex;\n",
" flex-direction: column;\n",
" align-items: center;\n",
" background-color: var(--sklearn-color-background);\n",
" padding-right: 1em;\n",
" padding-left: 1em;\n",
"}\n",
"\n",
"\n",
"/* Toggleable style: style used for estimator/Pipeline/ColumnTransformer box that is\n",
"clickable and can be expanded/collapsed.\n",
"- Pipeline and ColumnTransformer use this feature and define the default style\n",
"- Estimators will overwrite some part of the style using the `sk-estimator` class\n",
"*/\n",
"\n",
"/* Pipeline and ColumnTransformer style (default) */\n",
"\n",
".sk-global div.sk-toggleable {\n",
" /* Default theme specific background. It is overwritten whether we have a\n",
" specific estimator or a Pipeline/ColumnTransformer */\n",
" background-color: var(--sklearn-color-background);\n",
"}\n",
"\n",
"/* Toggleable label */\n",
".sk-global label.sk-toggleable__label {\n",
" cursor: pointer;\n",
" display: flex;\n",
" width: 100%;\n",
" margin-bottom: 0;\n",
" padding: 0.5em;\n",
" box-sizing: border-box;\n",
" text-align: center;\n",
" align-items: center;\n",
" justify-content: center;\n",
" gap: 0.5em;\n",
"}\n",
"\n",
".sk-global label.sk-toggleable__label .caption {\n",
" font-size: 0.6rem;\n",
" font-weight: lighter;\n",
" color: var(--sklearn-color-text-muted);\n",
"}\n",
"\n",
".sk-global label.sk-toggleable__label-arrow:before {\n",
" /* Arrow on the left of the label */\n",
" content: \"▸\";\n",
" float: left;\n",
" margin-right: 0.25em;\n",
" color: var(--sklearn-color-icon);\n",
"}\n",
"\n",
".sk-global label.sk-toggleable__label-arrow:hover:before {\n",
" color: var(--sklearn-color-text);\n",
"}\n",
"\n",
"/* Toggleable content - dropdown */\n",
"\n",
".sk-global div.sk-toggleable__content {\n",
" display: none;\n",
" text-align: left;\n",
" /* unfitted */\n",
" background-color: var(--sklearn-color-unfitted-level-0);\n",
"}\n",
"\n",
".sk-global div.sk-toggleable__content.fitted {\n",
" /* fitted */\n",
" background-color: var(--sklearn-color-fitted-level-0);\n",
"}\n",
"\n",
".sk-global div.sk-toggleable__content pre {\n",
" margin: 0.2em;\n",
" border-radius: 0.25em;\n",
" color: var(--sklearn-color-text);\n",
" /* unfitted */\n",
" background-color: var(--sklearn-color-unfitted-level-0);\n",
"}\n",
"\n",
".sk-global div.sk-toggleable__content.fitted pre {\n",
" /* unfitted */\n",
" background-color: var(--sklearn-color-fitted-level-0);\n",
"}\n",
"\n",
".sk-global input.sk-toggleable__control:checked~div.sk-toggleable__content {\n",
" /* Expand drop-down */\n",
" display: block;\n",
" width: 100%;\n",
" overflow: visible;\n",
"}\n",
"\n",
".sk-global input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {\n",
" content: \"▾\";\n",
"}\n",
"\n",
"/* Pipeline/ColumnTransformer-specific style */\n",
"\n",
".sk-global div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
" color: var(--sklearn-color-text);\n",
" background-color: var(--sklearn-color-unfitted-level-2);\n",
"}\n",
"\n",
".sk-global div.sk-label.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
" background-color: var(--sklearn-color-fitted-level-2);\n",
"}\n",
"\n",
"/* Estimator-specific style */\n",
"\n",
"/* Colorize estimator box */\n",
".sk-global div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
" /* unfitted */\n",
" background-color: var(--sklearn-color-unfitted-level-2);\n",
"}\n",
"\n",
".sk-global div.sk-estimator.fitted input.sk-toggleable__control:checked~label.sk-toggleable__label {\n",
" /* fitted */\n",
" background-color: var(--sklearn-color-fitted-level-2);\n",
"}\n",
"\n",
".sk-global div.sk-label label.sk-toggleable__label,\n",
".sk-global div.sk-label label {\n",
" /* The background is the default theme color */\n",
" color: var(--sklearn-color-text-on-default-background);\n",
"}\n",
"\n",
"/* On hover, darken the color of the background */\n",
".sk-global div.sk-label:hover label.sk-toggleable__label {\n",
" color: var(--sklearn-color-text);\n",
" background-color: var(--sklearn-color-unfitted-level-2);\n",
"}\n",
"\n",
"/* Label box, darken color on hover, fitted */\n",
".sk-global div.sk-label.fitted:hover label.sk-toggleable__label.fitted {\n",
" color: var(--sklearn-color-text);\n",
" background-color: var(--sklearn-color-fitted-level-2);\n",
"}\n",
"\n",
"/* Estimator label */\n",
"\n",
".sk-global div.sk-label label {\n",
" font-family: monospace;\n",
" font-weight: bold;\n",
" line-height: 1.2em;\n",
"}\n",
"\n",
".sk-global div.sk-label-container {\n",
" text-align: center;\n",
"}\n",
"\n",
"/* Estimator-specific */\n",
".sk-global div.sk-estimator {\n",
" font-family: monospace;\n",
" border: 1px dotted var(--sklearn-color-border-box);\n",
" border-radius: 0.25em;\n",
" box-sizing: border-box;\n",
" margin-bottom: 0.5em;\n",
" /* unfitted */\n",
" background-color: var(--sklearn-color-unfitted-level-0);\n",
"}\n",
"\n",
".sk-global div.sk-estimator.fitted {\n",
" /* fitted */\n",
" background-color: var(--sklearn-color-fitted-level-0);\n",
"}\n",
"\n",
"/* on hover */\n",
".sk-global div.sk-estimator:hover {\n",
" /* unfitted */\n",
" background-color: var(--sklearn-color-unfitted-level-2);\n",
"}\n",
"\n",
".sk-global div.sk-estimator.fitted:hover {\n",
" /* fitted */\n",
" background-color: var(--sklearn-color-fitted-level-2);\n",
"}\n",
"\n",
"/* Specification for estimator info (e.g. \"i\" and \"?\") */\n",
"\n",
"/* Common style for \"i\" and \"?\" */\n",
"\n",
".sk-estimator-doc-link,\n",
"a:link.sk-estimator-doc-link,\n",
"a:visited.sk-estimator-doc-link {\n",
" float: right;\n",
" font-size: smaller;\n",
" line-height: 1em;\n",
" font-family: monospace;\n",
" background-color: var(--sklearn-color-unfitted-level-0);\n",
" border-radius: 1em;\n",
" height: 1em;\n",
" width: 1em;\n",
" text-decoration: none !important;\n",
" margin-left: 0.5em;\n",
" text-align: center;\n",
" /* unfitted */\n",
" border: var(--sklearn-color-unfitted-level-3) 1pt solid;\n",
" color: var(--sklearn-color-unfitted-level-3);\n",
"}\n",
"\n",
".sk-estimator-doc-link.fitted,\n",
"a:link.sk-estimator-doc-link.fitted,\n",
"a:visited.sk-estimator-doc-link.fitted {\n",
" /* fitted */\n",
" background-color: var(--sklearn-color-fitted-level-0);\n",
" border: var(--sklearn-color-fitted-level-3) 1pt solid;\n",
" color: var(--sklearn-color-fitted-level-3);\n",
"}\n",
"\n",
"/* On hover */\n",
"div.sk-estimator:hover .sk-estimator-doc-link:hover,\n",
".sk-estimator-doc-link:hover,\n",
"div.sk-label-container:hover .sk-estimator-doc-link:hover,\n",
".sk-estimator-doc-link:hover {\n",
" /* unfitted */\n",
" background-color: var(--sklearn-color-unfitted-level-3);\n",
" border: var(--sklearn-color-fitted-level-0) 1pt solid;\n",
" color: var(--sklearn-color-unfitted-level-0);\n",
" text-decoration: none;\n",
"}\n",
"\n",
"div.sk-estimator.fitted:hover .sk-estimator-doc-link.fitted:hover,\n",
".sk-estimator-doc-link.fitted:hover,\n",
"div.sk-label-container:hover .sk-estimator-doc-link.fitted:hover,\n",
".sk-estimator-doc-link.fitted:hover {\n",
" /* fitted */\n",
" background-color: var(--sklearn-color-fitted-level-3);\n",
" border: var(--sklearn-color-fitted-level-0) 1pt solid;\n",
" color: var(--sklearn-color-fitted-level-0);\n",
" text-decoration: none;\n",
"}\n",
"\n",
"/* Span, style for the box shown on hovering the info icon */\n",
".sk-estimator-doc-link span {\n",
" display: none;\n",
" z-index: 9999;\n",
" position: relative;\n",
" font-weight: normal;\n",
" right: .2ex;\n",
" padding: .5ex;\n",
" margin: .5ex;\n",
" width: min-content;\n",
" min-width: 20ex;\n",
" max-width: 50ex;\n",
" color: var(--sklearn-color-text);\n",
" box-shadow: 2pt 2pt 4pt #999;\n",
" /* unfitted */\n",
" background: var(--sklearn-color-unfitted-level-0);\n",
" border: .5pt solid var(--sklearn-color-unfitted-level-3);\n",
"}\n",
"\n",
".sk-estimator-doc-link.fitted span {\n",
" /* fitted */\n",
" background: var(--sklearn-color-fitted-level-0);\n",
" border: var(--sklearn-color-fitted-level-3);\n",
"}\n",
"\n",
".sk-estimator-doc-link:hover span {\n",
" display: block;\n",
"}\n",
"\n",
"/* \"?\"-specific style due to the `<a>` HTML tag */\n",
"\n",
".sk-global a.estimator_doc_link {\n",
" float: right;\n",
" font-size: 1rem;\n",
" line-height: 1em;\n",
" font-family: monospace;\n",
" background-color: var(--sklearn-color-unfitted-level-0);\n",
" border-radius: 1rem;\n",
" height: 1rem;\n",
" width: 1rem;\n",
" text-decoration: none;\n",
" /* unfitted */\n",
" color: var(--sklearn-color-unfitted-level-1);\n",
" border: var(--sklearn-color-unfitted-level-1) 1pt solid;\n",
"}\n",
"\n",
".sk-global a.estimator_doc_link.fitted {\n",
" /* fitted */\n",
" background-color: var(--sklearn-color-fitted-level-0);\n",
" border: var(--sklearn-color-fitted-level-1) 1pt solid;\n",
" color: var(--sklearn-color-fitted-level-1);\n",
"}\n",
"\n",
"/* On hover */\n",
".sk-global a.estimator_doc_link:hover {\n",
" /* unfitted */\n",
" background-color: var(--sklearn-color-unfitted-level-3);\n",
" color: var(--sklearn-color-background);\n",
" text-decoration: none;\n",
"}\n",
"\n",
".sk-global a.estimator_doc_link.fitted:hover {\n",
" /* fitted */\n",
" background-color: var(--sklearn-color-fitted-level-3);\n",
"}\n",
"\n",
".sk-top-container.sk-global {\n",
" /* pydata-sphinx-theme hides overflow, so scrolling is disabled.\n",
" We need to set it to !important and add tabindex=\"0\" in the HTML\n",
" to allow keyboard-only users to navigate the display. */\n",
" overflow-x: scroll !important;\n",
" max-width: 100%;\n",
"}\n",
"\n",
".estimator-table {\n",
" font-family: monospace;\n",
"}\n",
"\n",
".estimator-table summary {\n",
" padding: .5rem;\n",
" cursor: pointer;\n",
"}\n",
"\n",
".estimator-table summary::marker {\n",
" font-size: 0.7rem;\n",
"}\n",
"\n",
".estimator-table details[open] {\n",
" padding-left: 0.1rem;\n",
" padding-right: 0.1rem;\n",
" padding-bottom: 0.3rem;\n",
"}\n",
"\n",
".estimator-table .parameters-table {\n",
" margin-left: auto !important;\n",
" margin-right: auto !important;\n",
" margin-top: 0;\n",
"}\n",
"\n",
".estimator-table .parameters-table tr:nth-child(odd) {\n",
" background-color: #fff;\n",
"}\n",
"\n",
".estimator-table .parameters-table tr:nth-child(even) {\n",
" background-color: #f6f6f6;\n",
"}\n",
"\n",
".estimator-table .parameters-table tr:hover td {\n",
" background-color: #e0e0e0;\n",
"}\n",
"\n",
".estimator-table table :is(td, th) {\n",
" border: 1px solid rgba(106, 105, 104, 0.232);\n",
"}\n",
"\n",
"/*\n",
" `table td`is set in notebook with right text-align.\n",
" We need to overwrite it.\n",
"*/\n",
".estimator-table table td.param {\n",
" text-align: left;\n",
" position: relative;\n",
" padding: 0;\n",
"}\n",
"\n",
".user-set td {\n",
" color:rgb(255, 94, 0);\n",
" text-align: left !important;\n",
"}\n",
"\n",
".user-set td.value {\n",
" color:rgb(255, 94, 0);\n",
" background-color: transparent;\n",
"}\n",
"\n",
".default td, .estimator-table th {\n",
" color: black;\n",
" text-align: left !important;\n",
"}\n",
"\n",
".user-set td i,\n",
".default td i {\n",
" color: black;\n",
"}\n",
"\n",
"td.fitted-att-type {\n",
" white-space: preserve nowrap;\n",
"}\n",
"\n",
"/*\n",
" Styles for parameter documentation links\n",
" We need styling for visited so jupyter doesn't overwrite it\n",
"*/\n",
"a.param-doc-link,\n",
"a.param-doc-link:link,\n",
"a.param-doc-link:visited {\n",
" text-decoration: underline dashed;\n",
" text-underline-offset: .3em;\n",
" color: inherit;\n",
" display: block;\n",
" padding: .5em;\n",
"}\n",
"\n",
"@supports(anchor-name: --doc-link) {\n",
" a.param-doc-link,\n",
" a.param-doc-link:link,\n",
" a.param-doc-link:visited {\n",
" anchor-name: --doc-link;\n",
" }\n",
"}\n",
"\n",
"/* \"hack\" to make the entire area of the cell containing the link clickable */\n",
"a.param-doc-link::before {\n",
" position: absolute;\n",
" content: \"\";\n",
" inset: 0;\n",
"}\n",
"\n",
".param-doc-description {\n",
" display: none;\n",
" position: absolute;\n",
" z-index: 9999;\n",
" left: 0;\n",
" padding: .5ex;\n",
" margin-left: 1.5em;\n",
" color: var(--sklearn-color-text);\n",
" box-shadow: .3em .3em .4em #999;\n",
" width: max-content;\n",
" text-align: left;\n",
" max-height: 10em;\n",
" overflow-y: auto;\n",
"\n",
" /* unfitted */\n",
" background: var(--sklearn-color-unfitted-level-0);\n",
" border: thin solid var(--sklearn-color-unfitted-level-3);\n",
"}\n",
"\n",
"@supports(position-area: center right) {\n",
" .param-doc-description {\n",
" position-area: center right;\n",
" position: fixed;\n",
" margin-left: 0;\n",
" }\n",
"}\n",
"\n",
"/* Fitted state for parameter tooltips */\n",
".fitted .param-doc-description {\n",
" /* fitted */\n",
" background: var(--sklearn-color-fitted-level-0);\n",
" border: thin solid var(--sklearn-color-fitted-level-3);\n",
"}\n",
"\n",
".param-doc-link:hover .param-doc-description {\n",
" display: block;\n",
"}\n",
"\n",
".copy-paste-icon {\n",
" background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NDggNTEyIj48IS0tIUZvbnQgQXdlc29tZSBGcmVlIDYuNy4yIGJ5IEBmb250YXdlc29tZSAtIGh0dHBzOi8vZm9udGF3ZXNvbWUuY29tIExpY2Vuc2UgLSBodHRwczovL2ZvbnRhd2Vzb21lLmNvbS9saWNlbnNlL2ZyZWUgQ29weXJpZ2h0IDIwMjUgRm9udGljb25zLCBJbmMuLS0+PHBhdGggZD0iTTIwOCAwTDMzMi4xIDBjMTIuNyAwIDI0LjkgNS4xIDMzLjkgMTQuMWw2Ny45IDY3LjljOSA5IDE0LjEgMjEuMiAxNC4xIDMzLjlMNDQ4IDMzNmMwIDI2LjUtMjEuNSA0OC00OCA0OGwtMTkyIDBjLTI2LjUgMC00OC0yMS41LTQ4LTQ4bDAtMjg4YzAtMjYuNSAyMS41LTQ4IDQ4LTQ4ek00OCAxMjhsODAgMCAwIDY0LTY0IDAgMCAyNTYgMTkyIDAgMC0zMiA2NCAwIDAgNDhjMCAyNi41LTIxLjUgNDgtNDggNDhMNDggNTEyYy0yNi41IDAtNDgtMjEuNS00OC00OEwwIDE3NmMwLTI2LjUgMjEuNS00OCA0OC00OHoiLz48L3N2Zz4=);\n",
" background-repeat: no-repeat;\n",
" background-size: 14px 14px;\n",
" background-position: 0;\n",
" display: inline-block;\n",
" width: 14px;\n",
" height: 14px;\n",
" cursor: pointer;\n",
" border: none;\n",
" padding: 0;\n",
" background-color: transparent;\n",
"}\n",
"\n",
".copy-paste-icon:focus-visible {\n",
" outline: 1px solid currentColor;\n",
" outline-offset: 1px;\n",
"}\n",
"\n",
".features {\n",
" font-family: monospace;\n",
" cursor: pointer;\n",
" background-color: var(--sklearn-color-unfitted-level-0);\n",
" border: 1px dotted var(--sklearn-color-border-box);\n",
" border-radius: .20em;\n",
" margin-bottom: 0.5em;\n",
" font-size: inherit; /* Needed for jupyter */\n",
"}\n",
"\n",
".features.fitted {\n",
" background-color: var(--sklearn-color-fitted-level-0);\n",
"}\n",
"\n",
".features summary {\n",
" cursor: pointer;\n",
" display: flex;\n",
" margin-bottom: 0;\n",
" text-align: center;\n",
" align-items: center;\n",
" justify-content: center;\n",
" gap: 0.5em;\n",
" padding: .25em;\n",
"}\n",
"\n",
".features details[open] > summary {\n",
" color: var(--sklearn-color-text);\n",
" background-color: var(--sklearn-color-unfitted-level-2);\n",
" border-radius: .20em 0 0 0;\n",
"}\n",
"\n",
".features.fitted details[open] > summary {\n",
" background-color: var(--sklearn-color-fitted-level-2);\n",
" border-radius: .20em 0 0 0;\n",
"}\n",
"\n",
".features details > summary .arrow::before {\n",
" content: \"▸\";\n",
" color: grey;\n",
"}\n",
"\n",
".features details[open] > summary .arrow::before {\n",
" content: \"▾\";\n",
"}\n",
"\n",
".features details:hover > summary {\n",
" margin: 0;\n",
" background-color: var(--sklearn-color-unfitted-level-2);\n",
"}\n",
"\n",
".features.fitted details:hover > summary {\n",
" margin: 0;\n",
" background-color: var(--sklearn-color-fitted-level-2);\n",
"}\n",
"\n",
".features .features-container {\n",
" max-height: 10em;\n",
" overflow: auto;\n",
" scrollbar-width: thin;\n",
" padding: .25em 0.1rem;\n",
" background-color: var(--sklearn-color-unfitted-level-0);\n",
" border-radius: 0 0 .5em .5em;\n",
"}\n",
"\n",
".features.fitted .features-container {\n",
" background-color: var(--sklearn-color-fitted-level-0);\n",
"}\n",
"\n",
".features .image-container {\n",
" block-size: 1em;\n",
" inline-size: 1em;\n",
" padding: 0;\n",
" margin: 0%;\n",
" display: flex;\n",
" justify-content: center;\n",
" align-items: center;\n",
"}\n",
"\n",
".features .copy-paste-icon {\n",
" background-size: 1em 1em;\n",
" width: 1em;\n",
" height: 1em;\n",
" filter: grayscale(100%) opacity(60%);\n",
"}\n",
"\n",
".features .features-container table {\n",
" width: 100%;\n",
" margin: 0.01em;\n",
"}\n",
"\n",
".features .features-container table tr:nth-child(odd) {\n",
" background-color: #fff;\n",
"}\n",
"\n",
".features .features-container table tr:nth-child(even) {\n",
" background-color: #f6f6f6;\n",
"}\n",
"\n",
".features .features-container table tr:hover {\n",
" background-color: #e0e0e0;\n",
"}\n",
"\n",
".features .features-container table {\n",
" table-layout: inherit;\n",
"}\n",
"\n",
".features .features-container table td {\n",
" text-align: left;\n",
" padding: 0 0.5em;\n",
" border: 1px solid rgba(106, 105, 104, 0.232);\n",
" white-space: nowrap;\n",
" color: var(--sklearn-color-text);\n",
"}\n",
"\n",
".total_features {\n",
" display: flex;\n",
" justify-content: center;\n",
" margin-top: 0.5em;\n",
"}\n",
"</style><body><div id=\"sk-container-id-3\" tabindex=\"0\" class=\"sk-top-container sk-global\"><div class=\"sk-text-repr-fallback\"><pre>LinearSVC()</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator fitted sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually sk-global\" id=\"sk-estimator-id-3\" type=\"checkbox\" checked><label for=\"sk-estimator-id-3\" class=\"sk-toggleable__label fitted sk-toggleable__label-arrow\"><div><div>LinearSVC</div></div><div><a class=\"sk-estimator-doc-link fitted\" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html\">?<span>Documentation for LinearSVC</span></a><span class=\"sk-estimator-doc-link fitted\">i<span>Fitted</span></span></div></label><div class=\"sk-toggleable__content fitted\" data-param-prefix=\"\">\n",
" <div class=\"estimator-table\">\n",
" <details>\n",
" <summary>Parameters</summary>\n",
" <table class=\"parameters-table\">\n",
" <tbody>\n",
" \n",
" <tr class=\"default\">\n",
" <td><button type=\"button\" class=\"copy-paste-icon\"\n",
" aria-label=\"Copy penalty to clipboard\"\n",
" onclick=\"copyToClipboard('penalty',\n",
" this.parentElement.nextElementSibling)\"\n",
" ></button></td>\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-penalty;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=penalty,-%7B%27l1%27%2C%20%27l2%27%7D%2C%20default%3D%27l2%27\">\n",
" penalty\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-penalty;\">\n",
" penalty: {&#x27;l1&#x27;, &#x27;l2&#x27;}, default=&#x27;l2&#x27;<br><br>Specifies the norm used in the penalization. The &#x27;l2&#x27;<br>penalty is the standard used in SVC. The &#x27;l1&#x27; leads to ``coef_``<br>vectors that are sparse.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"value\">&#x27;l2&#x27;</td>\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td><button type=\"button\" class=\"copy-paste-icon\"\n",
" aria-label=\"Copy loss to clipboard\"\n",
" onclick=\"copyToClipboard('loss',\n",
" this.parentElement.nextElementSibling)\"\n",
" ></button></td>\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-loss;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=loss,-%7B%27hinge%27%2C%20%27squared_hinge%27%7D%2C%20default%3D%27squared_hinge%27\">\n",
" loss\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-loss;\">\n",
" loss: {&#x27;hinge&#x27;, &#x27;squared_hinge&#x27;}, default=&#x27;squared_hinge&#x27;<br><br>Specifies the loss function. &#x27;hinge&#x27; is the standard SVM loss<br>(used e.g. by the SVC class) while &#x27;squared_hinge&#x27; is the<br>square of the hinge loss. The combination of ``penalty=&#x27;l1&#x27;``<br>and ``loss=&#x27;hinge&#x27;`` is not supported.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"value\">&#x27;squared_hinge&#x27;</td>\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td><button type=\"button\" class=\"copy-paste-icon\"\n",
" aria-label=\"Copy dual to clipboard\"\n",
" onclick=\"copyToClipboard('dual',\n",
" this.parentElement.nextElementSibling)\"\n",
" ></button></td>\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-dual;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=dual,-%22auto%22%20or%20bool%2C%20default%3D%22auto%22\">\n",
" dual\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-dual;\">\n",
" dual: &quot;auto&quot; or bool, default=&quot;auto&quot;<br><br>Select the algorithm to either solve the dual or primal<br>optimization problem. Prefer dual=False when n_samples &gt; n_features.<br>`dual=&quot;auto&quot;` will choose the value of the parameter automatically,<br>based on the values of `n_samples`, `n_features`, `loss`, `multi_class`<br>and `penalty`. If `n_samples` &lt; `n_features` and optimizer supports<br>chosen `loss`, `multi_class` and `penalty`, then dual will be set to True,<br>otherwise it will be set to False.<br><br>.. versionchanged:: 1.3<br> The `&quot;auto&quot;` option is added in version 1.3 and will be the default<br> in version 1.5.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"value\">&#x27;auto&#x27;</td>\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td><button type=\"button\" class=\"copy-paste-icon\"\n",
" aria-label=\"Copy tol to clipboard\"\n",
" onclick=\"copyToClipboard('tol',\n",
" this.parentElement.nextElementSibling)\"\n",
" ></button></td>\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-tol;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=tol,-float%2C%20default%3D1e-4\">\n",
" tol\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-tol;\">\n",
" tol: float, default=1e-4<br><br>Tolerance for stopping criteria.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"value\">0.0001</td>\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td><button type=\"button\" class=\"copy-paste-icon\"\n",
" aria-label=\"Copy C to clipboard\"\n",
" onclick=\"copyToClipboard('C',\n",
" this.parentElement.nextElementSibling)\"\n",
" ></button></td>\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-C;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=C,-float%2C%20default%3D1.0\">\n",
" C\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-C;\">\n",
" C: float, default=1.0<br><br>Regularization parameter. The strength of the regularization is<br>inversely proportional to C. Must be strictly positive.<br>For an intuitive visualization of the effects of scaling<br>the regularization parameter C, see<br>:ref:`sphx_glr_auto_examples_svm_plot_svm_scale_c.py`.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"value\">1.0</td>\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td><button type=\"button\" class=\"copy-paste-icon\"\n",
" aria-label=\"Copy multi_class to clipboard\"\n",
" onclick=\"copyToClipboard('multi_class',\n",
" this.parentElement.nextElementSibling)\"\n",
" ></button></td>\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-multi_class;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=multi_class,-%7B%27ovr%27%2C%20%27crammer_singer%27%7D%2C%20default%3D%27ovr%27\">\n",
" multi_class\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-multi_class;\">\n",
" multi_class: {&#x27;ovr&#x27;, &#x27;crammer_singer&#x27;}, default=&#x27;ovr&#x27;<br><br>Determines the multi-class strategy if `y` contains more than<br>two classes.<br>``&quot;ovr&quot;`` trains n_classes one-vs-rest classifiers, while<br>``&quot;crammer_singer&quot;`` optimizes a joint objective over all classes.<br>While `crammer_singer` is interesting from a theoretical perspective<br>as it is consistent, it is seldom used in practice as it rarely leads<br>to better accuracy and is more expensive to compute.<br>If ``&quot;crammer_singer&quot;`` is chosen, the options loss, penalty and dual<br>will be ignored.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"value\">&#x27;ovr&#x27;</td>\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td><button type=\"button\" class=\"copy-paste-icon\"\n",
" aria-label=\"Copy fit_intercept to clipboard\"\n",
" onclick=\"copyToClipboard('fit_intercept',\n",
" this.parentElement.nextElementSibling)\"\n",
" ></button></td>\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-fit_intercept;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=fit_intercept,-bool%2C%20default%3DTrue\">\n",
" fit_intercept\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-fit_intercept;\">\n",
" fit_intercept: bool, default=True<br><br>Whether or not to fit an intercept. If set to True, the feature vector<br>is extended to include an intercept term: `[x_1, ..., x_n, 1]`, where<br>1 corresponds to the intercept. If set to False, no intercept will be<br>used in calculations (i.e. data is expected to be already centered).</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"value\">True</td>\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td><button type=\"button\" class=\"copy-paste-icon\"\n",
" aria-label=\"Copy intercept_scaling to clipboard\"\n",
" onclick=\"copyToClipboard('intercept_scaling',\n",
" this.parentElement.nextElementSibling)\"\n",
" ></button></td>\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-intercept_scaling;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=intercept_scaling,-float%2C%20default%3D1.0\">\n",
" intercept_scaling\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-intercept_scaling;\">\n",
" intercept_scaling: float, default=1.0<br><br>When `fit_intercept` is True, the instance vector x becomes ``[x_1,<br>..., x_n, intercept_scaling]``, i.e. a &quot;synthetic&quot; feature with a<br>constant value equal to `intercept_scaling` is appended to the instance<br>vector. The intercept becomes intercept_scaling * synthetic feature<br>weight. Note that liblinear internally penalizes the intercept,<br>treating it like any other term in the feature vector. To reduce the<br>impact of the regularization on the intercept, the `intercept_scaling`<br>parameter can be set to a value greater than 1; the higher the value of<br>`intercept_scaling`, the lower the impact of regularization on it.<br>Then, the weights become `[w_x_1, ..., w_x_n,<br>w_intercept*intercept_scaling]`, where `w_x_1, ..., w_x_n` represent<br>the feature weights and the intercept weight is scaled by<br>`intercept_scaling`. This scaling allows the intercept term to have a<br>different regularization behavior compared to the other features.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"value\">1</td>\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td><button type=\"button\" class=\"copy-paste-icon\"\n",
" aria-label=\"Copy class_weight to clipboard\"\n",
" onclick=\"copyToClipboard('class_weight',\n",
" this.parentElement.nextElementSibling)\"\n",
" ></button></td>\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-class_weight;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=class_weight,-dict%20or%20%27balanced%27%2C%20default%3DNone\">\n",
" class_weight\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-class_weight;\">\n",
" class_weight: dict or &#x27;balanced&#x27;, default=None<br><br>Set the parameter C of class i to ``class_weight[i]*C`` for<br>SVC. If not given, all classes are supposed to have<br>weight one.<br>The &quot;balanced&quot; mode uses the values of y to automatically adjust<br>weights inversely proportional to class frequencies in the input data<br>as ``n_samples / (n_classes * np.bincount(y))``.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"value\">None</td>\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td><button type=\"button\" class=\"copy-paste-icon\"\n",
" aria-label=\"Copy verbose to clipboard\"\n",
" onclick=\"copyToClipboard('verbose',\n",
" this.parentElement.nextElementSibling)\"\n",
" ></button></td>\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-verbose;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=verbose,-int%2C%20default%3D0\">\n",
" verbose\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-verbose;\">\n",
" verbose: int, default=0<br><br>Enable verbose output. Note that this setting takes advantage of a<br>per-process runtime setting in liblinear that, if enabled, may not work<br>properly in a multithreaded context.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"value\">0</td>\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td><button type=\"button\" class=\"copy-paste-icon\"\n",
" aria-label=\"Copy random_state to clipboard\"\n",
" onclick=\"copyToClipboard('random_state',\n",
" this.parentElement.nextElementSibling)\"\n",
" ></button></td>\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-random_state;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=random_state,-int%2C%20RandomState%20instance%20or%20None%2C%20default%3DNone\">\n",
" random_state\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-random_state;\">\n",
" random_state: int, RandomState instance or None, default=None<br><br>Controls the pseudo random number generation for shuffling the data for<br>the dual coordinate descent (if ``dual=True``). When ``dual=False`` the<br>underlying implementation of :class:`LinearSVC` is not random and<br>``random_state`` has no effect on the results.<br>Pass an int for reproducible output across multiple function calls.<br>See :term:`Glossary &lt;random_state&gt;`.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"value\">None</td>\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td><button type=\"button\" class=\"copy-paste-icon\"\n",
" aria-label=\"Copy max_iter to clipboard\"\n",
" onclick=\"copyToClipboard('max_iter',\n",
" this.parentElement.nextElementSibling)\"\n",
" ></button></td>\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-max_iter;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=max_iter,-int%2C%20default%3D1000\">\n",
" max_iter\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-max_iter;\">\n",
" max_iter: int, default=1000<br><br>The maximum number of iterations to be run.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"value\">1000</td>\n",
" </tr>\n",
" \n",
" </tbody>\n",
" </table>\n",
" </details>\n",
" </div>\n",
" \n",
" <div class=\"estimator-table\">\n",
" <details>\n",
" <summary>Fitted attributes</summary>\n",
" <table class=\"parameters-table\">\n",
" <tbody>\n",
" <tr>\n",
" <th>Name</th>\n",
" <th>Type</th>\n",
" <th>Value</th>\n",
" </tr>\n",
" \n",
" <tr class=\"default\">\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-classes_;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=classes_,-ndarray%20of%20shape%20%28n_classes%2C%29\">\n",
" classes_\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-classes_;\">\n",
" classes_: ndarray of shape (n_classes,)<br><br>The unique classes labels.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"fitted-att-type\">ndarray[float64](3,)</td>\n",
" <td>[0.,1.,2.]</td>\n",
"\n",
"\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-coef_;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=coef_,-ndarray%20of%20shape%20%281%2C%20n_features%29%20if%20n_classes%20%3D%3D%202%20%20%20%20%20%20%20%20%20%20%20%20%20else%20%28n_classes%2C%20n_features%29\">\n",
" coef_\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-coef_;\">\n",
" coef_: ndarray of shape (1, n_features) if n_classes == 2 else (n_classes, n_features)<br><br>Weights assigned to the features (coefficients in the primal<br>problem).<br><br>``coef_`` is a readonly property derived from ``raw_coef_`` that<br>follows the internal memory layout of liblinear.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"fitted-att-type\">ndarray[float64](3, 2)</td>\n",
" <td>[[-1.54, 2.28],\n",
" [ 0.1 ,-0.98],\n",
" [ 0.66,-0.35]]</td>\n",
"\n",
"\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-intercept_;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=intercept_,-ndarray%20of%20shape%20%281%2C%29%20if%20n_classes%20%3D%3D%202%20else%20%28n_classes%2C%29\">\n",
" intercept_\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-intercept_;\">\n",
" intercept_: ndarray of shape (1,) if n_classes == 2 else (n_classes,)<br><br>Constants in decision function.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"fitted-att-type\">ndarray[float64](3,)</td>\n",
" <td>[ 1.2 , 2.02,-3.14]</td>\n",
"\n",
"\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-n_features_in_;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=n_features_in_,-int\">\n",
" n_features_in_\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-n_features_in_;\">\n",
" n_features_in_: int<br><br>Number of features seen during :term:`fit`.<br><br>.. versionadded:: 0.24</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"fitted-att-type\">int</td>\n",
" <td>2</td>\n",
"\n",
"\n",
" </tr>\n",
" \n",
"\n",
" <tr class=\"default\">\n",
" <td class=\"param\">\n",
" <a class=\"param-doc-link\"\n",
" style=\"anchor-name: --doc-link-n_iter_;\"\n",
" rel=\"noreferrer\" target=\"_blank\" href=\"https://scikit-learn.org/1.9/modules/generated/sklearn.svm.LinearSVC.html#:~:text=n_iter_,-int\">\n",
" n_iter_\n",
" <span class=\"param-doc-description\"\n",
" style=\"position-anchor: --doc-link-n_iter_;\">\n",
" n_iter_: int<br><br>Maximum number of iterations run across all classes.</span>\n",
" </a>\n",
" </td>\n",
" <td class=\"fitted-att-type\">int</td>\n",
" <td>8</td>\n",
"\n",
"\n",
" </tr>\n",
" \n",
" </tbody>\n",
" </table>\n",
" </details>\n",
" </div>\n",
" </div></div></div></div></div><script>/* Authors: The scikit-learn developers\n",
" SPDX-License-Identifier: BSD-3-Clause\n",
"*/\n",
"\n",
"function copyToClipboard(text, element) {\n",
" // Get the parameter prefix from the closest toggleable content\n",
" const toggleableContent = element.closest('.sk-toggleable__content');\n",
" const paramPrefix = toggleableContent ? toggleableContent.dataset.paramPrefix : '';\n",
" const fullParamName = paramPrefix ? `${paramPrefix}${text}` : text;\n",
"\n",
" const originalStyle = element.style;\n",
" const computedStyle = window.getComputedStyle(element);\n",
" const originalWidth = computedStyle.width;\n",
" const originalHTML = element.innerHTML.replace('Copied!', '');\n",
"\n",
" navigator.clipboard.writeText(fullParamName)\n",
" .then(() => {\n",
" element.style.width = originalWidth;\n",
" element.style.color = 'green';\n",
" element.innerHTML = \"Copied!\";\n",
"\n",
" setTimeout(() => {\n",
" element.innerHTML = originalHTML;\n",
" element.style = originalStyle;\n",
" }, 2000);\n",
" })\n",
" .catch(err => {\n",
" console.error('Failed to copy:', err);\n",
" element.style.color = 'red';\n",
" element.innerHTML = \"Failed!\";\n",
" setTimeout(() => {\n",
" element.innerHTML = originalHTML;\n",
" element.style = originalStyle;\n",
" }, 2000);\n",
" });\n",
" return false;\n",
"}\n",
"\n",
"document.querySelectorAll('.copy-paste-icon').forEach(function(element) {\n",
" const toggleableContent = element.closest('.sk-toggleable__content');\n",
" const paramPrefix = toggleableContent ? toggleableContent.dataset.paramPrefix : '';\n",
"\n",
" const parent = element.parentElement;\n",
" if (!parent || !parent.nextElementSibling) {\n",
" console.warn('Expected copy-paste icon is missing from the DOM structure');\n",
" return;\n",
" }\n",
"\n",
" const paramName = element.parentElement.nextElementSibling\n",
" .textContent.trim().split(' ')[0];\n",
" const fullParamName = paramPrefix ? `${paramPrefix}${paramName}` : paramName;\n",
"\n",
" element.setAttribute('title', fullParamName);\n",
"});\n",
"\n",
"/**\n",
" * Copy the list of feature names formatted as a Python list.\n",
" *\n",
" * @param {HTMLElement} element - The copy button inside a `.features` block; its siblings\n",
" * contain a `details` element and a table containing feature named.\n",
" * @returns {boolean} Always returns `false` so callers can prevent the default click behavior.\n",
" */\n",
"function copyFeatureNamesToClipboard(element) {\n",
" var detailsElem = element.closest('.features').querySelector('details');\n",
" var wasOpen = detailsElem.open;\n",
" detailsElem.open = true;\n",
" var content = element.closest('.features').querySelector('tbody')\n",
" .innerText.trim();\n",
" if (!wasOpen) detailsElem.open = false;\n",
" const rows = content.split('\\n').map(row => ` \"${row}\"`);\n",
" const formattedText = `[\\n${rows.join(',\\n')},\\n]`;\n",
" const originalHTML = element.innerHTML.replace('✔', '');\n",
" const originalStyle = element.style;\n",
" const copyMark = document.createElement('span');\n",
" copyMark.innerHTML = '✔';\n",
" copyMark.style.color = 'blue';\n",
" copyMark.style.fontSize = '1em';\n",
"\n",
" navigator.clipboard.writeText(formattedText)\n",
" .then(() => {\n",
" element.style.display = 'none';\n",
" element.parentElement.appendChild(copyMark);\n",
"\n",
" setTimeout(() => {\n",
" copyMark.remove();\n",
" element.innerHTML = originalHTML;\n",
" element.style = originalStyle;\n",
" }, 1000);\n",
" })\n",
" .catch(err => {\n",
" console.error('Failed to copy:', err);\n",
" element.style.color = 'orange';\n",
" element.innerHTML = \"Failed!\";\n",
" setTimeout(() => {\n",
" element.innerHTML = originalHTML;\n",
" element.style = originalStyle;\n",
" }, 1000);\n",
" });\n",
" return false;\n",
"}\n",
"/**\n",
" * Adapted from Skrub\n",
" * https://github.com/skrub-data/skrub/blob/403466d1d5d4dc76a7ef569b3f8228db59a31dc3/skrub/_reporting/_data/templates/report.js#L789\n",
" * @returns \"light\" or \"dark\"\n",
" */\n",
"function detectTheme(element) {\n",
" const body = document.querySelector('body');\n",
"\n",
" // Check VSCode theme\n",
" const themeKindAttr = body.getAttribute('data-vscode-theme-kind');\n",
" const themeNameAttr = body.getAttribute('data-vscode-theme-name');\n",
"\n",
" if (themeKindAttr && themeNameAttr) {\n",
" const themeKind = themeKindAttr.toLowerCase();\n",
" const themeName = themeNameAttr.toLowerCase();\n",
"\n",
" if (themeKind.includes(\"dark\") || themeName.includes(\"dark\")) {\n",
" return \"dark\";\n",
" }\n",
" if (themeKind.includes(\"light\") || themeName.includes(\"light\")) {\n",
" return \"light\";\n",
" }\n",
" }\n",
"\n",
" // Check Jupyter theme\n",
" if (body.getAttribute('data-jp-theme-light') === 'false') {\n",
" return 'dark';\n",
" } else if (body.getAttribute('data-jp-theme-light') === 'true') {\n",
" return 'light';\n",
" }\n",
"\n",
" // Guess based on a parent element's color\n",
" const color = window.getComputedStyle(element.parentNode, null).getPropertyValue('color');\n",
" const match = color.match(/^rgb\\s*\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)\\s*$/i);\n",
" if (match) {\n",
" const [r, g, b] = [\n",
" parseFloat(match[1]),\n",
" parseFloat(match[2]),\n",
" parseFloat(match[3])\n",
" ];\n",
"\n",
" // https://en.wikipedia.org/wiki/HSL_and_HSV#Lightness\n",
" const luma = 0.299 * r + 0.587 * g + 0.114 * b;\n",
"\n",
" if (luma > 180) {\n",
" // If the text is very bright we have a dark theme\n",
" return 'dark';\n",
" }\n",
" if (luma < 75) {\n",
" // If the text is very dark we have a light theme\n",
" return 'light';\n",
" }\n",
" // Otherwise fall back to the next heuristic.\n",
" }\n",
"\n",
" // Fallback to system preference\n",
" return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';\n",
"}\n",
"\n",
"\n",
"function forceTheme(elementId) {\n",
" const estimatorElement = document.querySelector(`#${elementId}`);\n",
" if (estimatorElement === null) {\n",
" console.error(`Element with id ${elementId} not found.`);\n",
" } else {\n",
" const theme = detectTheme(estimatorElement);\n",
" estimatorElement.classList.add(theme);\n",
" }\n",
"}\n",
"\n",
"forceTheme('sk-container-id-3');</script></body>"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 30
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-10-01T14:23:11.380597900Z",
"start_time": "2026-10-01T14:23:11.187662800Z"
}
},
"cell_type": "code",
"source": [
"y = clf.predict(two_features)\n",
"print(y)"
],
"id": "2e0e66f9f3a60d87",
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 1. 0. 0. 0. 0. 0. 0.\n",
" 0. 0. 2. 2. 2. 1. 2. 1. 2. 1. 2. 1. 1. 2. 1. 2. 1. 2. 1. 1. 1. 1. 2. 1.\n",
" 1. 1. 2. 2. 2. 2. 2. 1. 1. 1. 1. 1. 0. 0. 2. 1. 1. 1. 1. 2. 1. 1. 1. 1.\n",
" 1. 2. 1. 1. 2. 1. 2. 2. 2. 2. 1. 2. 2. 2. 2. 2. 2. 1. 1. 2. 2. 2. 2. 1.\n",
" 2. 1. 2. 2. 2. 2. 2. 2. 2. 2. 2. 2. 2. 2. 1. 2. 2. 2. 2. 2. 2. 2. 1. 2.\n",
" 2. 2. 1. 2. 2. 2.]\n"
]
}
],
"execution_count": 31
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-10-01T14:26:59.459276400Z",
"start_time": "2026-10-01T14:26:59.386191100Z"
}
},
"cell_type": "code",
"source": "index = y==T",
"id": "ea068a1b9d64787d",
"outputs": [],
"execution_count": 39
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-10-01T14:38:15.112322Z",
"start_time": "2026-10-01T14:38:14.936347100Z"
}
},
"cell_type": "code",
"source": "two_features.shape",
"id": "80e4213e33d6c2",
"outputs": [
{
"data": {
"text/plain": [
"(150, 2)"
]
},
"execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 58
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-10-01T14:38:20.409051600Z",
"start_time": "2026-10-01T14:38:20.245872400Z"
}
},
"cell_type": "code",
"source": "T.T.shape",
"id": "8f18658e9536dcf0",
"outputs": [
{
"data": {
"text/plain": [
"(150,)"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 59
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-10-01T14:38:42.682356Z",
"start_time": "2026-10-01T14:38:42.348831900Z"
}
},
"cell_type": "code",
"source": "np.concatenate((two_features, T), axis=1)",
"id": "68d556d64d2ad82f",
"outputs": [
{
"ename": "ValueError",
"evalue": "all the input arrays must have same number of dimensions, but the array at index 0 has 2 dimension(s) and the array at index 1 has 1 dimension(s)",
"output_type": "error",
"traceback": [
"\u001B[31m---------------------------------------------------------------------------\u001B[39m",
"\u001B[31mValueError\u001B[39m Traceback (most recent call last)",
"\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[62]\u001B[39m\u001B[32m, line 1\u001B[39m\n\u001B[32m----> \u001B[39m\u001B[32m1\u001B[39m np.concatenate((two_features, T), axis=\u001B[32m1\u001B[39m)\n",
"\u001B[31mValueError\u001B[39m: all the input arrays must have same number of dimensions, but the array at index 0 has 2 dimension(s) and the array at index 1 has 1 dimension(s)"
]
}
],
"execution_count": 62
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-10-01T14:28:17.348307800Z",
"start_time": "2026-10-01T14:28:17.266740100Z"
}
},
"cell_type": "code",
"source": "two_features[:,index==False]",
"id": "3906d80d8bb319ee",
"outputs": [
{
"data": {
"text/plain": [
"array([[4.5, 7. , 6.4, 6.9, 6.5, 6.3, 6.6, 5.9, 6.1, 6.7, 5.9, 6.4, 6.6,\n",
" 6.8, 6.7, 6. , 5.4, 6. , 6.7, 6.1, 6.2, 5.8, 4.9, 5.7, 5.8, 6. ,\n",
" 5.6, 6.1, 5.8, 6.3],\n",
" [2.3, 3.2, 3.2, 3.1, 2.8, 3.3, 2.9, 3. , 2.9, 3.1, 3.2, 2.9, 3. ,\n",
" 2.8, 3. , 2.9, 3. , 3.4, 3.1, 3. , 2.9, 2.7, 2.5, 2.5, 2.8, 2.2,\n",
" 2.8, 2.6, 2.7, 2.5],\n",
" [1.3, 4.7, 4.5, 4.9, 4.6, 4.7, 4.6, 4.2, 4.7, 4.4, 4.8, 4.3, 4.4,\n",
" 4.8, 5. , 4.5, 4.5, 4.5, 4.7, 4.6, 4.3, 5.1, 4.5, 5. , 5.1, 5. ,\n",
" 4.9, 5.6, 5.1, 5. ],\n",
" [0.3, 1.4, 1.5, 1.5, 1.5, 1.6, 1.3, 1.5, 1.4, 1.4, 1.8, 1.3, 1.4,\n",
" 1.4, 1.7, 1.5, 1.5, 1.6, 1.5, 1.4, 1.3, 1.9, 1.7, 2. , 2.4, 1.5,\n",
" 2. , 1.4, 1.9, 1.9]])"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 43
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2026-10-01T14:26:05.035597400Z",
"start_time": "2026-10-01T14:26:04.961584600Z"
}
},
"cell_type": "code",
"source": "",
"id": "93e92a26c6f8690b",
"outputs": [
{
"data": {
"text/plain": [
"array([[4.9, 4.6],\n",
" [3. , 3.1],\n",
" [1.4, 1.5],\n",
" [0.2, 0.2]])"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 38
},
{
"metadata": {},
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": "",
"id": "f8fd7c58418b5620"
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}