1
0
mirror of https://github.com/gsi-upm/sitc synced 2024-11-21 22:12:30 +00:00

updated notebooks

This commit is contained in:
Carlos A. Iglesias 2019-02-28 11:32:00 +01:00
parent e824fd8fed
commit f9965fdbcd
9 changed files with 369 additions and 719 deletions

View File

@ -18,7 +18,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © 2016 Carlos A. Iglesias" "Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © Carlos A. Iglesias"
] ]
}, },
{ {
@ -82,7 +82,7 @@
"## Licence\n", "## Licence\n",
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n", "The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
"\n", "\n",
2016 Carlos A. Iglesias, Universidad Politécnica de Madrid." "© Carlos A. Iglesias, Universidad Politécnica de Madrid."
] ]
} }
], ],
@ -102,9 +102,26 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.2" "version": "3.5.5"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -18,7 +18,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © 2016 Carlos A. Iglesias" "Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © Carlos A. Iglesias"
] ]
}, },
{ {
@ -75,7 +75,7 @@
"## LIcence\n", "## LIcence\n",
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n", "The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
"\n", "\n",
2016 Carlos A. Iglesias, Universidad Politécnica de Madrid." "© Carlos A. Iglesias, Universidad Politécnica de Madrid."
] ]
} }
], ],
@ -95,9 +95,26 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.1" "version": "3.5.5"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -18,7 +18,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © 2016 Carlos A. Iglesias" "Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © Carlos A. Iglesias"
] ]
}, },
{ {
@ -105,8 +105,8 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"In addition, scikit-learn helps in several tasks:\n", "In addition, scikit-learn helps in several tasks:\n",
"* ** Model selection**: Comparing, validating, choosing parameters and models, and persisting models. Some of the [available functionalities](http://scikit-learn.org/stable/model_selection.html#model-selection) are cross-validation or grid search for optimizing the parameters. \n", "* **Model selection**: Comparing, validating, choosing parameters and models, and persisting models. Some of the [available functionalities](http://scikit-learn.org/stable/model_selection.html#model-selection) are cross-validation or grid search for optimizing the parameters. \n",
"* ** Preprocessing**: Several common utility functions and transformer classes to change raw feature vectors into a representation that is more suitable for the downstream estimators. Some of the available [preprocessing functions](http://scikit-learn.org/stable/modules/preprocessing.html#preprocessing) are scaling and normalizing data, or imputing missing values." "* **Preprocessing**: Several common utility functions and transformer classes to change raw feature vectors into a representation that is more suitable for the downstream estimators. Some of the available [preprocessing functions](http://scikit-learn.org/stable/modules/preprocessing.html#preprocessing) are scaling and normalizing data, or imputing missing values."
] ]
}, },
{ {
@ -156,7 +156,7 @@
"## Licence\n", "## Licence\n",
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n", "The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
"\n", "\n",
2016 Carlos A. Iglesias, Universidad Politécnica de Madrid." "© Carlos A. Iglesias, Universidad Politécnica de Madrid."
] ]
} }
], ],
@ -176,9 +176,26 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.1+" "version": "3.5.5"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

View File

@ -8,7 +8,7 @@
"\n", "\n",
"# Course Notes for Learning Intelligent Systems\n", "# Course Notes for Learning Intelligent Systems\n",
"\n", "\n",
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © 2016 Carlos A. Iglesias\n", "Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © Carlos A. Iglesias\n",
"\n", "\n",
"## [Introduction to Machine Learning](2_0_0_Intro_ML.ipynb)" "## [Introduction to Machine Learning](2_0_0_Intro_ML.ipynb)"
] ]
@ -68,10 +68,8 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 8, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false
},
"outputs": [], "outputs": [],
"source": [ "source": [
"# import datasets from scikit-learn\n", "# import datasets from scikit-learn\n",
@ -90,22 +88,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 9, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"data": {
"text/plain": [
"sklearn.datasets.base.Bunch"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"#type 'bunch' of a dataset\n", "#type 'bunch' of a dataset\n",
"type(iris)" "type(iris)"
@ -113,80 +98,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Iris Plants Database\n",
"\n",
"Notes\n",
"-----\n",
"Data Set Characteristics:\n",
" :Number of Instances: 150 (50 in each of three classes)\n",
" :Number of Attributes: 4 numeric, predictive attributes and the class\n",
" :Attribute Information:\n",
" - sepal length in cm\n",
" - sepal width in cm\n",
" - petal length in cm\n",
" - petal width in cm\n",
" - class:\n",
" - Iris-Setosa\n",
" - Iris-Versicolour\n",
" - Iris-Virginica\n",
" :Summary Statistics:\n",
"\n",
" ============== ==== ==== ======= ===== ====================\n",
" Min Max Mean SD Class Correlation\n",
" ============== ==== ==== ======= ===== ====================\n",
" sepal length: 4.3 7.9 5.84 0.83 0.7826\n",
" sepal width: 2.0 4.4 3.05 0.43 -0.4194\n",
" petal length: 1.0 6.9 3.76 1.76 0.9490 (high!)\n",
" petal width: 0.1 2.5 1.20 0.76 0.9565 (high!)\n",
" ============== ==== ==== ======= ===== ====================\n",
"\n",
" :Missing Attribute Values: None\n",
" :Class Distribution: 33.3% for each of 3 classes.\n",
" :Creator: R.A. Fisher\n",
" :Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov)\n",
" :Date: July, 1988\n",
"\n",
"This is a copy of UCI ML iris datasets.\n",
"http://archive.ics.uci.edu/ml/datasets/Iris\n",
"\n",
"The famous Iris database, first used by Sir R.A Fisher\n",
"\n",
"This is perhaps the best known database to be found in the\n",
"pattern recognition literature. Fisher's paper is a classic in the field and\n",
"is referenced frequently to this day. (See Duda & Hart, for example.) The\n",
"data set contains 3 classes of 50 instances each, where each class refers to a\n",
"type of iris plant. One class is linearly separable from the other 2; the\n",
"latter are NOT linearly separable from each other.\n",
"\n",
"References\n",
"----------\n",
" - Fisher,R.A. \"The use of multiple measurements in taxonomic problems\"\n",
" Annual Eugenics, 7, Part II, 179-188 (1936); also in \"Contributions to\n",
" Mathematical Statistics\" (John Wiley, NY, 1950).\n",
" - Duda,R.O., & Hart,P.E. (1973) Pattern Classification and Scene Analysis.\n",
" (Q327.D83) John Wiley & Sons. ISBN 0-471-22361-1. See page 218.\n",
" - Dasarathy, B.V. (1980) \"Nosing Around the Neighborhood: A New System\n",
" Structure and Classification Rule for Recognition in Partially Exposed\n",
" Environments\". IEEE Transactions on Pattern Analysis and Machine\n",
" Intelligence, Vol. PAMI-2, No. 1, 67-71.\n",
" - Gates, G.W. (1972) \"The Reduced Nearest Neighbor Rule\". IEEE Transactions\n",
" on Information Theory, May 1972, 431-433.\n",
" - See also: 1988 MLC Proceedings, 54-64. Cheeseman et al\"s AUTOCLASS II\n",
" conceptual clustering system finds 3 classes in the data.\n",
" - Many, many more ...\n",
"\n"
]
}
],
"source": [ "source": [
"# print descrition of the dataset\n", "# print descrition of the dataset\n",
"print(iris.DESCR)" "print(iris.DESCR)"
@ -194,19 +108,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)']\n"
]
}
],
"source": [ "source": [
"# names of the features (attributes of the entities)\n", "# names of the features (attributes of the entities)\n",
"print(iris.feature_names)" "print(iris.feature_names)"
@ -214,19 +118,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['setosa' 'versicolor' 'virginica']\n"
]
}
],
"source": [ "source": [
"#names of the targets(classes of the classifier)\n", "#names of the targets(classes of the classifier)\n",
"print(iris.target_names)" "print(iris.target_names)"
@ -234,22 +128,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"data": {
"text/plain": [
"numpy.ndarray"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"#type numpy array\n", "#type numpy array\n",
"type(iris.data)" "type(iris.data)"
@ -264,168 +145,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 5.1 3.5 1.4 0.2]\n",
" [ 4.9 3. 1.4 0.2]\n",
" [ 4.7 3.2 1.3 0.2]\n",
" [ 4.6 3.1 1.5 0.2]\n",
" [ 5. 3.6 1.4 0.2]\n",
" [ 5.4 3.9 1.7 0.4]\n",
" [ 4.6 3.4 1.4 0.3]\n",
" [ 5. 3.4 1.5 0.2]\n",
" [ 4.4 2.9 1.4 0.2]\n",
" [ 4.9 3.1 1.5 0.1]\n",
" [ 5.4 3.7 1.5 0.2]\n",
" [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.9 3.1 5.1 2.3]\n",
" [ 5.8 2.7 5.1 1.9]\n",
" [ 6.8 3.2 5.9 2.3]\n",
" [ 6.7 3.3 5.7 2.5]\n",
" [ 6.7 3. 5.2 2.3]\n",
" [ 6.3 2.5 5. 1.9]\n",
" [ 6.5 3. 5.2 2. ]\n",
" [ 6.2 3.4 5.4 2.3]\n",
" [ 5.9 3. 5.1 1.8]]\n"
]
}
],
"source": [ "source": [
"#Data in the iris dataset. The value of the features of the samples.\n", "#Data in the iris dataset. The value of the features of the samples.\n",
"print(iris.data)" "print(iris.data)"
@ -433,23 +155,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"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 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 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1\n",
" 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2\n",
" 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2\n",
" 2 2]\n"
]
}
],
"source": [ "source": [
"# Target. Category of every sample\n", "# Target. Category of every sample\n",
"print(iris.target)" "print(iris.target)"
@ -457,19 +165,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(150, 4)\n"
]
}
],
"source": [ "source": [
"# Iris data is a numpy array\n", "# Iris data is a numpy array\n",
"# We can inspect its shape (rows, columns). In our case, (n_samples, n_features)\n", "# We can inspect its shape (rows, columns). In our case, (n_samples, n_features)\n",
@ -478,19 +176,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2\n"
]
}
],
"source": [ "source": [
"#Using numpy, I can print the dimensions (here we are working with 2D matriz)\n", "#Using numpy, I can print the dimensions (here we are working with 2D matriz)\n",
"print(iris.data.ndim)" "print(iris.data.ndim)"
@ -498,19 +186,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"150\n"
]
}
],
"source": [ "source": [
"# I can print n_samples\n", "# I can print n_samples\n",
"print(iris.data.shape[0])" "print(iris.data.shape[0])"
@ -518,19 +196,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 19, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4\n"
]
}
],
"source": [ "source": [
"# ... n_features\n", "# ... n_features\n",
"print(iris.data.shape[1])" "print(iris.data.shape[1])"
@ -538,19 +206,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 20, "execution_count": null,
"metadata": { "metadata": {},
"collapsed": false "outputs": [],
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)']\n"
]
}
],
"source": [ "source": [
"# names of the features\n", "# names of the features\n",
"print(iris.feature_names)" "print(iris.feature_names)"
@ -590,7 +248,7 @@
"\n", "\n",
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n", "The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
"\n", "\n",
2016 Carlos A. Iglesias, Universidad Politécnica de Madrid." "© Carlos A. Iglesias, Universidad Politécnica de Madrid."
] ]
} }
], ],
@ -610,9 +268,26 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.1+" "version": "3.5.5"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © 2016 Carlos A. Iglesias" "Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © Carlos A. Iglesias"
] ]
}, },
{ {
@ -55,7 +55,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 1, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -81,7 +81,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -93,17 +93,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 4, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"(112, 4) (38, 4)\n"
]
}
],
"source": [ "source": [
"# Dimensions of train and testing\n", "# Dimensions of train and testing\n",
"print(x_train.shape, x_test.shape)" "print(x_train.shape, x_test.shape)"
@ -111,54 +103,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[ 5.7 2.9 4.2 1.3]\n",
" [ 6.7 3.1 4.4 1.4]\n",
" [ 4.7 3.2 1.6 0.2]\n",
" [ 6.5 2.8 4.6 1.5]\n",
" [ 6.1 2.6 5.6 1.4]\n",
" [ 6.3 3.3 6. 2.5]\n",
" [ 4.8 3.4 1.9 0.2]\n",
" [ 5.1 3.5 1.4 0.3]\n",
" [ 6.4 3.1 5.5 1.8]\n",
" [ 6.9 3.2 5.7 2.3]\n",
" [ 6.8 3.2 5.9 2.3]\n",
" [ 4.4 3. 1.3 0.2]\n",
" [ 6.3 3.4 5.6 2.4]\n",
" [ 6.1 2.9 4.7 1.4]\n",
" [ 6.9 3.1 5.1 2.3]\n",
" [ 6.4 2.9 4.3 1.3]\n",
" [ 6. 3. 4.8 1.8]\n",
" [ 5.2 3.5 1.5 0.2]\n",
" [ 6.3 3.3 4.7 1.6]\n",
" [ 7.2 3.2 6. 1.8]\n",
" [ 4.9 3.1 1.5 0.1]\n",
" [ 5.7 3.8 1.7 0.3]\n",
" [ 6.5 3. 5.8 2.2]\n",
" [ 4.8 3. 1.4 0.1]\n",
" [ 6. 2.2 5. 1.5]\n",
" [ 6.2 2.8 4.8 1.8]\n",
" [ 6.1 3. 4.6 1.4]\n",
" [ 6.1 2.8 4. 1.3]\n",
" [ 6.5 3. 5.2 2. ]\n",
" [ 5.9 3. 5.1 1.8]\n",
" [ 5.6 2.7 4.2 1.3]\n",
" [ 6.7 3.1 4.7 1.5]\n",
" [ 5.6 2.8 4.9 2. ]\n",
" [ 6.4 3.2 5.3 2.3]\n",
" [ 6.7 3.1 5.6 2.4]\n",
" [ 6.7 3. 5.2 2.3]\n",
" [ 5.8 2.7 5.1 1.9]\n",
" [ 5.7 3. 4.2 1.2]]\n"
]
}
],
"source": [ "source": [
"#Test set\n", "#Test set\n",
"print (x_test)" "print (x_test)"
@ -182,7 +129,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 10, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
@ -195,54 +142,9 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 11, "execution_count": null,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"[[-0.09752318 -0.32858743 0.34599443 0.25682671]\n",
" [ 1.06445511 0.09442168 0.45718919 0.39124069]\n",
" [-1.25950146 0.30592623 -1.09953753 -1.22172707]\n",
" [ 0.83205945 -0.54009199 0.56838396 0.52565467]\n",
" [ 0.36726814 -0.9631011 1.12435779 0.39124069]\n",
" [ 0.59966379 0.51743079 1.34674732 1.86979447]\n",
" [-1.14330363 0.72893534 -0.93274538 -1.22172707]\n",
" [-0.79471015 0.9404399 -1.2107323 -1.08731309]\n",
" [ 0.71586162 0.09442168 1.06876041 0.92889661]\n",
" [ 1.29685076 0.30592623 1.17995517 1.60096651]\n",
" [ 1.18065293 0.30592623 1.29114994 1.60096651]\n",
" [-1.60809495 -0.11708288 -1.26632968 -1.22172707]\n",
" [ 0.59966379 0.72893534 1.12435779 1.73538049]\n",
" [ 0.36726814 -0.32858743 0.62398134 0.39124069]\n",
" [ 1.29685076 0.09442168 0.84637087 1.60096651]\n",
" [ 0.71586162 -0.32858743 0.40159181 0.25682671]\n",
" [ 0.25107031 -0.11708288 0.67957873 0.92889661]\n",
" [-0.67851232 0.9404399 -1.15513491 -1.22172707]\n",
" [ 0.59966379 0.51743079 0.62398134 0.66006865]\n",
" [ 1.64544425 0.30592623 1.34674732 0.92889661]\n",
" [-1.0271058 0.09442168 -1.15513491 -1.35614105]\n",
" [-0.09752318 1.57495356 -1.04394015 -1.08731309]\n",
" [ 0.83205945 -0.11708288 1.23555256 1.46655253]\n",
" [-1.14330363 -0.11708288 -1.2107323 -1.35614105]\n",
" [ 0.25107031 -1.80911932 0.79077349 0.52565467]\n",
" [ 0.48346596 -0.54009199 0.67957873 0.92889661]\n",
" [ 0.36726814 -0.11708288 0.56838396 0.39124069]\n",
" [ 0.36726814 -0.54009199 0.23479966 0.25682671]\n",
" [ 0.83205945 -0.11708288 0.90196826 1.19772457]\n",
" [ 0.13487248 -0.11708288 0.84637087 0.92889661]\n",
" [-0.21372101 -0.75159654 0.34599443 0.25682671]\n",
" [ 1.06445511 0.09442168 0.62398134 0.52565467]\n",
" [-0.21372101 -0.54009199 0.73517611 1.19772457]\n",
" [ 0.71586162 0.30592623 0.95756564 1.60096651]\n",
" [ 1.06445511 0.09442168 1.12435779 1.73538049]\n",
" [ 1.06445511 -0.11708288 0.90196826 1.60096651]\n",
" [ 0.01867465 -0.75159654 0.84637087 1.06331059]\n",
" [-0.09752318 -0.11708288 0.34599443 0.12241273]]\n"
]
}
],
"source": [ "source": [
"# As we see, the iris dataset is now normalized\n", "# As we see, the iris dataset is now normalized\n",
"print(x_test)" "print(x_test)"
@ -274,7 +176,7 @@
"### Licences\n", "### Licences\n",
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n", "The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
"\n", "\n",
2016 Carlos A. Iglesias, Universidad Politécnica de Madrid." "© Carlos A. Iglesias, Universidad Politécnica de Madrid."
] ]
} }
], ],
@ -294,7 +196,24 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.3" "version": "3.5.6"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@ -18,7 +18,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © 2016 Carlos A. Iglesias" "Department of Telematic Engineering Systems, Universidad Politécnica de Madrid, © Carlos A. Iglesias"
] ]
}, },
{ {
@ -145,9 +145,7 @@
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {},
"collapsed": false
},
"source": [ "source": [
"## References" "## References"
] ]
@ -173,7 +171,7 @@
"source": [ "source": [
"The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n", "The notebook is freely licensed under under the [Creative Commons Attribution Share-Alike license](https://creativecommons.org/licenses/by/2.0/). \n",
"\n", "\n",
2016 Carlos A. Iglesias, Universidad Politécnica de Madrid." "© Carlos A. Iglesias, Universidad Politécnica de Madrid."
] ]
} }
], ],
@ -193,9 +191,26 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.5.1+" "version": "3.5.6"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,
"autocomplete": true,
"bibliofile": "biblio.bib",
"cite_by": "apalike",
"current_citInitial": 1,
"eqLabelWithNumbers": true,
"eqNumInitial": 1,
"hotkeys": {
"equation": "Ctrl-E",
"itemize": "Ctrl-I"
},
"labels_anchors": false,
"latex_user_defs": false,
"report_style_numbering": false,
"user_envs_cfg": false
} }
}, },
"nbformat": 4, "nbformat": 4,
"nbformat_minor": 0 "nbformat_minor": 1
} }

File diff suppressed because one or more lines are too long