├── README.md ├── TenisID3.odt ├── TasasError.ods ├── RiesgoCrediticio.ods ├── PlayTennis.csv ├── RiesgoCrediticio.csv ├── weather.nominal.arff ├── RiesgoCrediticio.arff ├── LICENSE ├── arbol.dot ├── .gitignore ├── Practica 1.ipynb ├── machine.names ├── contact-lenses.arff ├── Cluster.ipynb ├── KNN-59.ipynb ├── Boston.ipynb ├── Distancias y similaridad.ipynb ├── Práctica RBF.ipynb ├── iris.arff ├── SOM.ipynb ├── RBF.ipynb ├── machine.data ├── Regresion Lineal Multiple y Logistica.ipynb ├── IRIS decision tree.ipynb ├── Datos_ Credit_100.csv ├── DBCluster.ipynb ├── Perceptron simple y ADALINE.ipynb ├── Perceptron Multicapa.ipynb ├── house-votes-84.csv └── ThoraricSurgery.arff /README.md: -------------------------------------------------------------------------------- 1 | # AprendizajeAutomatico 2 | Ejercicios de la asignatura TAA 3 | -------------------------------------------------------------------------------- /TenisID3.odt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarroyoc/AprendizajeAutomatico/master/TenisID3.odt -------------------------------------------------------------------------------- /TasasError.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarroyoc/AprendizajeAutomatico/master/TasasError.ods -------------------------------------------------------------------------------- /RiesgoCrediticio.ods: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/aarroyoc/AprendizajeAutomatico/master/RiesgoCrediticio.ods -------------------------------------------------------------------------------- /PlayTennis.csv: -------------------------------------------------------------------------------- 1 | Outlook,Temperature,Humidity,Wind,PlayTennis 2 | Overcast,Mild,High,Strong,YES 3 | Overcast,Cool,Normal,Strong,YES 4 | Overcast,Hot,High,Weak,YES 5 | Overcast,Hot,Normal,Weak,YES 6 | Rain,Mild,High,Strong,NO 7 | Rain,Cool,Normal,Strong,NO 8 | Rain,Mild,High,Weak,YES 9 | Rain,Cool,Normal,Weak,YES 10 | Rain,Mild,Normal,Weak,YES 11 | Sunny,Hot,High,Strong,NO 12 | Sunny,Mild,Normal,Strong,YES 13 | Sunny,Hot,High,Weak,NO 14 | Sunny,Mild,High,Weak,NO 15 | Sunny,Cool,Normal,Weak,YES 16 | -------------------------------------------------------------------------------- /RiesgoCrediticio.csv: -------------------------------------------------------------------------------- 1 | Riesgo,Historia,Deuda,Avales,Ingresos 2 | alto,mala,alta,no,0 a 2M 3 | alto,desconocida,alta,no,2 a 5M 4 | moderado,desconocida,baja,no,2 a 5M 5 | alto,desconocida,baja,no,0 a 2M 6 | bajo,desconocida,baja,no,más de 5M 7 | bajo,desconocida,baja,adecuados,más de 5M 8 | alto,mala,baja,no,0 a 2M 9 | moderado,mala,baja,adecuados,más de 5M 10 | bajo,buena,baja,no,más de 5M 11 | bajo,buena,alta,adecuados,más de 5M 12 | alto,buena,alta,no,0 a 2M 13 | moderado,buena,alta,no,2 a 5M 14 | bajo,buena,alta,no,más de 5M 15 | alto,mala,alta,no,2 a 5M 16 | -------------------------------------------------------------------------------- /weather.nominal.arff: -------------------------------------------------------------------------------- 1 | @relation weather.symbolic 2 | 3 | @attribute outlook {sunny, overcast, rainy} 4 | @attribute temperature {hot, mild, cool} 5 | @attribute humidity {high, normal} 6 | @attribute windy {TRUE, FALSE} 7 | @attribute play {yes, no} 8 | 9 | @data 10 | sunny,hot,high,FALSE,no 11 | sunny,hot,high,TRUE,no 12 | overcast,hot,high,FALSE,yes 13 | rainy,mild,high,FALSE,yes 14 | rainy,cool,normal,FALSE,yes 15 | rainy,cool,normal,TRUE,no 16 | overcast,cool,normal,TRUE,yes 17 | sunny,mild,high,FALSE,no 18 | sunny,cool,normal,FALSE,yes 19 | rainy,mild,normal,FALSE,yes 20 | sunny,mild,normal,TRUE,yes 21 | overcast,mild,high,TRUE,yes 22 | overcast,hot,normal,FALSE,yes 23 | rainy,mild,high,TRUE,no 24 | -------------------------------------------------------------------------------- /RiesgoCrediticio.arff: -------------------------------------------------------------------------------- 1 | @relation RiesgoCrediticio 2 | 3 | @attribute Riesgo {alto,moderado,bajo} 4 | @attribute Historia {mala,desconocida,buena} 5 | @attribute Deuda {alta,baja} 6 | @attribute Avales {no,adecuados} 7 | @attribute Ingresos {'0 a 2M','2 a 5M','más de 5M'} 8 | 9 | @data 10 | alto,mala,alta,no,'0 a 2M' 11 | alto,desconocida,alta,no,'2 a 5M' 12 | moderado,desconocida,baja,no,'2 a 5M' 13 | alto,desconocida,baja,no,'0 a 2M' 14 | bajo,desconocida,baja,no,'más de 5M' 15 | bajo,desconocida,baja,adecuados,'más de 5M' 16 | alto,mala,baja,no,'0 a 2M' 17 | moderado,mala,baja,adecuados,'más de 5M' 18 | bajo,buena,baja,no,'más de 5M' 19 | bajo,buena,alta,adecuados,'más de 5M' 20 | alto,buena,alta,no,'0 a 2M' 21 | moderado,buena,alta,no,'2 a 5M' 22 | bajo,buena,alta,no,'más de 5M' 23 | alto,mala,alta,no,'2 a 5M' 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /arbol.dot: -------------------------------------------------------------------------------- 1 | digraph Tree { 2 | node [shape=box] ; 3 | 0 [label="petal width (cm) <= 0.8\nentropy = 1.585\nsamples = 100\nvalue = [34, 33, 33]"] ; 4 | 1 [label="entropy = 0.0\nsamples = 34\nvalue = [34, 0, 0]"] ; 5 | 0 -> 1 [labeldistance=2.5, labelangle=45, headlabel="True"] ; 6 | 2 [label="petal width (cm) <= 1.75\nentropy = 1.0\nsamples = 66\nvalue = [0, 33, 33]"] ; 7 | 0 -> 2 [labeldistance=2.5, labelangle=-45, headlabel="False"] ; 8 | 3 [label="petal length (cm) <= 4.95\nentropy = 0.494\nsamples = 37\nvalue = [0, 33, 4]"] ; 9 | 2 -> 3 ; 10 | 4 [label="petal width (cm) <= 1.65\nentropy = 0.201\nsamples = 32\nvalue = [0, 31, 1]"] ; 11 | 3 -> 4 ; 12 | 5 [label="entropy = 0.0\nsamples = 31\nvalue = [0, 31, 0]"] ; 13 | 4 -> 5 ; 14 | 6 [label="entropy = 0.0\nsamples = 1\nvalue = [0, 0, 1]"] ; 15 | 4 -> 6 ; 16 | 7 [label="petal width (cm) <= 1.55\nentropy = 0.971\nsamples = 5\nvalue = [0, 2, 3]"] ; 17 | 3 -> 7 ; 18 | 8 [label="entropy = 0.0\nsamples = 2\nvalue = [0, 0, 2]"] ; 19 | 7 -> 8 ; 20 | 9 [label="sepal length (cm) <= 6.95\nentropy = 0.918\nsamples = 3\nvalue = [0, 2, 1]"] ; 21 | 7 -> 9 ; 22 | 10 [label="entropy = 0.0\nsamples = 2\nvalue = [0, 2, 0]"] ; 23 | 9 -> 10 ; 24 | 11 [label="entropy = 0.0\nsamples = 1\nvalue = [0, 0, 1]"] ; 25 | 9 -> 11 ; 26 | 12 [label="entropy = 0.0\nsamples = 29\nvalue = [0, 0, 29]"] ; 27 | 2 -> 12 ; 28 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /Practica 1.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "Cantidad de información\n" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 2, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import math\n", 17 | "\n", 18 | "def cantidad_informacion(probabilidad):\n", 19 | " return math.log2(1/probabilidad)\n", 20 | "def entropia(probabilidades):\n", 21 | " sums = [probabilidad*cantidad_informacion(probabilidad) for probabilidad in probabilidades]\n", 22 | " return sum(sums)" 23 | ] 24 | }, 25 | { 26 | "cell_type": "code", 27 | "execution_count": 54, 28 | "metadata": { 29 | "scrolled": true 30 | }, 31 | "outputs": [ 32 | { 33 | "data": { 34 | "text/plain": [ 35 | "0.9402859586706309" 36 | ] 37 | }, 38 | "execution_count": 54, 39 | "metadata": {}, 40 | "output_type": "execute_result" 41 | } 42 | ], 43 | "source": [ 44 | "entropia([5/14,9/14])" 45 | ] 46 | }, 47 | { 48 | "cell_type": "code", 49 | "execution_count": null, 50 | "metadata": { 51 | "scrolled": true 52 | }, 53 | "outputs": [], 54 | "source": [] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": null, 59 | "metadata": {}, 60 | "outputs": [], 61 | "source": [] 62 | } 63 | ], 64 | "metadata": { 65 | "kernelspec": { 66 | "display_name": "Python 3", 67 | "language": "python", 68 | "name": "python3" 69 | }, 70 | "language_info": { 71 | "codemirror_mode": { 72 | "name": "ipython", 73 | "version": 3 74 | }, 75 | "file_extension": ".py", 76 | "mimetype": "text/x-python", 77 | "name": "python", 78 | "nbconvert_exporter": "python", 79 | "pygments_lexer": "ipython3", 80 | "version": "3.7.2+" 81 | } 82 | }, 83 | "nbformat": 4, 84 | "nbformat_minor": 2 85 | } 86 | -------------------------------------------------------------------------------- /machine.names: -------------------------------------------------------------------------------- 1 | 1. Title: Relative CPU Performance Data 2 | 3 | 2. Source Information 4 | -- Creators: Phillip Ein-Dor and Jacob Feldmesser 5 | -- Ein-Dor: Faculty of Management; Tel Aviv University; Ramat-Aviv; 6 | Tel Aviv, 69978; Israel 7 | -- Donor: David W. Aha (aha@ics.uci.edu) (714) 856-8779 8 | -- Date: October, 1987 9 | 10 | 3. Past Usage: 11 | 1. Ein-Dor and Feldmesser (CACM 4/87, pp 308-317) 12 | -- Results: 13 | -- linear regression prediction of relative cpu performance 14 | -- Recorded 34% average deviation from actual values 15 | 2. Kibler,D. & Aha,D. (1988). Instance-Based Prediction of 16 | Real-Valued Attributes. In Proceedings of the CSCSI (Canadian 17 | AI) Conference. 18 | -- Results: 19 | -- instance-based prediction of relative cpu performance 20 | -- similar results; no transformations required 21 | - Predicted attribute: cpu relative performance (numeric) 22 | 23 | 4. Relevant Information: 24 | -- The estimated relative performance values were estimated by the authors 25 | using a linear regression method. See their article (pp 308-313) for 26 | more details on how the relative performance values were set. 27 | 28 | 5. Number of Instances: 209 29 | 30 | 6. Number of Attributes: 10 (6 predictive attributes, 2 non-predictive, 31 | 1 goal field, and the linear regression's guess) 32 | 33 | 7. Attribute Information: 34 | 1. vendor name: 30 35 | (adviser, amdahl,apollo, basf, bti, burroughs, c.r.d, cambex, cdc, dec, 36 | dg, formation, four-phase, gould, honeywell, hp, ibm, ipl, magnuson, 37 | microdata, nas, ncr, nixdorf, perkin-elmer, prime, siemens, sperry, 38 | sratus, wang) 39 | 2. Model Name: many unique symbols 40 | 3. MYCT: machine cycle time in nanoseconds (integer) 41 | 4. MMIN: minimum main memory in kilobytes (integer) 42 | 5. MMAX: maximum main memory in kilobytes (integer) 43 | 6. CACH: cache memory in kilobytes (integer) 44 | 7. CHMIN: minimum channels in units (integer) 45 | 8. CHMAX: maximum channels in units (integer) 46 | 9. PRP: published relative performance (integer) 47 | 10. ERP: estimated relative performance from the original article (integer) 48 | 49 | 8. Missing Attribute Values: None 50 | 51 | 9. Class Distribution: the class value (PRP) is continuously valued. 52 | PRP Value Range: Number of Instances in Range: 53 | 0-20 31 54 | 21-100 121 55 | 101-200 27 56 | 201-300 13 57 | 301-400 7 58 | 401-500 4 59 | 501-600 2 60 | above 600 4 61 | 62 | Summary Statistics: 63 | Min Max Mean SD PRP Correlation 64 | MCYT: 17 1500 203.8 260.3 -0.3071 65 | MMIN: 64 32000 2868.0 3878.7 0.7949 66 | MMAX: 64 64000 11796.1 11726.6 0.8630 67 | CACH: 0 256 25.2 40.6 0.6626 68 | CHMIN: 0 52 4.7 6.8 0.6089 69 | CHMAX: 0 176 18.2 26.0 0.6052 70 | PRP: 6 1150 105.6 160.8 1.0000 71 | ERP: 15 1238 99.3 154.8 0.9665 72 | 73 | -------------------------------------------------------------------------------- /contact-lenses.arff: -------------------------------------------------------------------------------- 1 | % 1. Title: Database for fitting contact lenses 2 | % 3 | % 2. Sources: 4 | % (a) Cendrowska, J. "PRISM: An algorithm for inducing modular rules", 5 | % International Journal of Man-Machine Studies, 1987, 27, 349-370 6 | % (b) Donor: Benoit Julien (Julien@ce.cmu.edu) 7 | % (c) Date: 1 August 1990 8 | % 9 | % 3. Past Usage: 10 | % 1. See above. 11 | % 2. Witten, I. H. & MacDonald, B. A. (1988). Using concept 12 | % learning for knowledge acquisition. International Journal of 13 | % Man-Machine Studies, 27, (pp. 349-370). 14 | % 15 | % Notes: This database is complete (all possible combinations of 16 | % attribute-value pairs are represented). 17 | % 18 | % Each instance is complete and correct. 19 | % 20 | % 9 rules cover the training set. 21 | % 22 | % 4. Relevant Information Paragraph: 23 | % The examples are complete and noise free. 24 | % The examples highly simplified the problem. The attributes do not 25 | % fully describe all the factors affecting the decision as to which type, 26 | % if any, to fit. 27 | % 28 | % 5. Number of Instances: 24 29 | % 30 | % 6. Number of Attributes: 4 (all nominal) 31 | % 32 | % 7. Attribute Information: 33 | % -- 3 Classes 34 | % 1 : the patient should be fitted with hard contact lenses, 35 | % 2 : the patient should be fitted with soft contact lenses, 36 | % 1 : the patient should not be fitted with contact lenses. 37 | % 38 | % 1. age of the patient: (1) young, (2) pre-presbyopic, (3) presbyopic 39 | % 2. spectacle prescription: (1) myope, (2) hypermetrope 40 | % 3. astigmatic: (1) no, (2) yes 41 | % 4. tear production rate: (1) reduced, (2) normal 42 | % 43 | % 8. Number of Missing Attribute Values: 0 44 | % 45 | % 9. Class Distribution: 46 | % 1. hard contact lenses: 4 47 | % 2. soft contact lenses: 5 48 | % 3. no contact lenses: 15 49 | 50 | @relation contact-lenses 51 | 52 | @attribute age {young, pre-presbyopic, presbyopic} 53 | @attribute spectacle-prescrip {myope, hypermetrope} 54 | @attribute astigmatism {no, yes} 55 | @attribute tear-prod-rate {reduced, normal} 56 | @attribute contact-lenses {soft, hard, none} 57 | 58 | @data 59 | % 60 | % 24 instances 61 | % 62 | young,myope,no,reduced,none 63 | young,myope,no,normal,soft 64 | young,myope,yes,reduced,none 65 | young,myope,yes,normal,hard 66 | young,hypermetrope,no,reduced,none 67 | young,hypermetrope,no,normal,soft 68 | young,hypermetrope,yes,reduced,none 69 | young,hypermetrope,yes,normal,hard 70 | pre-presbyopic,myope,no,reduced,none 71 | pre-presbyopic,myope,no,normal,soft 72 | pre-presbyopic,myope,yes,reduced,none 73 | pre-presbyopic,myope,yes,normal,hard 74 | pre-presbyopic,hypermetrope,no,reduced,none 75 | pre-presbyopic,hypermetrope,no,normal,soft 76 | pre-presbyopic,hypermetrope,yes,reduced,none 77 | pre-presbyopic,hypermetrope,yes,normal,none 78 | presbyopic,myope,no,reduced,none 79 | presbyopic,myope,no,normal,none 80 | presbyopic,myope,yes,reduced,none 81 | presbyopic,myope,yes,normal,hard 82 | presbyopic,hypermetrope,no,reduced,none 83 | presbyopic,hypermetrope,no,normal,soft 84 | presbyopic,hypermetrope,yes,reduced,none 85 | presbyopic,hypermetrope,yes,normal,none 86 | -------------------------------------------------------------------------------- /Cluster.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Cluster KMeans\n", 8 | "\n", 9 | "Adrián Arroyo Calle" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 2, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import numpy as np\n", 19 | "from sklearn.datasets import load_iris\n", 20 | "\n", 21 | "X, Y = load_iris(return_X_y=True)" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 3, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "from sklearn.preprocessing import MinMaxScaler\n", 31 | "\n", 32 | "X = MinMaxScaler().fit_transform(X)" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 4, 38 | "metadata": {}, 39 | "outputs": [ 40 | { 41 | "name": "stdout", 42 | "output_type": "stream", 43 | "text": [ 44 | "Cluster: 3\tScore: 0.886667\n", 45 | "Cluster: 4\tScore: 0.886667\n", 46 | "Cluster: 5\tScore: 0.880000\n", 47 | "Cluster: 6\tScore: 0.893333\n", 48 | "Cluster: 7\tScore: 0.966667\n", 49 | "Cluster: 8\tScore: 0.973333\n", 50 | "Cluster: 9\tScore: 0.966667\n", 51 | "Cluster: 10\tScore: 0.960000\n", 52 | "Cluster: 11\tScore: 0.966667\n", 53 | "Cluster: 12\tScore: 0.966667\n", 54 | "Cluster: 13\tScore: 0.973333\n", 55 | "Cluster: 14\tScore: 0.973333\n", 56 | "Cluster: 15\tScore: 0.993333\n" 57 | ] 58 | } 59 | ], 60 | "source": [ 61 | "from sklearn.model_selection import StratifiedKFold\n", 62 | "from sklearn.cluster import KMeans\n", 63 | "from scipy import stats\n", 64 | "from sklearn.metrics import accuracy_score\n", 65 | "\n", 66 | "for clusters in range(3,11):\n", 67 | " xv = StratifiedKFold(n_splits=10, random_state=0)\n", 68 | " score = 0\n", 69 | " for train_index, test_index in xv.split(X, Y):\n", 70 | " kmeans = KMeans(n_clusters=clusters, random_state=0)\n", 71 | " kmeans.fit(X[train_index])\n", 72 | " Y_labels = kmeans.predict(X[test_index])\n", 73 | " ok = 0\n", 74 | " total = 0\n", 75 | " for cluster in range(clusters):\n", 76 | " cluster_index = np.argwhere(Y_labels==cluster)\n", 77 | " try:\n", 78 | " Y_predict = stats.mode(Y[test_index][cluster_index])[0][0][0] # la clase que predice el cluster\n", 79 | " except:\n", 80 | " continue\n", 81 | " ok += np.sum(Y[test_index][cluster_index] == Y_predict) # los elementos cuya del cluster cuya clase coincide la predicha\n", 82 | " total += len(Y[test_index][cluster_index])\n", 83 | " score += ok/total\n", 84 | " print(\"Cluster: %d\\tScore: %f\" % (clusters, score/10))\n", 85 | "\n", 86 | " \n", 87 | " \n", 88 | " " 89 | ] 90 | }, 91 | { 92 | "cell_type": "markdown", 93 | "metadata": {}, 94 | "source": [ 95 | "# Conclusiones\n", 96 | "\n", 97 | "En general, KMedias obtiene resultados bastante acertados, mejorando según vamos aumentando el número de clusters, hasta 8, donde encontramos el valor óptimo de K." 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": null, 103 | "metadata": {}, 104 | "outputs": [], 105 | "source": [] 106 | } 107 | ], 108 | "metadata": { 109 | "kernelspec": { 110 | "display_name": "Python 3", 111 | "language": "python", 112 | "name": "python3" 113 | }, 114 | "language_info": { 115 | "codemirror_mode": { 116 | "name": "ipython", 117 | "version": 3 118 | }, 119 | "file_extension": ".py", 120 | "mimetype": "text/x-python", 121 | "name": "python", 122 | "nbconvert_exporter": "python", 123 | "pygments_lexer": "ipython3", 124 | "version": "3.7.5" 125 | } 126 | }, 127 | "nbformat": 4, 128 | "nbformat_minor": 2 129 | } 130 | -------------------------------------------------------------------------------- /KNN-59.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "KNN 59\n", 8 | "======\n", 9 | "\n", 10 | "Adrián Arroyo Calle - TAA Marzo 2019\n", 11 | "\n", 12 | "\n", 13 | "\n", 14 | "\n", 15 | "En esta entrega tenemos un conjunto de datos formado por imágenes en escala de grises que representan cincos y nueves de forma manuscrita. Usando estos datos analizaremos el comportamiento del clasificador perezoso K-NN, tratando de encontrar el K óptimo. Para ello se usa Python con el módulo sklearn.neighbors." 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 1, 21 | "metadata": {}, 22 | "outputs": [], 23 | "source": [ 24 | "import pandas as pd\n", 25 | "import numpy as np\n", 26 | "from sklearn.neighbors import KNeighborsClassifier\n", 27 | "from sklearn.model_selection import KFold" 28 | ] 29 | }, 30 | { 31 | "cell_type": "code", 32 | "execution_count": 2, 33 | "metadata": {}, 34 | "outputs": [], 35 | "source": [ 36 | "entrenae = pd.read_csv(\"entrenae59.csv\")\n", 37 | "entrenae_x = entrenae.drop(\"digito\",axis=1)\n", 38 | "entrenae_y = entrenae[\"digito\"]" 39 | ] 40 | }, 41 | { 42 | "cell_type": "code", 43 | "execution_count": 3, 44 | "metadata": {}, 45 | "outputs": [], 46 | "source": [ 47 | "pruebae = pd.read_csv(\"pruebae59.csv\")\n", 48 | "pruebae_x = pruebae.drop(\"digito\",axis=1)\n", 49 | "pruebae_y = pruebae[\"digito\"]" 50 | ] 51 | }, 52 | { 53 | "cell_type": "code", 54 | "execution_count": 4, 55 | "metadata": {}, 56 | "outputs": [ 57 | { 58 | "name": "stdout", 59 | "output_type": "stream", 60 | "text": [ 61 | "K=1 Tasa acierto: 0.901180\n", 62 | "K=3 Tasa acierto: 0.901938\n", 63 | "K=5 Tasa acierto: 0.964698\n", 64 | "K=7 Tasa acierto: 0.963922\n", 65 | "K=9 Tasa acierto: 0.960857\n" 66 | ] 67 | } 68 | ], 69 | "source": [ 70 | "res = dict()\n", 71 | "cv = KFold(10)\n", 72 | "for k in range(1,11,2):\n", 73 | " c = KNeighborsClassifier(n_neighbors=k)\n", 74 | " i = 0\n", 75 | " acumula = 0\n", 76 | " cv_iter = cv.split(entrenae_x,entrenae_y)\n", 77 | " for train, test in cv_iter:\n", 78 | " c.fit(entrenae_x.iloc[train],entrenae_y.iloc[train])\n", 79 | " aciertos = c.score(entrenae_x.iloc[test],entrenae_y.iloc[test])\n", 80 | " i += 1\n", 81 | " acumula += aciertos\n", 82 | " print(\"K=%d Tasa acierto: %f\" % (k,acumula/i))" 83 | ] 84 | }, 85 | { 86 | "cell_type": "code", 87 | "execution_count": 5, 88 | "metadata": {}, 89 | "outputs": [ 90 | { 91 | "data": { 92 | "text/plain": [ 93 | "{1: 0.8950617283950617,\n", 94 | " 3: 0.8950617283950617,\n", 95 | " 5: 0.8966049382716049,\n", 96 | " 7: 0.8935185185185185,\n", 97 | " 9: 0.8935185185185185}" 98 | ] 99 | }, 100 | "execution_count": 5, 101 | "metadata": {}, 102 | "output_type": "execute_result" 103 | } 104 | ], 105 | "source": [ 106 | "res = dict()\n", 107 | "for k in range(1,11,2):\n", 108 | " c = KNeighborsClassifier(n_neighbors=k)\n", 109 | " c.fit(entrenae_x,entrenae_y)\n", 110 | " res[k] = c.score(pruebae_x,pruebae_y)\n", 111 | "res" 112 | ] 113 | }, 114 | { 115 | "cell_type": "code", 116 | "execution_count": 8, 117 | "metadata": {}, 118 | "outputs": [ 119 | { 120 | "data": { 121 | "text/plain": [ 122 | "0.011960875193690374" 123 | ] 124 | }, 125 | "execution_count": 8, 126 | "metadata": {}, 127 | "output_type": "execute_result" 128 | } 129 | ], 130 | "source": [ 131 | "import math\n", 132 | "math.sqrt((res[5]*(1-res[5]))/pruebae_y.shape[0])" 133 | ] 134 | }, 135 | { 136 | "cell_type": "markdown", 137 | "metadata": {}, 138 | "source": [ 139 | "En ambos casos se obtiene que el K óptimo es 5.\n", 140 | "\n", 141 | "Su tasa de error con el conjunto de entrenamiento es 0.8966 con una desviación estándar de 0.0119" 142 | ] 143 | } 144 | ], 145 | "metadata": { 146 | "kernelspec": { 147 | "display_name": "Python 3", 148 | "language": "python", 149 | "name": "python3" 150 | }, 151 | "language_info": { 152 | "codemirror_mode": { 153 | "name": "ipython", 154 | "version": 3 155 | }, 156 | "file_extension": ".py", 157 | "mimetype": "text/x-python", 158 | "name": "python", 159 | "nbconvert_exporter": "python", 160 | "pygments_lexer": "ipython3", 161 | "version": "3.7.2+" 162 | } 163 | }, 164 | "nbformat": 4, 165 | "nbformat_minor": 2 166 | } 167 | -------------------------------------------------------------------------------- /Boston.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np\n", 10 | "from sklearn.datasets import load_boston\n", 11 | "from sklearn.neural_network import MLPRegressor\n", 12 | "from sklearn.preprocessing import MinMaxScaler" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 2, 18 | "metadata": {}, 19 | "outputs": [], 20 | "source": [ 21 | "boston = load_boston()" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 3, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "X = MinMaxScaler().fit(boston.data).transform(boston.data)" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": 4, 36 | "metadata": {}, 37 | "outputs": [], 38 | "source": [ 39 | "Y = MinMaxScaler().fit(boston.target.reshape(-1,1)).transform(boston.target.reshape(-1,1))" 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 5, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "adaline = MLPRegressor(hidden_layer_sizes=[],solver=\"sgd\",alpha=0.1,batch_size=1,max_iter=5000,momentum=0,verbose=True)" 49 | ] 50 | }, 51 | { 52 | "cell_type": "code", 53 | "execution_count": 6, 54 | "metadata": {}, 55 | "outputs": [ 56 | { 57 | "name": "stderr", 58 | "output_type": "stream", 59 | "text": [ 60 | "/opt/anaconda3/lib/python3.6/site-packages/sklearn/neural_network/multilayer_perceptron.py:1306: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n", 61 | " y = column_or_1d(y, warn=True)\n" 62 | ] 63 | }, 64 | { 65 | "name": "stdout", 66 | "output_type": "stream", 67 | "text": [ 68 | "Iteration 1, loss = 0.12056385\n", 69 | "Iteration 2, loss = 0.06030746\n", 70 | "Iteration 3, loss = 0.05284842\n", 71 | "Iteration 4, loss = 0.04748889\n", 72 | "Iteration 5, loss = 0.04300466\n", 73 | "Iteration 6, loss = 0.03919977\n", 74 | "Iteration 7, loss = 0.03595491\n", 75 | "Iteration 8, loss = 0.03316687\n", 76 | "Iteration 9, loss = 0.03075701\n", 77 | "Iteration 10, loss = 0.02864753\n", 78 | "Iteration 11, loss = 0.02682300\n", 79 | "Iteration 12, loss = 0.02522509\n", 80 | "Iteration 13, loss = 0.02383437\n", 81 | "Iteration 14, loss = 0.02260916\n", 82 | "Iteration 15, loss = 0.02152303\n", 83 | "Iteration 16, loss = 0.02056420\n", 84 | "Iteration 17, loss = 0.01975356\n", 85 | "Iteration 18, loss = 0.01901323\n", 86 | "Iteration 19, loss = 0.01836786\n", 87 | "Iteration 20, loss = 0.01779271\n", 88 | "Iteration 21, loss = 0.01727597\n", 89 | "Iteration 22, loss = 0.01684730\n", 90 | "Iteration 23, loss = 0.01644856\n", 91 | "Iteration 24, loss = 0.01610430\n", 92 | "Iteration 25, loss = 0.01579786\n", 93 | "Iteration 26, loss = 0.01550132\n", 94 | "Iteration 27, loss = 0.01528962\n", 95 | "Iteration 28, loss = 0.01507395\n", 96 | "Iteration 29, loss = 0.01487208\n", 97 | "Iteration 30, loss = 0.01471690\n", 98 | "Iteration 31, loss = 0.01456943\n", 99 | "Iteration 32, loss = 0.01442863\n", 100 | "Iteration 33, loss = 0.01430861\n", 101 | "Iteration 34, loss = 0.01418330\n", 102 | "Iteration 35, loss = 0.01412074\n", 103 | "Iteration 36, loss = 0.01402549\n", 104 | "Iteration 37, loss = 0.01396748\n", 105 | "Training loss did not improve more than tol=0.000100 for two consecutive epochs. Stopping.\n" 106 | ] 107 | }, 108 | { 109 | "data": { 110 | "text/plain": [ 111 | "MLPRegressor(activation='relu', alpha=0.1, batch_size=1, beta_1=0.9,\n", 112 | " beta_2=0.999, early_stopping=False, epsilon=1e-08,\n", 113 | " hidden_layer_sizes=[], learning_rate='constant',\n", 114 | " learning_rate_init=0.001, max_iter=5000, momentum=0,\n", 115 | " nesterovs_momentum=True, power_t=0.5, random_state=None,\n", 116 | " shuffle=True, solver='sgd', tol=0.0001, validation_fraction=0.1,\n", 117 | " verbose=True, warm_start=False)" 118 | ] 119 | }, 120 | "execution_count": 6, 121 | "metadata": {}, 122 | "output_type": "execute_result" 123 | } 124 | ], 125 | "source": [ 126 | "adaline.fit(X,Y)" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": null, 132 | "metadata": {}, 133 | "outputs": [], 134 | "source": [] 135 | } 136 | ], 137 | "metadata": { 138 | "kernelspec": { 139 | "display_name": "Python 3", 140 | "language": "python", 141 | "name": "python3" 142 | }, 143 | "language_info": { 144 | "codemirror_mode": { 145 | "name": "ipython", 146 | "version": 3 147 | }, 148 | "file_extension": ".py", 149 | "mimetype": "text/x-python", 150 | "name": "python", 151 | "nbconvert_exporter": "python", 152 | "pygments_lexer": "ipython3", 153 | "version": "3.6.4" 154 | } 155 | }, 156 | "nbformat": 4, 157 | "nbformat_minor": 2 158 | } 159 | -------------------------------------------------------------------------------- /Distancias y similaridad.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "Adrián Arroyo Calle" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "# Distancias atributos continuos" 15 | ] 16 | }, 17 | { 18 | "cell_type": "code", 19 | "execution_count": 2, 20 | "metadata": {}, 21 | "outputs": [], 22 | "source": [ 23 | "import numpy as np\n", 24 | "\n", 25 | "X = np.array([2.1, 3.1, 3.4, 1.9])\n", 26 | "Y = np.array([1.2, 2.0, 1.7, 3.6])" 27 | ] 28 | }, 29 | { 30 | "cell_type": "code", 31 | "execution_count": 3, 32 | "metadata": {}, 33 | "outputs": [], 34 | "source": [ 35 | "from scipy.spatial.distance import euclidean, mahalanobis, minkowski" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 5, 41 | "metadata": {}, 42 | "outputs": [ 43 | { 44 | "name": "stdout", 45 | "output_type": "stream", 46 | "text": [ 47 | "Distancia euclídea 2.792848\n" 48 | ] 49 | } 50 | ], 51 | "source": [ 52 | "d = euclidean(X, Y)\n", 53 | "print(\"Distancia euclídea %f\" % d)" 54 | ] 55 | }, 56 | { 57 | "cell_type": "code", 58 | "execution_count": 6, 59 | "metadata": {}, 60 | "outputs": [ 61 | { 62 | "name": "stdout", 63 | "output_type": "stream", 64 | "text": [ 65 | "Distancia Minkowski (P=1): 5.400000\n", 66 | "Distancia Minkowski (P=3): 2.282156\n" 67 | ] 68 | } 69 | ], 70 | "source": [ 71 | "d = minkowski(X, Y, 1)\n", 72 | "print(\"Distancia Minkowski (P=1): %f\" % d)\n", 73 | "d = minkowski(X, Y, 3)\n", 74 | "print(\"Distancia Minkowski (P=3): %f\" % d)" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 7, 80 | "metadata": {}, 81 | "outputs": [ 82 | { 83 | "name": "stdout", 84 | "output_type": "stream", 85 | "text": [ 86 | "Distanca Mahalanobis: 4.878524\n" 87 | ] 88 | } 89 | ], 90 | "source": [ 91 | "cov = np.array([[2,0,0,0],[0,4,0,0],[0,0,4,0],[0,0,0,2]])\n", 92 | "d = mahalanobis(X, Y, cov)\n", 93 | "print(\"Distanca Mahalanobis: %f\" % d)" 94 | ] 95 | }, 96 | { 97 | "cell_type": "markdown", 98 | "metadata": {}, 99 | "source": [ 100 | "# Distancia atributos binarios\n" 101 | ] 102 | }, 103 | { 104 | "cell_type": "code", 105 | "execution_count": 8, 106 | "metadata": {}, 107 | "outputs": [ 108 | { 109 | "data": { 110 | "text/plain": [ 111 | "array([[3, 3],\n", 112 | " [1, 3]])" 113 | ] 114 | }, 115 | "execution_count": 8, 116 | "metadata": {}, 117 | "output_type": "execute_result" 118 | } 119 | ], 120 | "source": [ 121 | "X = np.array([1,0,0,0,1,1,0,1,0,0])\n", 122 | "Y = np.array([0,0,1,0,1,1,1,1,0,1])\n", 123 | "\n", 124 | "from sklearn.metrics import confusion_matrix\n", 125 | "c = confusion_matrix(X, Y, labels=[0,1])\n", 126 | "c" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 12, 132 | "metadata": {}, 133 | "outputs": [ 134 | { 135 | "name": "stdout", 136 | "output_type": "stream", 137 | "text": [ 138 | "Sokal-Michel: 0.600000\n", 139 | "Distancia equivalente: 0.632456\n" 140 | ] 141 | } 142 | ], 143 | "source": [ 144 | "# Sokal-Michel\n", 145 | "s = (3+3)/(3+3+3+1)\n", 146 | "print(\"Sokal-Michel: %f\" % s)\n", 147 | "d = np.sqrt(1-s)\n", 148 | "print(\"Distancia equivalente: %f\" %d)" 149 | ] 150 | }, 151 | { 152 | "cell_type": "code", 153 | "execution_count": 14, 154 | "metadata": {}, 155 | "outputs": [ 156 | { 157 | "name": "stdout", 158 | "output_type": "stream", 159 | "text": [ 160 | "Jaccard: 0.428571\n", 161 | "Distancia equivalente: 0.755929\n" 162 | ] 163 | } 164 | ], 165 | "source": [ 166 | "# Jaccard\n", 167 | "s = 3/(3+3+1)\n", 168 | "print(\"Jaccard: %f\" % s)\n", 169 | "d = np.sqrt(1-s)\n", 170 | "print(\"Distancia equivalente: %f\" % d)" 171 | ] 172 | }, 173 | { 174 | "cell_type": "markdown", 175 | "metadata": {}, 176 | "source": [ 177 | "# Variables mixtas" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": 18, 183 | "metadata": {}, 184 | "outputs": [ 185 | { 186 | "name": "stdout", 187 | "output_type": "stream", 188 | "text": [ 189 | "Similaridad: 0.518605\n" 190 | ] 191 | } 192 | ], 193 | "source": [ 194 | "p = 1-(abs(50.2-52.3)/(54.1-49.8)) + 1-(abs(2.9-3.7)/(4.6-2.6))\n", 195 | "s = (p+1+1)/(2+(2-0)+2)\n", 196 | "print(\"Similaridad: %f\" % s)" 197 | ] 198 | } 199 | ], 200 | "metadata": { 201 | "kernelspec": { 202 | "display_name": "Python 3", 203 | "language": "python", 204 | "name": "python3" 205 | }, 206 | "language_info": { 207 | "codemirror_mode": { 208 | "name": "ipython", 209 | "version": 3 210 | }, 211 | "file_extension": ".py", 212 | "mimetype": "text/x-python", 213 | "name": "python", 214 | "nbconvert_exporter": "python", 215 | "pygments_lexer": "ipython3", 216 | "version": "3.7.5" 217 | } 218 | }, 219 | "nbformat": 4, 220 | "nbformat_minor": 2 221 | } 222 | -------------------------------------------------------------------------------- /Práctica RBF.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np\n", 10 | "import pandas as pd\n" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 2, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "url = \"http://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data\"\n", 20 | "df = pd.read_csv(url,header=None)" 21 | ] 22 | }, 23 | { 24 | "cell_type": "code", 25 | "execution_count": 3, 26 | "metadata": {}, 27 | "outputs": [], 28 | "source": [ 29 | "from sklearn.preprocessing import MinMaxScaler\n", 30 | "\n", 31 | "X = MinMaxScaler().fit_transform(df.iloc[:,1:])\n", 32 | "Y = np.array(df.iloc[:,0])" 33 | ] 34 | }, 35 | { 36 | "cell_type": "code", 37 | "execution_count": 4, 38 | "metadata": {}, 39 | "outputs": [], 40 | "source": [ 41 | "from sklearn.model_selection import train_test_split" 42 | ] 43 | }, 44 | { 45 | "cell_type": "code", 46 | "execution_count": 5, 47 | "metadata": {}, 48 | "outputs": [], 49 | "source": [ 50 | "X_train, X_test, Y_train, Y_test = train_test_split(X,Y,test_size=1/3,stratify=Y)" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": 6, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "from sklearn.cluster import KMeans\n", 60 | "kmedias = KMeans(n_clusters=15).fit(X_train)\n", 61 | "centros = kmedias.cluster_centers_" 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": 7, 67 | "metadata": {}, 68 | "outputs": [], 69 | "source": [ 70 | "from sklearn.metrics.pairwise import euclidean_distances\n", 71 | "distancias = euclidean_distances(centros)\n", 72 | "sigma = sum(distancias)/(centros.shape[0]-1)" 73 | ] 74 | }, 75 | { 76 | "cell_type": "code", 77 | "execution_count": 8, 78 | "metadata": {}, 79 | "outputs": [], 80 | "source": [ 81 | "def mahalanobis(X,Y,S):\n", 82 | " return (X-Y) @ S @ (X-Y).T\n", 83 | "\n", 84 | "S = np.cov(X,rowvar=False)\n", 85 | "S_inv = np.linalg.inv(S)" 86 | ] 87 | }, 88 | { 89 | "cell_type": "code", 90 | "execution_count": 60, 91 | "metadata": {}, 92 | "outputs": [], 93 | "source": [ 94 | "X_mlp_train = np.zeros((X_train.shape[0], centros.shape[0]), dtype=float)\n", 95 | "for i in range(X_train.shape[0]):\n", 96 | " for j in range(centros.shape[0]):\n", 97 | " X_mlp_train[i][j] = np.exp(-mahalanobis(X_train[i],centros[j],S_inv)/(2.0*(sigma[j]**2)))" 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": 61, 103 | "metadata": {}, 104 | "outputs": [ 105 | { 106 | "data": { 107 | "text/plain": [ 108 | "19.789408688887022" 109 | ] 110 | }, 111 | "execution_count": 61, 112 | "metadata": {}, 113 | "output_type": "execute_result" 114 | } 115 | ], 116 | "source": [ 117 | "S = np.cov(X,rowvar=False)\n", 118 | "S_inv = np.linalg.inv(S)\n", 119 | "(X_train[0]-centros[0]) @ S_inv @ (X_train[0]-centros[0]).T" 120 | ] 121 | }, 122 | { 123 | "cell_type": "code", 124 | "execution_count": 62, 125 | "metadata": {}, 126 | "outputs": [], 127 | "source": [ 128 | "X_mlp_test = np.zeros((X_test.shape[0], centros.shape[0]), dtype=float)\n", 129 | "for i in range(X_test.shape[0]):\n", 130 | " for j in range(centros.shape[0]):\n", 131 | " X_mlp_test[i][j] = np.exp(-mahalanobis(X_test[i],centros[j],S_inv)/(2.0*(sigma[j]**2)))" 132 | ] 133 | }, 134 | { 135 | "cell_type": "code", 136 | "execution_count": 63, 137 | "metadata": {}, 138 | "outputs": [], 139 | "source": [ 140 | "from sklearn.preprocessing import LabelBinarizer\n", 141 | "etiquetas = LabelBinarizer()\n", 142 | "etiquetas.fit([1,2,3])\n", 143 | "Ymlp = etiquetas.transform(Y)\n", 144 | "Y_mlp_train = etiquetas.transform(Y_train)\n", 145 | "Y_mlp_test = etiquetas.transform(Y_test)" 146 | ] 147 | }, 148 | { 149 | "cell_type": "code", 150 | "execution_count": 14, 151 | "metadata": {}, 152 | "outputs": [ 153 | { 154 | "name": "stdout", 155 | "output_type": "stream", 156 | "text": [ 157 | "Tasa de aciertos = 58.333333333333336 %\n" 158 | ] 159 | } 160 | ], 161 | "source": [ 162 | "from sklearn.linear_model import SGDRegressor\n", 163 | "adaline = SGDRegressor(max_iter=5000)\n", 164 | "Yp_test = np.zeros((Y_test.shape[0],3))\n", 165 | "for neurona_salida in range(3):\n", 166 | " adaline.fit(X_mlp_train,Y_mlp_train[:,neurona_salida])\n", 167 | " Yp_test[:,neurona_salida] = adaline.predict(X_mlp_test)\n", 168 | "aciertos = sum(np.argmax(Yp_test, axis=1) == np.argmax(Y_mlp_test,axis=1)) / Y_mlp_test.shape[0]\n", 169 | "print(\"Tasa de aciertos =\",aciertos*100, \"%\")" 170 | ] 171 | }, 172 | { 173 | "cell_type": "markdown", 174 | "metadata": {}, 175 | "source": [ 176 | "Resultados\n", 177 | "\n", 178 | "||3|4|5|6|7|8|9|10|11|12|13|14|15|\n", 179 | "|-|-|-|-|-|-|-|-|-|-|-|-|-|-|\n", 180 | "|Euclídea|1|1|1|1|1|1|1|1|1|1|1|1|1|\n", 181 | "|Mahalanobis|0.48|0.46|0.46|0.46|0.48|0.5|0.51|0.51|0.5|0.45|0.48|0.5|0.58|" 182 | ] 183 | }, 184 | { 185 | "cell_type": "markdown", 186 | "metadata": {}, 187 | "source": [ 188 | "# Parte 2: MLP de salida" 189 | ] 190 | }, 191 | { 192 | "cell_type": "code", 193 | "execution_count": 75, 194 | "metadata": {}, 195 | "outputs": [], 196 | "source": [ 197 | "from sklearn.neural_network import MLPClassifier\n", 198 | "\n", 199 | "net = MLPClassifier(hidden_layer_sizes=(10),activation=\"identity\",solver=\"lbfgs\",batch_size=1,max_iter=5000,momentum=0)" 200 | ] 201 | }, 202 | { 203 | "cell_type": "code", 204 | "execution_count": 76, 205 | "metadata": {}, 206 | "outputs": [ 207 | { 208 | "data": { 209 | "text/plain": [ 210 | "MLPClassifier(activation='identity', alpha=0.0001, batch_size=1, beta_1=0.9,\n", 211 | " beta_2=0.999, early_stopping=False, epsilon=1e-08,\n", 212 | " hidden_layer_sizes=10, learning_rate='constant',\n", 213 | " learning_rate_init=0.001, max_iter=5000, momentum=0,\n", 214 | " nesterovs_momentum=True, power_t=0.5, random_state=None,\n", 215 | " shuffle=True, solver='lbfgs', tol=0.0001, validation_fraction=0.1,\n", 216 | " verbose=False, warm_start=False)" 217 | ] 218 | }, 219 | "execution_count": 76, 220 | "metadata": {}, 221 | "output_type": "execute_result" 222 | } 223 | ], 224 | "source": [ 225 | "net.fit(X_mlp_train,Y_train)" 226 | ] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": 77, 231 | "metadata": {}, 232 | "outputs": [], 233 | "source": [ 234 | "Y_predict = net.predict(X_mlp_test)" 235 | ] 236 | }, 237 | { 238 | "cell_type": "code", 239 | "execution_count": 78, 240 | "metadata": {}, 241 | "outputs": [ 242 | { 243 | "data": { 244 | "text/plain": [ 245 | "0.95" 246 | ] 247 | }, 248 | "execution_count": 78, 249 | "metadata": {}, 250 | "output_type": "execute_result" 251 | } 252 | ], 253 | "source": [ 254 | "sum(Y_predict == Y_test)/Y_test.shape[0]" 255 | ] 256 | }, 257 | { 258 | "cell_type": "markdown", 259 | "metadata": {}, 260 | "source": [ 261 | "Tasa de acierto del 95% para tamaño de cluster 15 y distancia de Mahalanobis, usando LBFGS" 262 | ] 263 | } 264 | ], 265 | "metadata": { 266 | "kernelspec": { 267 | "display_name": "Python 3", 268 | "language": "python", 269 | "name": "python3" 270 | }, 271 | "language_info": { 272 | "codemirror_mode": { 273 | "name": "ipython", 274 | "version": 3 275 | }, 276 | "file_extension": ".py", 277 | "mimetype": "text/x-python", 278 | "name": "python", 279 | "nbconvert_exporter": "python", 280 | "pygments_lexer": "ipython3", 281 | "version": "3.7.3" 282 | } 283 | }, 284 | "nbformat": 4, 285 | "nbformat_minor": 2 286 | } 287 | -------------------------------------------------------------------------------- /iris.arff: -------------------------------------------------------------------------------- 1 | % 1. Title: Iris Plants Database 2 | % 3 | % 2. Sources: 4 | % (a) Creator: R.A. Fisher 5 | % (b) Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov) 6 | % (c) Date: July, 1988 7 | % 8 | % 3. Past Usage: 9 | % - Publications: too many to mention!!! Here are a few. 10 | % 1. Fisher,R.A. "The use of multiple measurements in taxonomic problems" 11 | % Annual Eugenics, 7, Part II, 179-188 (1936); also in "Contributions 12 | % to Mathematical Statistics" (John Wiley, NY, 1950). 13 | % 2. Duda,R.O., & Hart,P.E. (1973) Pattern Classification and Scene Analysis. 14 | % (Q327.D83) John Wiley & Sons. ISBN 0-471-22361-1. See page 218. 15 | % 3. Dasarathy, B.V. (1980) "Nosing Around the Neighborhood: A New System 16 | % Structure and Classification Rule for Recognition in Partially Exposed 17 | % Environments". IEEE Transactions on Pattern Analysis and Machine 18 | % Intelligence, Vol. PAMI-2, No. 1, 67-71. 19 | % -- Results: 20 | % -- very low misclassification rates (0% for the setosa class) 21 | % 4. Gates, G.W. (1972) "The Reduced Nearest Neighbor Rule". IEEE 22 | % Transactions on Information Theory, May 1972, 431-433. 23 | % -- Results: 24 | % -- very low misclassification rates again 25 | % 5. See also: 1988 MLC Proceedings, 54-64. Cheeseman et al's AUTOCLASS II 26 | % conceptual clustering system finds 3 classes in the data. 27 | % 28 | % 4. Relevant Information: 29 | % --- This is perhaps the best known database to be found in the pattern 30 | % recognition literature. Fisher's paper is a classic in the field 31 | % and is referenced frequently to this day. (See Duda & Hart, for 32 | % example.) The data set contains 3 classes of 50 instances each, 33 | % where each class refers to a type of iris plant. One class is 34 | % linearly separable from the other 2; the latter are NOT linearly 35 | % separable from each other. 36 | % --- Predicted attribute: class of iris plant. 37 | % --- This is an exceedingly simple domain. 38 | % 39 | % 5. Number of Instances: 150 (50 in each of three classes) 40 | % 41 | % 6. Number of Attributes: 4 numeric, predictive attributes and the class 42 | % 43 | % 7. Attribute Information: 44 | % 1. sepal length in cm 45 | % 2. sepal width in cm 46 | % 3. petal length in cm 47 | % 4. petal width in cm 48 | % 5. class: 49 | % -- Iris Setosa 50 | % -- Iris Versicolour 51 | % -- Iris Virginica 52 | % 53 | % 8. Missing Attribute Values: None 54 | % 55 | % Summary Statistics: 56 | % Min Max Mean SD Class Correlation 57 | % sepal length: 4.3 7.9 5.84 0.83 0.7826 58 | % sepal width: 2.0 4.4 3.05 0.43 -0.4194 59 | % petal length: 1.0 6.9 3.76 1.76 0.9490 (high!) 60 | % petal width: 0.1 2.5 1.20 0.76 0.9565 (high!) 61 | % 62 | % 9. Class Distribution: 33.3% for each of 3 classes. 63 | 64 | @RELATION iris 65 | 66 | @ATTRIBUTE sepallength REAL 67 | @ATTRIBUTE sepalwidth REAL 68 | @ATTRIBUTE petallength REAL 69 | @ATTRIBUTE petalwidth REAL 70 | @ATTRIBUTE class {Iris-setosa,Iris-versicolor,Iris-virginica} 71 | 72 | @DATA 73 | 5.1,3.5,1.4,0.2,Iris-setosa 74 | 4.9,3.0,1.4,0.2,Iris-setosa 75 | 4.7,3.2,1.3,0.2,Iris-setosa 76 | 4.6,3.1,1.5,0.2,Iris-setosa 77 | 5.0,3.6,1.4,0.2,Iris-setosa 78 | 5.4,3.9,1.7,0.4,Iris-setosa 79 | 4.6,3.4,1.4,0.3,Iris-setosa 80 | 5.0,3.4,1.5,0.2,Iris-setosa 81 | 4.4,2.9,1.4,0.2,Iris-setosa 82 | 4.9,3.1,1.5,0.1,Iris-setosa 83 | 5.4,3.7,1.5,0.2,Iris-setosa 84 | 4.8,3.4,1.6,0.2,Iris-setosa 85 | 4.8,3.0,1.4,0.1,Iris-setosa 86 | 4.3,3.0,1.1,0.1,Iris-setosa 87 | 5.8,4.0,1.2,0.2,Iris-setosa 88 | 5.7,4.4,1.5,0.4,Iris-setosa 89 | 5.4,3.9,1.3,0.4,Iris-setosa 90 | 5.1,3.5,1.4,0.3,Iris-setosa 91 | 5.7,3.8,1.7,0.3,Iris-setosa 92 | 5.1,3.8,1.5,0.3,Iris-setosa 93 | 5.4,3.4,1.7,0.2,Iris-setosa 94 | 5.1,3.7,1.5,0.4,Iris-setosa 95 | 4.6,3.6,1.0,0.2,Iris-setosa 96 | 5.1,3.3,1.7,0.5,Iris-setosa 97 | 4.8,3.4,1.9,0.2,Iris-setosa 98 | 5.0,3.0,1.6,0.2,Iris-setosa 99 | 5.0,3.4,1.6,0.4,Iris-setosa 100 | 5.2,3.5,1.5,0.2,Iris-setosa 101 | 5.2,3.4,1.4,0.2,Iris-setosa 102 | 4.7,3.2,1.6,0.2,Iris-setosa 103 | 4.8,3.1,1.6,0.2,Iris-setosa 104 | 5.4,3.4,1.5,0.4,Iris-setosa 105 | 5.2,4.1,1.5,0.1,Iris-setosa 106 | 5.5,4.2,1.4,0.2,Iris-setosa 107 | 4.9,3.1,1.5,0.1,Iris-setosa 108 | 5.0,3.2,1.2,0.2,Iris-setosa 109 | 5.5,3.5,1.3,0.2,Iris-setosa 110 | 4.9,3.1,1.5,0.1,Iris-setosa 111 | 4.4,3.0,1.3,0.2,Iris-setosa 112 | 5.1,3.4,1.5,0.2,Iris-setosa 113 | 5.0,3.5,1.3,0.3,Iris-setosa 114 | 4.5,2.3,1.3,0.3,Iris-setosa 115 | 4.4,3.2,1.3,0.2,Iris-setosa 116 | 5.0,3.5,1.6,0.6,Iris-setosa 117 | 5.1,3.8,1.9,0.4,Iris-setosa 118 | 4.8,3.0,1.4,0.3,Iris-setosa 119 | 5.1,3.8,1.6,0.2,Iris-setosa 120 | 4.6,3.2,1.4,0.2,Iris-setosa 121 | 5.3,3.7,1.5,0.2,Iris-setosa 122 | 5.0,3.3,1.4,0.2,Iris-setosa 123 | 7.0,3.2,4.7,1.4,Iris-versicolor 124 | 6.4,3.2,4.5,1.5,Iris-versicolor 125 | 6.9,3.1,4.9,1.5,Iris-versicolor 126 | 5.5,2.3,4.0,1.3,Iris-versicolor 127 | 6.5,2.8,4.6,1.5,Iris-versicolor 128 | 5.7,2.8,4.5,1.3,Iris-versicolor 129 | 6.3,3.3,4.7,1.6,Iris-versicolor 130 | 4.9,2.4,3.3,1.0,Iris-versicolor 131 | 6.6,2.9,4.6,1.3,Iris-versicolor 132 | 5.2,2.7,3.9,1.4,Iris-versicolor 133 | 5.0,2.0,3.5,1.0,Iris-versicolor 134 | 5.9,3.0,4.2,1.5,Iris-versicolor 135 | 6.0,2.2,4.0,1.0,Iris-versicolor 136 | 6.1,2.9,4.7,1.4,Iris-versicolor 137 | 5.6,2.9,3.6,1.3,Iris-versicolor 138 | 6.7,3.1,4.4,1.4,Iris-versicolor 139 | 5.6,3.0,4.5,1.5,Iris-versicolor 140 | 5.8,2.7,4.1,1.0,Iris-versicolor 141 | 6.2,2.2,4.5,1.5,Iris-versicolor 142 | 5.6,2.5,3.9,1.1,Iris-versicolor 143 | 5.9,3.2,4.8,1.8,Iris-versicolor 144 | 6.1,2.8,4.0,1.3,Iris-versicolor 145 | 6.3,2.5,4.9,1.5,Iris-versicolor 146 | 6.1,2.8,4.7,1.2,Iris-versicolor 147 | 6.4,2.9,4.3,1.3,Iris-versicolor 148 | 6.6,3.0,4.4,1.4,Iris-versicolor 149 | 6.8,2.8,4.8,1.4,Iris-versicolor 150 | 6.7,3.0,5.0,1.7,Iris-versicolor 151 | 6.0,2.9,4.5,1.5,Iris-versicolor 152 | 5.7,2.6,3.5,1.0,Iris-versicolor 153 | 5.5,2.4,3.8,1.1,Iris-versicolor 154 | 5.5,2.4,3.7,1.0,Iris-versicolor 155 | 5.8,2.7,3.9,1.2,Iris-versicolor 156 | 6.0,2.7,5.1,1.6,Iris-versicolor 157 | 5.4,3.0,4.5,1.5,Iris-versicolor 158 | 6.0,3.4,4.5,1.6,Iris-versicolor 159 | 6.7,3.1,4.7,1.5,Iris-versicolor 160 | 6.3,2.3,4.4,1.3,Iris-versicolor 161 | 5.6,3.0,4.1,1.3,Iris-versicolor 162 | 5.5,2.5,4.0,1.3,Iris-versicolor 163 | 5.5,2.6,4.4,1.2,Iris-versicolor 164 | 6.1,3.0,4.6,1.4,Iris-versicolor 165 | 5.8,2.6,4.0,1.2,Iris-versicolor 166 | 5.0,2.3,3.3,1.0,Iris-versicolor 167 | 5.6,2.7,4.2,1.3,Iris-versicolor 168 | 5.7,3.0,4.2,1.2,Iris-versicolor 169 | 5.7,2.9,4.2,1.3,Iris-versicolor 170 | 6.2,2.9,4.3,1.3,Iris-versicolor 171 | 5.1,2.5,3.0,1.1,Iris-versicolor 172 | 5.7,2.8,4.1,1.3,Iris-versicolor 173 | 6.3,3.3,6.0,2.5,Iris-virginica 174 | 5.8,2.7,5.1,1.9,Iris-virginica 175 | 7.1,3.0,5.9,2.1,Iris-virginica 176 | 6.3,2.9,5.6,1.8,Iris-virginica 177 | 6.5,3.0,5.8,2.2,Iris-virginica 178 | 7.6,3.0,6.6,2.1,Iris-virginica 179 | 4.9,2.5,4.5,1.7,Iris-virginica 180 | 7.3,2.9,6.3,1.8,Iris-virginica 181 | 6.7,2.5,5.8,1.8,Iris-virginica 182 | 7.2,3.6,6.1,2.5,Iris-virginica 183 | 6.5,3.2,5.1,2.0,Iris-virginica 184 | 6.4,2.7,5.3,1.9,Iris-virginica 185 | 6.8,3.0,5.5,2.1,Iris-virginica 186 | 5.7,2.5,5.0,2.0,Iris-virginica 187 | 5.8,2.8,5.1,2.4,Iris-virginica 188 | 6.4,3.2,5.3,2.3,Iris-virginica 189 | 6.5,3.0,5.5,1.8,Iris-virginica 190 | 7.7,3.8,6.7,2.2,Iris-virginica 191 | 7.7,2.6,6.9,2.3,Iris-virginica 192 | 6.0,2.2,5.0,1.5,Iris-virginica 193 | 6.9,3.2,5.7,2.3,Iris-virginica 194 | 5.6,2.8,4.9,2.0,Iris-virginica 195 | 7.7,2.8,6.7,2.0,Iris-virginica 196 | 6.3,2.7,4.9,1.8,Iris-virginica 197 | 6.7,3.3,5.7,2.1,Iris-virginica 198 | 7.2,3.2,6.0,1.8,Iris-virginica 199 | 6.2,2.8,4.8,1.8,Iris-virginica 200 | 6.1,3.0,4.9,1.8,Iris-virginica 201 | 6.4,2.8,5.6,2.1,Iris-virginica 202 | 7.2,3.0,5.8,1.6,Iris-virginica 203 | 7.4,2.8,6.1,1.9,Iris-virginica 204 | 7.9,3.8,6.4,2.0,Iris-virginica 205 | 6.4,2.8,5.6,2.2,Iris-virginica 206 | 6.3,2.8,5.1,1.5,Iris-virginica 207 | 6.1,2.6,5.6,1.4,Iris-virginica 208 | 7.7,3.0,6.1,2.3,Iris-virginica 209 | 6.3,3.4,5.6,2.4,Iris-virginica 210 | 6.4,3.1,5.5,1.8,Iris-virginica 211 | 6.0,3.0,4.8,1.8,Iris-virginica 212 | 6.9,3.1,5.4,2.1,Iris-virginica 213 | 6.7,3.1,5.6,2.4,Iris-virginica 214 | 6.9,3.1,5.1,2.3,Iris-virginica 215 | 5.8,2.7,5.1,1.9,Iris-virginica 216 | 6.8,3.2,5.9,2.3,Iris-virginica 217 | 6.7,3.3,5.7,2.5,Iris-virginica 218 | 6.7,3.0,5.2,2.3,Iris-virginica 219 | 6.3,2.5,5.0,1.9,Iris-virginica 220 | 6.5,3.0,5.2,2.0,Iris-virginica 221 | 6.2,3.4,5.4,2.3,Iris-virginica 222 | 5.9,3.0,5.1,1.8,Iris-virginica 223 | % 224 | % 225 | % 226 | -------------------------------------------------------------------------------- /SOM.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 13, 6 | "metadata": { 7 | "colab": {}, 8 | "colab_type": "code", 9 | "id": "p8-I7pnopY9L" 10 | }, 11 | "outputs": [], 12 | "source": [ 13 | "from sklearn.datasets import load_iris, fetch_openml\n", 14 | "from sklearn.preprocessing import MinMaxScaler, normalize\n", 15 | "from sklearn.model_selection import train_test_split\n", 16 | "from scipy.spatial.distance import minkowski, cosine\n", 17 | "from sklearn.metrics import accuracy_score\n", 18 | "from collections import Counter\n", 19 | "import numpy as np\n", 20 | "import math\n", 21 | "import random" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 14, 27 | "metadata": { 28 | "colab": {}, 29 | "colab_type": "code", 30 | "id": "MUEMnD1lpY9Z" 31 | }, 32 | "outputs": [], 33 | "source": [ 34 | "X, Y = load_iris(return_X_y=True)\n", 35 | "X = MinMaxScaler().fit_transform(X)" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": 15, 41 | "metadata": { 42 | "colab": {}, 43 | "colab_type": "code", 44 | "id": "9qcHMOROpY9i" 45 | }, 46 | "outputs": [], 47 | "source": [ 48 | "class Neuron:\n", 49 | " def __init__(self, size, x, y):\n", 50 | " self.weight = np.array([random.uniform(-1, 1) for i in range(size)]).reshape(1,-1)\n", 51 | " self.x = x\n", 52 | " self.y = y\n", 53 | " self.label = None\n", 54 | " self.wins = Counter()\n", 55 | " self.active = True\n", 56 | "\n", 57 | " def predict(self, data):\n", 58 | " return cosine(data, self.weight)\n", 59 | "\n", 60 | "class SOM:\n", 61 | " def __init__(self, rows, columns, size):\n", 62 | " self.network = list()\n", 63 | " for i in range(rows):\n", 64 | " for j in range(columns):\n", 65 | " self.network.append(Neuron(size=size, x=i, y=j))\n", 66 | " \n", 67 | " def fit(self, X, epochs, radius, alpha0):\n", 68 | " alpha = alpha0\n", 69 | " for t in range(epochs):\n", 70 | " D = np.copy(X)\n", 71 | " np.random.shuffle(D)\n", 72 | " for data in D:\n", 73 | " l = map(lambda x: x.predict(data), self.network)\n", 74 | " l = list(l)\n", 75 | " winner = self.network[np.argmax(l)]\n", 76 | " for neuron in self.network:\n", 77 | " if winner.x-radius < neuron.x < winner.x+radius and winner.y-radius < neuron.y < winner.y+radius:\n", 78 | " #p = neuron.weight+alpha*data\n", 79 | " #neuron.weight = p/np.linalg.norm(p)\n", 80 | " #neuron.weight += normalize(alpha*(data-neuron.weight), norm=\"max\")\n", 81 | " neuron.weight += alpha*(data-neuron.weight)\n", 82 | " radius -= 1\n", 83 | " if radius == -1:\n", 84 | " radius == 0\n", 85 | " alpha = alpha0 / (1+(t/len(D)))\n", 86 | " def neuron_labeling(self, X, Y):\n", 87 | " for neuron in self.network:\n", 88 | " l = map(neuron.predict, X)\n", 89 | " l = list(l)\n", 90 | " neuron.label = Y[np.argmax(l)]\n", 91 | " \n", 92 | " def mode_labeling(self, X, Y):\n", 93 | " for i, instance in enumerate(X):\n", 94 | " l = map(lambda x: x.predict(instance), filter(lambda x: x.active, self.network))\n", 95 | " l = list(l)\n", 96 | " winner = self.network[np.argmax(l)]\n", 97 | " winner.wins[Y[i]] += 1\n", 98 | " winner.label = winner.wins.most_common()[0][0]\n", 99 | " if len(winner.wins.keys()) > 1:\n", 100 | " winner.active = True\n", 101 | " \n", 102 | " \n", 103 | " def predict(self, X):\n", 104 | " output = np.zeros((X.shape[0],))\n", 105 | " for i,instance in enumerate(X):\n", 106 | " l = map(lambda x: x.predict(instance), filter(lambda x: x.active, self.network))\n", 107 | " l = list(l)\n", 108 | " output[i] = self.network[np.argmax(l)].label\n", 109 | " return output\n", 110 | " " 111 | ] 112 | }, 113 | { 114 | "cell_type": "code", 115 | "execution_count": 16, 116 | "metadata": { 117 | "colab": {}, 118 | "colab_type": "code", 119 | "id": "FVTVAH-mpY9p" 120 | }, 121 | "outputs": [], 122 | "source": [ 123 | "X_train, X_test, Y_train, Y_test= train_test_split(X, Y, test_size=0.33, random_state=0, stratify=Y)" 124 | ] 125 | }, 126 | { 127 | "cell_type": "code", 128 | "execution_count": 17, 129 | "metadata": { 130 | "colab": {}, 131 | "colab_type": "code", 132 | "id": "_Y4kuA-2pY9u" 133 | }, 134 | "outputs": [], 135 | "source": [ 136 | "som = SOM(12, 8, 4)\n", 137 | "som.fit(X_train, 100, 4, 0.5)\n", 138 | "som.mode_labeling(X_train, Y_train)\n", 139 | "Y_predict = som.predict(X_test)" 140 | ] 141 | }, 142 | { 143 | "cell_type": "code", 144 | "execution_count": 18, 145 | "metadata": { 146 | "colab": { 147 | "base_uri": "https://localhost:8080/", 148 | "height": 34 149 | }, 150 | "colab_type": "code", 151 | "id": "I6Jh_xncpY90", 152 | "outputId": "971becf7-c26b-4160-af65-196b29909963", 153 | "scrolled": true 154 | }, 155 | "outputs": [ 156 | { 157 | "data": { 158 | "text/plain": [ 159 | "0.82" 160 | ] 161 | }, 162 | "execution_count": 18, 163 | "metadata": {}, 164 | "output_type": "execute_result" 165 | } 166 | ], 167 | "source": [ 168 | "np.sum(Y_predict == Y_test)/Y_test.shape[0]" 169 | ] 170 | }, 171 | { 172 | "cell_type": "code", 173 | "execution_count": 19, 174 | "metadata": { 175 | "colab": {}, 176 | "colab_type": "code", 177 | "id": "HbQeUhYlpY97" 178 | }, 179 | "outputs": [], 180 | "source": [ 181 | "# MNIST\n", 182 | "X, Y = fetch_openml(\"mnist_784\", return_X_y=True)\n", 183 | "X = MinMaxScaler().fit_transform(X)" 184 | ] 185 | }, 186 | { 187 | "cell_type": "code", 188 | "execution_count": 20, 189 | "metadata": { 190 | "colab": {}, 191 | "colab_type": "code", 192 | "id": "QOX8zP7kpY9_" 193 | }, 194 | "outputs": [], 195 | "source": [ 196 | "X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=10000, random_state=0, stratify=Y)" 197 | ] 198 | }, 199 | { 200 | "cell_type": "code", 201 | "execution_count": null, 202 | "metadata": { 203 | "colab": { 204 | "base_uri": "https://localhost:8080/", 205 | "height": 52 206 | }, 207 | "colab_type": "code", 208 | "id": "Iu3Z-a5cpY-F", 209 | "outputId": "f3542f3a-ff29-43e5-d37a-72cfc0a036f1" 210 | }, 211 | "outputs": [], 212 | "source": [ 213 | "som = SOM(12, 8, 784)\n", 214 | "som.fit(X_train, 10, 4, 0.5)\n", 215 | "som.mode_labeling(X_train, Y_train)\n", 216 | "Y_predict = som.predict(X_test)\n", 217 | "print(accuracy_score(Y_predict, Y_test, normalize=True))\n", 218 | "som = SOM(12, 8, 784)\n", 219 | "som.fit(X_train, 10, 4, 0.5)\n", 220 | "som.neuron_labeling(X_train, Y_train)\n", 221 | "Y_predict = som.predict(X_test)\n", 222 | "print(accuracy_score(Y_predict, Y_test, normalize=True))" 223 | ] 224 | }, 225 | { 226 | "cell_type": "markdown", 227 | "metadata": { 228 | "colab_type": "text", 229 | "id": "UVzQz6rbQGEN" 230 | }, 231 | "source": [ 232 | "Los resultados con Iris dan un 25% de acierto" 233 | ] 234 | } 235 | ], 236 | "metadata": { 237 | "colab": { 238 | "name": "SOM.ipynb", 239 | "provenance": [] 240 | }, 241 | "kernelspec": { 242 | "display_name": "Python 3", 243 | "language": "python", 244 | "name": "python3" 245 | }, 246 | "language_info": { 247 | "codemirror_mode": { 248 | "name": "ipython", 249 | "version": 3 250 | }, 251 | "file_extension": ".py", 252 | "mimetype": "text/x-python", 253 | "name": "python", 254 | "nbconvert_exporter": "python", 255 | "pygments_lexer": "ipython3", 256 | "version": "3.7.5" 257 | } 258 | }, 259 | "nbformat": 4, 260 | "nbformat_minor": 1 261 | } 262 | -------------------------------------------------------------------------------- /RBF.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np\n", 10 | "from pandas import DataFrame, read_csv\n", 11 | "from sklearn.model_selection import train_test_split\n", 12 | "from sklearn.preprocessing import minmax_scale" 13 | ] 14 | }, 15 | { 16 | "cell_type": "code", 17 | "execution_count": 4, 18 | "metadata": {}, 19 | "outputs": [], 20 | "source": [ 21 | "datos = read_csv(\"https://archive.ics.uci.edu/ml/machine-learning-databases/wine/wine.data\",header=None)" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 8, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "X = minmax_scale(datos.iloc[:,1:])\n", 31 | "Y = np.array(datos.iloc[:,0])" 32 | ] 33 | }, 34 | { 35 | "cell_type": "code", 36 | "execution_count": 11, 37 | "metadata": {}, 38 | "outputs": [ 39 | { 40 | "data": { 41 | "text/plain": [ 42 | "(numpy.ndarray, numpy.ndarray, (178, 13), (178,))" 43 | ] 44 | }, 45 | "execution_count": 11, 46 | "metadata": {}, 47 | "output_type": "execute_result" 48 | } 49 | ], 50 | "source": [ 51 | "type(X),type(Y),X.shape,Y.shape" 52 | ] 53 | }, 54 | { 55 | "cell_type": "code", 56 | "execution_count": 12, 57 | "metadata": {}, 58 | "outputs": [], 59 | "source": [ 60 | "X_train, X_test, Y_train, Y_test = train_test_split(X,Y,test_size=1/3,stratify=Y,random_state=0)" 61 | ] 62 | }, 63 | { 64 | "cell_type": "code", 65 | "execution_count": 13, 66 | "metadata": {}, 67 | "outputs": [], 68 | "source": [ 69 | "from sklearn.cluster import KMeans\n", 70 | "kmedias = KMeans(n_clusters=6).fit(X_train)\n", 71 | "centros = kmedias.cluster_centers_" 72 | ] 73 | }, 74 | { 75 | "cell_type": "code", 76 | "execution_count": 14, 77 | "metadata": {}, 78 | "outputs": [ 79 | { 80 | "data": { 81 | "text/plain": [ 82 | "array([[0.33216374, 0.63658322, 0.55496138, 0.58476518, 0.28743961,\n", 83 | " 0.59923372, 0.52344116, 0.44025157, 0.56642131, 0.15822905,\n", 84 | " 0.35953026, 0.66992267, 0.14098906],\n", 85 | " [0.30797697, 0.16606966, 0.48128342, 0.51449742, 0.24592391,\n", 86 | " 0.39881466, 0.34236551, 0.40625 , 0.37569006, 0.14193153,\n", 87 | " 0.46392276, 0.59375 , 0.16614658],\n", 88 | " [0.77539474, 0.22401186, 0.57647059, 0.31649485, 0.37880435,\n", 89 | " 0.69465517, 0.62004219, 0.26886792, 0.57413249, 0.44001706,\n", 90 | " 0.50406504, 0.63461538, 0.70139087],\n", 91 | " [0.50626566, 0.45586298, 0.52126305, 0.48576338, 0.28416149,\n", 92 | " 0.23809524, 0.09694595, 0.71069182, 0.17425267, 0.31244921,\n", 93 | " 0.25783972, 0.18367347, 0.22124856],\n", 94 | " [0.63634868, 0.5444664 , 0.59959893, 0.57313144, 0.31725543,\n", 95 | " 0.28340517, 0.1119462 , 0.60966981, 0.32492114, 0.71096416,\n", 96 | " 0.10670732, 0.14010989, 0.25953994],\n", 97 | " [0.65223684, 0.21610672, 0.5868984 , 0.39871134, 0.39130435,\n", 98 | " 0.6012069 , 0.50685654, 0.35283019, 0.41514196, 0.29035836,\n", 99 | " 0.49065041, 0.69230769, 0.51776034]])" 100 | ] 101 | }, 102 | "execution_count": 14, 103 | "metadata": {}, 104 | "output_type": "execute_result" 105 | } 106 | ], 107 | "source": [ 108 | "centros" 109 | ] 110 | }, 111 | { 112 | "cell_type": "markdown", 113 | "metadata": {}, 114 | "source": [ 115 | "# Matriz de distancias - SIGMA" 116 | ] 117 | }, 118 | { 119 | "cell_type": "code", 120 | "execution_count": 15, 121 | "metadata": {}, 122 | "outputs": [], 123 | "source": [ 124 | "from sklearn.metrics.pairwise import euclidean_distances\n", 125 | "distancias = euclidean_distances(centros)\n", 126 | "sigma = sum(distancias)/(centros.shape[0]-1)" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 16, 132 | "metadata": {}, 133 | "outputs": [ 134 | { 135 | "data": { 136 | "text/plain": [ 137 | "array([0.85810088, 0.79314121, 0.94171946, 0.88927048, 0.97776535,\n", 138 | " 0.76089675])" 139 | ] 140 | }, 141 | "execution_count": 16, 142 | "metadata": {}, 143 | "output_type": "execute_result" 144 | } 145 | ], 146 | "source": [ 147 | "sigma" 148 | ] 149 | }, 150 | { 151 | "cell_type": "markdown", 152 | "metadata": {}, 153 | "source": [ 154 | "# Salida capa OCULTA datos entrenamiento" 155 | ] 156 | }, 157 | { 158 | "cell_type": "code", 159 | "execution_count": 17, 160 | "metadata": {}, 161 | "outputs": [], 162 | "source": [ 163 | "X_mlp_train = np.zeros((X_train.shape[0], centros.shape[0]), dtype=float)\n", 164 | "for i in range(X_train.shape[0]):\n", 165 | " for j in range(centros.shape[0]):\n", 166 | " X_mlp_train[i][j] = np.exp(-sum((X_train[i]-centros[j])**2)/(2.0*(sigma[j]**2)))" 167 | ] 168 | }, 169 | { 170 | "cell_type": "markdown", 171 | "metadata": {}, 172 | "source": [ 173 | "# Salida capa OCULTA datos test" 174 | ] 175 | }, 176 | { 177 | "cell_type": "code", 178 | "execution_count": 18, 179 | "metadata": {}, 180 | "outputs": [], 181 | "source": [ 182 | "X_mlp_test = np.zeros((X_test.shape[0], centros.shape[0]), dtype=float)\n", 183 | "for i in range(X_test.shape[0]):\n", 184 | " for j in range(centros.shape[0]):\n", 185 | " X_mlp_test[i][j] = np.exp(-sum((X_test[i]-centros[j])**2)/(2.0*(sigma[j]**2)))" 186 | ] 187 | }, 188 | { 189 | "cell_type": "markdown", 190 | "metadata": {}, 191 | "source": [ 192 | "# Binarización de las salidas" 193 | ] 194 | }, 195 | { 196 | "cell_type": "code", 197 | "execution_count": 19, 198 | "metadata": {}, 199 | "outputs": [ 200 | { 201 | "data": { 202 | "text/plain": [ 203 | "LabelBinarizer(neg_label=0, pos_label=1, sparse_output=False)" 204 | ] 205 | }, 206 | "execution_count": 19, 207 | "metadata": {}, 208 | "output_type": "execute_result" 209 | } 210 | ], 211 | "source": [ 212 | "from sklearn.preprocessing import LabelBinarizer\n", 213 | "etiquetas = LabelBinarizer()\n", 214 | "etiquetas.fit([1,2,3])" 215 | ] 216 | }, 217 | { 218 | "cell_type": "code", 219 | "execution_count": 20, 220 | "metadata": {}, 221 | "outputs": [], 222 | "source": [ 223 | "Ymlp = etiquetas.transform(Y)\n", 224 | "Y_mlp_train = etiquetas.transform(Y_train)\n", 225 | "Y_mlp_test = etiquetas.transform(Y_test)" 226 | ] 227 | }, 228 | { 229 | "cell_type": "code", 230 | "execution_count": 21, 231 | "metadata": {}, 232 | "outputs": [ 233 | { 234 | "data": { 235 | "text/plain": [ 236 | "((118, 6), (60, 6), (118, 3), (60, 3))" 237 | ] 238 | }, 239 | "execution_count": 21, 240 | "metadata": {}, 241 | "output_type": "execute_result" 242 | } 243 | ], 244 | "source": [ 245 | "X_mlp_train.shape, X_mlp_test.shape, Y_mlp_train.shape, Y_mlp_test.shape" 246 | ] 247 | }, 248 | { 249 | "cell_type": "markdown", 250 | "metadata": {}, 251 | "source": [ 252 | "# Adaline con SGD" 253 | ] 254 | }, 255 | { 256 | "cell_type": "code", 257 | "execution_count": 23, 258 | "metadata": {}, 259 | "outputs": [], 260 | "source": [ 261 | "from sklearn.linear_model import SGDRegressor\n", 262 | "adaline = SGDRegressor(max_iter=5000)" 263 | ] 264 | }, 265 | { 266 | "cell_type": "code", 267 | "execution_count": 24, 268 | "metadata": {}, 269 | "outputs": [], 270 | "source": [ 271 | "Yp_test = np.zeros((Y_test.shape[0],3))" 272 | ] 273 | }, 274 | { 275 | "cell_type": "code", 276 | "execution_count": 25, 277 | "metadata": {}, 278 | "outputs": [], 279 | "source": [ 280 | "for neurona_salida in range(3):\n", 281 | " adaline.fit(X_mlp_train,Y_mlp_train[:,neurona_salida])\n", 282 | " Yp_test[:,neurona_salida] = adaline.predict(X_mlp_test)" 283 | ] 284 | }, 285 | { 286 | "cell_type": "code", 287 | "execution_count": 26, 288 | "metadata": {}, 289 | "outputs": [], 290 | "source": [ 291 | "aciertos = sum(np.argmax(Yp_test, axis=1) == np.argmax(Y_mlp_test,axis=1)) / Y_mlp_test.shape[0]" 292 | ] 293 | }, 294 | { 295 | "cell_type": "code", 296 | "execution_count": 27, 297 | "metadata": {}, 298 | "outputs": [ 299 | { 300 | "name": "stdout", 301 | "output_type": "stream", 302 | "text": [ 303 | "Tasa de aciertos = 100.0 %\n" 304 | ] 305 | } 306 | ], 307 | "source": [ 308 | "print(\"Tasa de aciertos =\",aciertos*100, \"%\")" 309 | ] 310 | } 311 | ], 312 | "metadata": { 313 | "kernelspec": { 314 | "display_name": "Python 3", 315 | "language": "python", 316 | "name": "python3" 317 | }, 318 | "language_info": { 319 | "codemirror_mode": { 320 | "name": "ipython", 321 | "version": 3 322 | }, 323 | "file_extension": ".py", 324 | "mimetype": "text/x-python", 325 | "name": "python", 326 | "nbconvert_exporter": "python", 327 | "pygments_lexer": "ipython3", 328 | "version": "3.7.3" 329 | } 330 | }, 331 | "nbformat": 4, 332 | "nbformat_minor": 2 333 | } 334 | -------------------------------------------------------------------------------- /machine.data: -------------------------------------------------------------------------------- 1 | adviser,32/60,125,256,6000,256,16,128,198,199 2 | amdahl,470v/7,29,8000,32000,32,8,32,269,253 3 | amdahl,470v/7a,29,8000,32000,32,8,32,220,253 4 | amdahl,470v/7b,29,8000,32000,32,8,32,172,253 5 | amdahl,470v/7c,29,8000,16000,32,8,16,132,132 6 | amdahl,470v/b,26,8000,32000,64,8,32,318,290 7 | amdahl,580-5840,23,16000,32000,64,16,32,367,381 8 | amdahl,580-5850,23,16000,32000,64,16,32,489,381 9 | amdahl,580-5860,23,16000,64000,64,16,32,636,749 10 | amdahl,580-5880,23,32000,64000,128,32,64,1144,1238 11 | apollo,dn320,400,1000,3000,0,1,2,38,23 12 | apollo,dn420,400,512,3500,4,1,6,40,24 13 | basf,7/65,60,2000,8000,65,1,8,92,70 14 | basf,7/68,50,4000,16000,65,1,8,138,117 15 | bti,5000,350,64,64,0,1,4,10,15 16 | bti,8000,200,512,16000,0,4,32,35,64 17 | burroughs,b1955,167,524,2000,8,4,15,19,23 18 | burroughs,b2900,143,512,5000,0,7,32,28,29 19 | burroughs,b2925,143,1000,2000,0,5,16,31,22 20 | burroughs,b4955,110,5000,5000,142,8,64,120,124 21 | burroughs,b5900,143,1500,6300,0,5,32,30,35 22 | burroughs,b5920,143,3100,6200,0,5,20,33,39 23 | burroughs,b6900,143,2300,6200,0,6,64,61,40 24 | burroughs,b6925,110,3100,6200,0,6,64,76,45 25 | c.r.d,68/10-80,320,128,6000,0,1,12,23,28 26 | c.r.d,universe:2203t,320,512,2000,4,1,3,69,21 27 | c.r.d,universe:68,320,256,6000,0,1,6,33,28 28 | c.r.d,universe:68/05,320,256,3000,4,1,3,27,22 29 | c.r.d,universe:68/137,320,512,5000,4,1,5,77,28 30 | c.r.d,universe:68/37,320,256,5000,4,1,6,27,27 31 | cdc,cyber:170/750,25,1310,2620,131,12,24,274,102 32 | cdc,cyber:170/760,25,1310,2620,131,12,24,368,102 33 | cdc,cyber:170/815,50,2620,10480,30,12,24,32,74 34 | cdc,cyber:170/825,50,2620,10480,30,12,24,63,74 35 | cdc,cyber:170/835,56,5240,20970,30,12,24,106,138 36 | cdc,cyber:170/845,64,5240,20970,30,12,24,208,136 37 | cdc,omega:480-i,50,500,2000,8,1,4,20,23 38 | cdc,omega:480-ii,50,1000,4000,8,1,5,29,29 39 | cdc,omega:480-iii,50,2000,8000,8,1,5,71,44 40 | cambex,1636-1,50,1000,4000,8,3,5,26,30 41 | cambex,1636-10,50,1000,8000,8,3,5,36,41 42 | cambex,1641-1,50,2000,16000,8,3,5,40,74 43 | cambex,1641-11,50,2000,16000,8,3,6,52,74 44 | cambex,1651-1,50,2000,16000,8,3,6,60,74 45 | dec,decsys:10:1091,133,1000,12000,9,3,12,72,54 46 | dec,decsys:20:2060,133,1000,8000,9,3,12,72,41 47 | dec,microvax-1,810,512,512,8,1,1,18,18 48 | dec,vax:11/730,810,1000,5000,0,1,1,20,28 49 | dec,vax:11/750,320,512,8000,4,1,5,40,36 50 | dec,vax:11/780,200,512,8000,8,1,8,62,38 51 | dg,eclipse:c/350,700,384,8000,0,1,1,24,34 52 | dg,eclipse:m/600,700,256,2000,0,1,1,24,19 53 | dg,eclipse:mv/10000,140,1000,16000,16,1,3,138,72 54 | dg,eclipse:mv/4000,200,1000,8000,0,1,2,36,36 55 | dg,eclipse:mv/6000,110,1000,4000,16,1,2,26,30 56 | dg,eclipse:mv/8000,110,1000,12000,16,1,2,60,56 57 | dg,eclipse:mv/8000-ii,220,1000,8000,16,1,2,71,42 58 | formation,f4000/100,800,256,8000,0,1,4,12,34 59 | formation,f4000/200,800,256,8000,0,1,4,14,34 60 | formation,f4000/200ap,800,256,8000,0,1,4,20,34 61 | formation,f4000/300,800,256,8000,0,1,4,16,34 62 | formation,f4000/300ap,800,256,8000,0,1,4,22,34 63 | four-phase,2000/260,125,512,1000,0,8,20,36,19 64 | gould,concept:32/8705,75,2000,8000,64,1,38,144,75 65 | gould,concept:32/8750,75,2000,16000,64,1,38,144,113 66 | gould,concept:32/8780,75,2000,16000,128,1,38,259,157 67 | hp,3000/30,90,256,1000,0,3,10,17,18 68 | hp,3000/40,105,256,2000,0,3,10,26,20 69 | hp,3000/44,105,1000,4000,0,3,24,32,28 70 | hp,3000/48,105,2000,4000,8,3,19,32,33 71 | hp,3000/64,75,2000,8000,8,3,24,62,47 72 | hp,3000/88,75,3000,8000,8,3,48,64,54 73 | hp,3000/iii,175,256,2000,0,3,24,22,20 74 | harris,100,300,768,3000,0,6,24,36,23 75 | harris,300,300,768,3000,6,6,24,44,25 76 | harris,500,300,768,12000,6,6,24,50,52 77 | harris,600,300,768,4500,0,1,24,45,27 78 | harris,700,300,384,12000,6,1,24,53,50 79 | harris,80,300,192,768,6,6,24,36,18 80 | harris,800,180,768,12000,6,1,31,84,53 81 | honeywell,dps:6/35,330,1000,3000,0,2,4,16,23 82 | honeywell,dps:6/92,300,1000,4000,8,3,64,38,30 83 | honeywell,dps:6/96,300,1000,16000,8,2,112,38,73 84 | honeywell,dps:7/35,330,1000,2000,0,1,2,16,20 85 | honeywell,dps:7/45,330,1000,4000,0,3,6,22,25 86 | honeywell,dps:7/55,140,2000,4000,0,3,6,29,28 87 | honeywell,dps:7/65,140,2000,4000,0,4,8,40,29 88 | honeywell,dps:8/44,140,2000,4000,8,1,20,35,32 89 | honeywell,dps:8/49,140,2000,32000,32,1,20,134,175 90 | honeywell,dps:8/50,140,2000,8000,32,1,54,66,57 91 | honeywell,dps:8/52,140,2000,32000,32,1,54,141,181 92 | honeywell,dps:8/62,140,2000,32000,32,1,54,189,181 93 | honeywell,dps:8/20,140,2000,4000,8,1,20,22,32 94 | ibm,3033:s,57,4000,16000,1,6,12,132,82 95 | ibm,3033:u,57,4000,24000,64,12,16,237,171 96 | ibm,3081,26,16000,32000,64,16,24,465,361 97 | ibm,3081:d,26,16000,32000,64,8,24,465,350 98 | ibm,3083:b,26,8000,32000,0,8,24,277,220 99 | ibm,3083:e,26,8000,16000,0,8,16,185,113 100 | ibm,370/125-2,480,96,512,0,1,1,6,15 101 | ibm,370/148,203,1000,2000,0,1,5,24,21 102 | ibm,370/158-3,115,512,6000,16,1,6,45,35 103 | ibm,38/3,1100,512,1500,0,1,1,7,18 104 | ibm,38/4,1100,768,2000,0,1,1,13,20 105 | ibm,38/5,600,768,2000,0,1,1,16,20 106 | ibm,38/7,400,2000,4000,0,1,1,32,28 107 | ibm,38/8,400,4000,8000,0,1,1,32,45 108 | ibm,4321,900,1000,1000,0,1,2,11,18 109 | ibm,4331-1,900,512,1000,0,1,2,11,17 110 | ibm,4331-11,900,1000,4000,4,1,2,18,26 111 | ibm,4331-2,900,1000,4000,8,1,2,22,28 112 | ibm,4341,900,2000,4000,0,3,6,37,28 113 | ibm,4341-1,225,2000,4000,8,3,6,40,31 114 | ibm,4341-10,225,2000,4000,8,3,6,34,31 115 | ibm,4341-11,180,2000,8000,8,1,6,50,42 116 | ibm,4341-12,185,2000,16000,16,1,6,76,76 117 | ibm,4341-2,180,2000,16000,16,1,6,66,76 118 | ibm,4341-9,225,1000,4000,2,3,6,24,26 119 | ibm,4361-4,25,2000,12000,8,1,4,49,59 120 | ibm,4361-5,25,2000,12000,16,3,5,66,65 121 | ibm,4381-1,17,4000,16000,8,6,12,100,101 122 | ibm,4381-2,17,4000,16000,32,6,12,133,116 123 | ibm,8130-a,1500,768,1000,0,0,0,12,18 124 | ibm,8130-b,1500,768,2000,0,0,0,18,20 125 | ibm,8140,800,768,2000,0,0,0,20,20 126 | ipl,4436,50,2000,4000,0,3,6,27,30 127 | ipl,4443,50,2000,8000,8,3,6,45,44 128 | ipl,4445,50,2000,8000,8,1,6,56,44 129 | ipl,4446,50,2000,16000,24,1,6,70,82 130 | ipl,4460,50,2000,16000,24,1,6,80,82 131 | ipl,4480,50,8000,16000,48,1,10,136,128 132 | magnuson,m80/30,100,1000,8000,0,2,6,16,37 133 | magnuson,m80/31,100,1000,8000,24,2,6,26,46 134 | magnuson,m80/32,100,1000,8000,24,3,6,32,46 135 | magnuson,m80/42,50,2000,16000,12,3,16,45,80 136 | magnuson,m80/43,50,2000,16000,24,6,16,54,88 137 | magnuson,m80/44,50,2000,16000,24,6,16,65,88 138 | microdata,seq.ms/3200,150,512,4000,0,8,128,30,33 139 | nas,as/3000,115,2000,8000,16,1,3,50,46 140 | nas,as/3000-n,115,2000,4000,2,1,5,40,29 141 | nas,as/5000,92,2000,8000,32,1,6,62,53 142 | nas,as/5000-e,92,2000,8000,32,1,6,60,53 143 | nas,as/5000-n,92,2000,8000,4,1,6,50,41 144 | nas,as/6130,75,4000,16000,16,1,6,66,86 145 | nas,as/6150,60,4000,16000,32,1,6,86,95 146 | nas,as/6620,60,2000,16000,64,5,8,74,107 147 | nas,as/6630,60,4000,16000,64,5,8,93,117 148 | nas,as/6650,50,4000,16000,64,5,10,111,119 149 | nas,as/7000,72,4000,16000,64,8,16,143,120 150 | nas,as/7000-n,72,2000,8000,16,6,8,105,48 151 | nas,as/8040,40,8000,16000,32,8,16,214,126 152 | nas,as/8050,40,8000,32000,64,8,24,277,266 153 | nas,as/8060,35,8000,32000,64,8,24,370,270 154 | nas,as/9000-dpc,38,16000,32000,128,16,32,510,426 155 | nas,as/9000-n,48,4000,24000,32,8,24,214,151 156 | nas,as/9040,38,8000,32000,64,8,24,326,267 157 | nas,as/9060,30,16000,32000,256,16,24,510,603 158 | ncr,v8535:ii,112,1000,1000,0,1,4,8,19 159 | ncr,v8545:ii,84,1000,2000,0,1,6,12,21 160 | ncr,v8555:ii,56,1000,4000,0,1,6,17,26 161 | ncr,v8565:ii,56,2000,6000,0,1,8,21,35 162 | ncr,v8565:ii-e,56,2000,8000,0,1,8,24,41 163 | ncr,v8575:ii,56,4000,8000,0,1,8,34,47 164 | ncr,v8585:ii,56,4000,12000,0,1,8,42,62 165 | ncr,v8595:ii,56,4000,16000,0,1,8,46,78 166 | ncr,v8635,38,4000,8000,32,16,32,51,80 167 | ncr,v8650,38,4000,8000,32,16,32,116,80 168 | ncr,v8655,38,8000,16000,64,4,8,100,142 169 | ncr,v8665,38,8000,24000,160,4,8,140,281 170 | ncr,v8670,38,4000,16000,128,16,32,212,190 171 | nixdorf,8890/30,200,1000,2000,0,1,2,25,21 172 | nixdorf,8890/50,200,1000,4000,0,1,4,30,25 173 | nixdorf,8890/70,200,2000,8000,64,1,5,41,67 174 | perkin-elmer,3205,250,512,4000,0,1,7,25,24 175 | perkin-elmer,3210,250,512,4000,0,4,7,50,24 176 | perkin-elmer,3230,250,1000,16000,1,1,8,50,64 177 | prime,50-2250,160,512,4000,2,1,5,30,25 178 | prime,50-250-ii,160,512,2000,2,3,8,32,20 179 | prime,50-550-ii,160,1000,4000,8,1,14,38,29 180 | prime,50-750-ii,160,1000,8000,16,1,14,60,43 181 | prime,50-850-ii,160,2000,8000,32,1,13,109,53 182 | siemens,7.521,240,512,1000,8,1,3,6,19 183 | siemens,7.531,240,512,2000,8,1,5,11,22 184 | siemens,7.536,105,2000,4000,8,3,8,22,31 185 | siemens,7.541,105,2000,6000,16,6,16,33,41 186 | siemens,7.551,105,2000,8000,16,4,14,58,47 187 | siemens,7.561,52,4000,16000,32,4,12,130,99 188 | siemens,7.865-2,70,4000,12000,8,6,8,75,67 189 | siemens,7.870-2,59,4000,12000,32,6,12,113,81 190 | siemens,7.872-2,59,8000,16000,64,12,24,188,149 191 | siemens,7.875-2,26,8000,24000,32,8,16,173,183 192 | siemens,7.880-2,26,8000,32000,64,12,16,248,275 193 | siemens,7.881-2,26,8000,32000,128,24,32,405,382 194 | sperry,1100/61-h1,116,2000,8000,32,5,28,70,56 195 | sperry,1100/81,50,2000,32000,24,6,26,114,182 196 | sperry,1100/82,50,2000,32000,48,26,52,208,227 197 | sperry,1100/83,50,2000,32000,112,52,104,307,341 198 | sperry,1100/84,50,4000,32000,112,52,104,397,360 199 | sperry,1100/93,30,8000,64000,96,12,176,915,919 200 | sperry,1100/94,30,8000,64000,128,12,176,1150,978 201 | sperry,80/3,180,262,4000,0,1,3,12,24 202 | sperry,80/4,180,512,4000,0,1,3,14,24 203 | sperry,80/5,180,262,4000,0,1,3,18,24 204 | sperry,80/6,180,512,4000,0,1,3,21,24 205 | sperry,80/8,124,1000,8000,0,1,8,42,37 206 | sperry,90/80-model-3,98,1000,8000,32,2,8,46,50 207 | sratus,32,125,2000,8000,0,2,14,52,41 208 | wang,vs-100,480,512,8000,32,0,0,67,47 209 | wang,vs-90,480,1000,4000,0,0,0,45,25 210 | -------------------------------------------------------------------------------- /Regresion Lineal Multiple y Logistica.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Práctica Regresión Lineal, Múltiple y Logística\n", 8 | "\n", 9 | "Autor: Adrián Arroyo Calle\n", 10 | "\n", 11 | "\n" 12 | ] 13 | }, 14 | { 15 | "cell_type": "markdown", 16 | "metadata": {}, 17 | "source": [ 18 | "Usando el conocido conjunto de datos IRIS, realice una clasificación mediante regresión lineal múltiple. Para ello, se destinará ⅔ de los datos escogidos aleatoriamente de manera estratificada para aprendizaje y, el resto, para verificación." 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 42, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "import numpy as np\n", 28 | "from sklearn.datasets import load_iris\n", 29 | "from sklearn.preprocessing import MinMaxScaler\n", 30 | "from sklearn.model_selection import train_test_split\n", 31 | "from sklearn.linear_model import LinearRegression, LogisticRegression\n", 32 | "\n", 33 | "from sklearn.metrics import confusion_matrix\n", 34 | "from sklearn.metrics import accuracy_score\n", 35 | "\n", 36 | "from sklearn.model_selection import StratifiedKFold" 37 | ] 38 | }, 39 | { 40 | "cell_type": "markdown", 41 | "metadata": {}, 42 | "source": [ 43 | "Cargamos el dataset IRIS" 44 | ] 45 | }, 46 | { 47 | "cell_type": "code", 48 | "execution_count": 43, 49 | "metadata": {}, 50 | "outputs": [], 51 | "source": [ 52 | "iris = load_iris(return_X_y=False)" 53 | ] 54 | }, 55 | { 56 | "cell_type": "markdown", 57 | "metadata": {}, 58 | "source": [ 59 | "Normalizamos la entrada al rango `[0,1]`" 60 | ] 61 | }, 62 | { 63 | "cell_type": "code", 64 | "execution_count": 44, 65 | "metadata": {}, 66 | "outputs": [], 67 | "source": [ 68 | "scaler = MinMaxScaler()\n", 69 | "scaled_iris_data = scaler.fit_transform(iris.data)" 70 | ] 71 | }, 72 | { 73 | "cell_type": "markdown", 74 | "metadata": {}, 75 | "source": [ 76 | "Binarizamos las clases de salida, para usar varios regresores lineales" 77 | ] 78 | }, 79 | { 80 | "cell_type": "code", 81 | "execution_count": 45, 82 | "metadata": { 83 | "scrolled": true 84 | }, 85 | "outputs": [], 86 | "source": [ 87 | "from sklearn.preprocessing import LabelBinarizer\n", 88 | "\n", 89 | "lb = LabelBinarizer()\n", 90 | "bin_iris_target = lb.fit_transform(iris.target)" 91 | ] 92 | }, 93 | { 94 | "cell_type": "markdown", 95 | "metadata": {}, 96 | "source": [ 97 | "Hacemos la separación Holdout 33%, estratificada" 98 | ] 99 | }, 100 | { 101 | "cell_type": "code", 102 | "execution_count": 46, 103 | "metadata": {}, 104 | "outputs": [], 105 | "source": [ 106 | "x_train,x_test,y_train,y_test = train_test_split(scaled_iris_data,bin_iris_target,test_size=0.33,stratify=bin_iris_target)" 107 | ] 108 | }, 109 | { 110 | "cell_type": "code", 111 | "execution_count": 47, 112 | "metadata": {}, 113 | "outputs": [ 114 | { 115 | "data": { 116 | "text/plain": [ 117 | "3" 118 | ] 119 | }, 120 | "execution_count": 47, 121 | "metadata": {}, 122 | "output_type": "execute_result" 123 | } 124 | ], 125 | "source": [ 126 | "y_test.shape[1]" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 48, 132 | "metadata": {}, 133 | "outputs": [], 134 | "source": [ 135 | "y_predict = np.zeros(y_test.shape, dtype=float)\n", 136 | "for i in range(y_test.shape[1]):\n", 137 | " reg = LinearRegression()\n", 138 | " reg.fit(x_train,y_train[:,i])\n", 139 | " y_predict[:,i] = reg.predict(x_test)" 140 | ] 141 | }, 142 | { 143 | "cell_type": "markdown", 144 | "metadata": {}, 145 | "source": [ 146 | "Ahora con los datos de prueba analizamos con qué regresor se obtiene más probabilidad" 147 | ] 148 | }, 149 | { 150 | "cell_type": "code", 151 | "execution_count": 49, 152 | "metadata": {}, 153 | "outputs": [ 154 | { 155 | "name": "stdout", 156 | "output_type": "stream", 157 | "text": [ 158 | "Tasa de acierto 0.820000\n" 159 | ] 160 | } 161 | ], 162 | "source": [ 163 | "score = np.sum(np.argmax(y_predict,axis=1) == np.argmax(y_test, axis=1))/y_test.shape[0]\n", 164 | "print(\"Tasa de acierto %f\" % score)" 165 | ] 166 | }, 167 | { 168 | "cell_type": "markdown", 169 | "metadata": {}, 170 | "source": [ 171 | "Matriz de confusión" 172 | ] 173 | }, 174 | { 175 | "cell_type": "code", 176 | "execution_count": 50, 177 | "metadata": {}, 178 | "outputs": [ 179 | { 180 | "data": { 181 | "text/plain": [ 182 | "array([[16, 1, 0],\n", 183 | " [ 0, 13, 4],\n", 184 | " [ 0, 4, 12]])" 185 | ] 186 | }, 187 | "execution_count": 50, 188 | "metadata": {}, 189 | "output_type": "execute_result" 190 | } 191 | ], 192 | "source": [ 193 | "s = accuracy_score(np.argmax(y_test,axis=1), np.argmax(y_predict, axis=1))\n", 194 | "m = confusion_matrix(np.argmax(y_test,axis=1), np.argmax(y_predict, axis=1))\n", 195 | "m" 196 | ] 197 | }, 198 | { 199 | "cell_type": "markdown", 200 | "metadata": {}, 201 | "source": [ 202 | "Validación cruzada" 203 | ] 204 | }, 205 | { 206 | "cell_type": "code", 207 | "execution_count": 51, 208 | "metadata": {}, 209 | "outputs": [ 210 | { 211 | "name": "stdout", 212 | "output_type": "stream", 213 | "text": [ 214 | "Tasa de acierto: 0.826667\n" 215 | ] 216 | } 217 | ], 218 | "source": [ 219 | "score = 0\n", 220 | "skf = StratifiedKFold(n_splits=10)\n", 221 | "for train_index, test_index in skf.split(scaled_iris_data,iris.target):\n", 222 | " x_train, x_test = scaled_iris_data[train_index], scaled_iris_data[test_index]\n", 223 | " y_train, y_test = bin_iris_target[train_index], bin_iris_target[test_index]\n", 224 | " y_predict = np.zeros(y_test.shape,dtype=float)\n", 225 | " for i in range(y_test.shape[1]):\n", 226 | " reg = LinearRegression()\n", 227 | " reg.fit(x_train,y_train[:,i])\n", 228 | " y_predict[:,i] = reg.predict(x_test)\n", 229 | " score += accuracy_score(np.argmax(y_test,axis=1), np.argmax(y_predict, axis=1))\n", 230 | "print(\"Tasa de acierto: %f\" % (score/10))" 231 | ] 232 | }, 233 | { 234 | "cell_type": "markdown", 235 | "metadata": {}, 236 | "source": [ 237 | "Regresión logística" 238 | ] 239 | }, 240 | { 241 | "cell_type": "markdown", 242 | "metadata": {}, 243 | "source": [ 244 | "Método holdout" 245 | ] 246 | }, 247 | { 248 | "cell_type": "code", 249 | "execution_count": 52, 250 | "metadata": {}, 251 | "outputs": [], 252 | "source": [ 253 | "x_train,x_test,y_train,y_test = train_test_split(scaled_iris_data,iris.target,test_size=0.33,stratify=iris.target)" 254 | ] 255 | }, 256 | { 257 | "cell_type": "code", 258 | "execution_count": 53, 259 | "metadata": {}, 260 | "outputs": [ 261 | { 262 | "name": "stdout", 263 | "output_type": "stream", 264 | "text": [ 265 | "Score: 0.820000\n" 266 | ] 267 | } 268 | ], 269 | "source": [ 270 | "y_predict = np.zeros(y_test.shape,dtype=float)\n", 271 | "clf = LogisticRegression()\n", 272 | "clf.fit(x_train,y_train)\n", 273 | "y_predict = clf.predict(x_test)\n", 274 | "score = accuracy_score(y_test, y_predict)\n", 275 | "print(\"Score: %f\" % score)" 276 | ] 277 | }, 278 | { 279 | "cell_type": "code", 280 | "execution_count": 54, 281 | "metadata": {}, 282 | "outputs": [ 283 | { 284 | "data": { 285 | "text/plain": [ 286 | "array([[17, 0, 0],\n", 287 | " [ 0, 9, 7],\n", 288 | " [ 0, 2, 15]])" 289 | ] 290 | }, 291 | "execution_count": 54, 292 | "metadata": {}, 293 | "output_type": "execute_result" 294 | } 295 | ], 296 | "source": [ 297 | "m = confusion_matrix(y_test, y_predict)\n", 298 | "m" 299 | ] 300 | }, 301 | { 302 | "cell_type": "markdown", 303 | "metadata": {}, 304 | "source": [ 305 | "Validación cruzada" 306 | ] 307 | }, 308 | { 309 | "cell_type": "code", 310 | "execution_count": 55, 311 | "metadata": {}, 312 | "outputs": [ 313 | { 314 | "name": "stdout", 315 | "output_type": "stream", 316 | "text": [ 317 | "Tasa de acierto: 0.840000\n" 318 | ] 319 | } 320 | ], 321 | "source": [ 322 | "score = 0\n", 323 | "skf = StratifiedKFold(n_splits=10)\n", 324 | "for train_index, test_index in skf.split(scaled_iris_data,iris.target):\n", 325 | " x_train, x_test = scaled_iris_data[train_index], scaled_iris_data[test_index]\n", 326 | " y_train, y_test = iris.target[train_index], iris.target[test_index]\n", 327 | " y_predict = np.zeros(y_test.shape,dtype=float)\n", 328 | " reg = LogisticRegression()\n", 329 | " reg.fit(x_train,y_train)\n", 330 | " y_predict = reg.predict(x_test)\n", 331 | " score += accuracy_score(y_test, y_predict)\n", 332 | "print(\"Tasa de acierto: %f\" % (score/10))" 333 | ] 334 | } 335 | ], 336 | "metadata": { 337 | "kernelspec": { 338 | "display_name": "Python 3", 339 | "language": "python", 340 | "name": "python3" 341 | }, 342 | "language_info": { 343 | "codemirror_mode": { 344 | "name": "ipython", 345 | "version": 3 346 | }, 347 | "file_extension": ".py", 348 | "mimetype": "text/x-python", 349 | "name": "python", 350 | "nbconvert_exporter": "python", 351 | "pygments_lexer": "ipython3", 352 | "version": "3.7.3" 353 | } 354 | }, 355 | "nbformat": 4, 356 | "nbformat_minor": 2 357 | } 358 | -------------------------------------------------------------------------------- /IRIS decision tree.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 2, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import numpy as np\n", 10 | "from sklearn import datasets" 11 | ] 12 | }, 13 | { 14 | "cell_type": "code", 15 | "execution_count": 3, 16 | "metadata": {}, 17 | "outputs": [], 18 | "source": [ 19 | "iris = datasets.load_iris()" 20 | ] 21 | }, 22 | { 23 | "cell_type": "code", 24 | "execution_count": 5, 25 | "metadata": {}, 26 | "outputs": [ 27 | { 28 | "name": "stdout", 29 | "output_type": "stream", 30 | "text": [ 31 | ".. _iris_dataset:\n", 32 | "\n", 33 | "Iris plants dataset\n", 34 | "--------------------\n", 35 | "\n", 36 | "**Data Set Characteristics:**\n", 37 | "\n", 38 | " :Number of Instances: 150 (50 in each of three classes)\n", 39 | " :Number of Attributes: 4 numeric, predictive attributes and the class\n", 40 | " :Attribute Information:\n", 41 | " - sepal length in cm\n", 42 | " - sepal width in cm\n", 43 | " - petal length in cm\n", 44 | " - petal width in cm\n", 45 | " - class:\n", 46 | " - Iris-Setosa\n", 47 | " - Iris-Versicolour\n", 48 | " - Iris-Virginica\n", 49 | " \n", 50 | " :Summary Statistics:\n", 51 | "\n", 52 | " ============== ==== ==== ======= ===== ====================\n", 53 | " Min Max Mean SD Class Correlation\n", 54 | " ============== ==== ==== ======= ===== ====================\n", 55 | " sepal length: 4.3 7.9 5.84 0.83 0.7826\n", 56 | " sepal width: 2.0 4.4 3.05 0.43 -0.4194\n", 57 | " petal length: 1.0 6.9 3.76 1.76 0.9490 (high!)\n", 58 | " petal width: 0.1 2.5 1.20 0.76 0.9565 (high!)\n", 59 | " ============== ==== ==== ======= ===== ====================\n", 60 | "\n", 61 | " :Missing Attribute Values: None\n", 62 | " :Class Distribution: 33.3% for each of 3 classes.\n", 63 | " :Creator: R.A. Fisher\n", 64 | " :Donor: Michael Marshall (MARSHALL%PLU@io.arc.nasa.gov)\n", 65 | " :Date: July, 1988\n", 66 | "\n", 67 | "The famous Iris database, first used by Sir R.A. Fisher. The dataset is taken\n", 68 | "from Fisher's paper. Note that it's the same as in R, but not as in the UCI\n", 69 | "Machine Learning Repository, which has two wrong data points.\n", 70 | "\n", 71 | "This is perhaps the best known database to be found in the\n", 72 | "pattern recognition literature. Fisher's paper is a classic in the field and\n", 73 | "is referenced frequently to this day. (See Duda & Hart, for example.) The\n", 74 | "data set contains 3 classes of 50 instances each, where each class refers to a\n", 75 | "type of iris plant. One class is linearly separable from the other 2; the\n", 76 | "latter are NOT linearly separable from each other.\n", 77 | "\n", 78 | ".. topic:: References\n", 79 | "\n", 80 | " - Fisher, R.A. \"The use of multiple measurements in taxonomic problems\"\n", 81 | " Annual Eugenics, 7, Part II, 179-188 (1936); also in \"Contributions to\n", 82 | " Mathematical Statistics\" (John Wiley, NY, 1950).\n", 83 | " - Duda, R.O., & Hart, P.E. (1973) Pattern Classification and Scene Analysis.\n", 84 | " (Q327.D83) John Wiley & Sons. ISBN 0-471-22361-1. See page 218.\n", 85 | " - Dasarathy, B.V. (1980) \"Nosing Around the Neighborhood: A New System\n", 86 | " Structure and Classification Rule for Recognition in Partially Exposed\n", 87 | " Environments\". IEEE Transactions on Pattern Analysis and Machine\n", 88 | " Intelligence, Vol. PAMI-2, No. 1, 67-71.\n", 89 | " - Gates, G.W. (1972) \"The Reduced Nearest Neighbor Rule\". IEEE Transactions\n", 90 | " on Information Theory, May 1972, 431-433.\n", 91 | " - See also: 1988 MLC Proceedings, 54-64. Cheeseman et al\"s AUTOCLASS II\n", 92 | " conceptual clustering system finds 3 classes in the data.\n", 93 | " - Many, many more ...\n" 94 | ] 95 | } 96 | ], 97 | "source": [ 98 | "print(iris.DESCR)" 99 | ] 100 | }, 101 | { 102 | "cell_type": "code", 103 | "execution_count": 6, 104 | "metadata": {}, 105 | "outputs": [], 106 | "source": [ 107 | "x = iris.data\n", 108 | "y = iris.target" 109 | ] 110 | }, 111 | { 112 | "cell_type": "code", 113 | "execution_count": 7, 114 | "metadata": {}, 115 | "outputs": [ 116 | { 117 | "data": { 118 | "text/plain": [ 119 | "((150, 4), (150,))" 120 | ] 121 | }, 122 | "execution_count": 7, 123 | "metadata": {}, 124 | "output_type": "execute_result" 125 | } 126 | ], 127 | "source": [ 128 | "x.shape, y.shape" 129 | ] 130 | }, 131 | { 132 | "cell_type": "code", 133 | "execution_count": 8, 134 | "metadata": {}, 135 | "outputs": [ 136 | { 137 | "name": "stderr", 138 | "output_type": "stream", 139 | "text": [ 140 | "/usr/lib/python3/dist-packages/sklearn/model_selection/_split.py:2179: FutureWarning: From version 0.21, test_size will always complement train_size unless both are specified.\n", 141 | " FutureWarning)\n" 142 | ] 143 | } 144 | ], 145 | "source": [ 146 | "from sklearn.model_selection import train_test_split\n", 147 | "x_train, x_test, y_train, y_test = train_test_split(x,y,train_size=2/3,stratify=y)" 148 | ] 149 | }, 150 | { 151 | "cell_type": "code", 152 | "execution_count": 9, 153 | "metadata": {}, 154 | "outputs": [ 155 | { 156 | "data": { 157 | "text/plain": [ 158 | "((100, 4), (50, 4), (100,), (50,))" 159 | ] 160 | }, 161 | "execution_count": 9, 162 | "metadata": {}, 163 | "output_type": "execute_result" 164 | } 165 | ], 166 | "source": [ 167 | "x_train.shape, x_test.shape, y_train.shape, y_test.shape" 168 | ] 169 | }, 170 | { 171 | "cell_type": "code", 172 | "execution_count": 10, 173 | "metadata": {}, 174 | "outputs": [], 175 | "source": [ 176 | "from sklearn.tree import DecisionTreeClassifier, export_graphviz\n", 177 | "arbol = DecisionTreeClassifier(criterion='entropy')" 178 | ] 179 | }, 180 | { 181 | "cell_type": "code", 182 | "execution_count": 15, 183 | "metadata": {}, 184 | "outputs": [ 185 | { 186 | "data": { 187 | "text/plain": [ 188 | "DecisionTreeClassifier(class_weight=None, criterion='entropy', max_depth=None,\n", 189 | " max_features=None, max_leaf_nodes=None,\n", 190 | " min_impurity_decrease=0.0, min_impurity_split=None,\n", 191 | " min_samples_leaf=1, min_samples_split=2,\n", 192 | " min_weight_fraction_leaf=0.0, presort=False, random_state=None,\n", 193 | " splitter='best')" 194 | ] 195 | }, 196 | "execution_count": 15, 197 | "metadata": {}, 198 | "output_type": "execute_result" 199 | } 200 | ], 201 | "source": [ 202 | "arbol.fit(x_train,y_train)" 203 | ] 204 | }, 205 | { 206 | "cell_type": "code", 207 | "execution_count": 16, 208 | "metadata": {}, 209 | "outputs": [], 210 | "source": [ 211 | "y_test_predict = arbol.predict(x_test)" 212 | ] 213 | }, 214 | { 215 | "cell_type": "code", 216 | "execution_count": 17, 217 | "metadata": {}, 218 | "outputs": [ 219 | { 220 | "data": { 221 | "text/plain": [ 222 | "array([ True, True, True, True, True, True, True, True, True,\n", 223 | " True, True, True, True, True, True, True, True, True,\n", 224 | " True, True, False, True, True, True, True, True, True,\n", 225 | " True, True, True, True, True, True, True, True, True,\n", 226 | " True, True, True, True, True, True, True, True, True,\n", 227 | " True, True, True, True, True])" 228 | ] 229 | }, 230 | "execution_count": 17, 231 | "metadata": {}, 232 | "output_type": "execute_result" 233 | } 234 | ], 235 | "source": [ 236 | "y_test_predict == y_test" 237 | ] 238 | }, 239 | { 240 | "cell_type": "code", 241 | "execution_count": 18, 242 | "metadata": {}, 243 | "outputs": [ 244 | { 245 | "data": { 246 | "text/plain": [ 247 | "0.98" 248 | ] 249 | }, 250 | "execution_count": 18, 251 | "metadata": {}, 252 | "output_type": "execute_result" 253 | } 254 | ], 255 | "source": [ 256 | "np.sum(y_test_predict == y_test)/y_test.shape[0]" 257 | ] 258 | }, 259 | { 260 | "cell_type": "code", 261 | "execution_count": 24, 262 | "metadata": {}, 263 | "outputs": [ 264 | { 265 | "name": "stdout", 266 | "output_type": "stream", 267 | "text": [ 268 | "[[17 0 0]\n", 269 | " [ 0 16 0]\n", 270 | " [ 0 1 16]]\n" 271 | ] 272 | } 273 | ], 274 | "source": [ 275 | "from sklearn.metrics import confusion_matrix\n", 276 | "cnf_matrix = confusion_matrix(y_test,y_test_predict)\n", 277 | "print(cnf_matrix)" 278 | ] 279 | }, 280 | { 281 | "cell_type": "code", 282 | "execution_count": 26, 283 | "metadata": {}, 284 | "outputs": [], 285 | "source": [ 286 | "dot_data = export_graphviz(arbol, feature_names=iris.feature_names, out_file=\"arbol.dot\")" 287 | ] 288 | }, 289 | { 290 | "cell_type": "code", 291 | "execution_count": 27, 292 | "metadata": {}, 293 | "outputs": [], 294 | "source": [ 295 | "export_graphviz?" 296 | ] 297 | } 298 | ], 299 | "metadata": { 300 | "kernelspec": { 301 | "display_name": "Python 3", 302 | "language": "python", 303 | "name": "python3" 304 | }, 305 | "language_info": { 306 | "codemirror_mode": { 307 | "name": "ipython", 308 | "version": 3 309 | }, 310 | "file_extension": ".py", 311 | "mimetype": "text/x-python", 312 | "name": "python", 313 | "nbconvert_exporter": "python", 314 | "pygments_lexer": "ipython3", 315 | "version": "3.7.2+" 316 | } 317 | }, 318 | "nbformat": 4, 319 | "nbformat_minor": 2 320 | } 321 | -------------------------------------------------------------------------------- /Datos_ Credit_100.csv: -------------------------------------------------------------------------------- 1 | PaymentHistory,WorkHistory,Reliability,Debit,Income,RatioDebInc,Assets,Worth,Profession,FutureIncome,Age,CreditWorthiness 2 | Without_Reference,Stable,Reliable,a11101_25900,s0_30000,Unfavorable,poor,Low,High_income_profession,Promissing,a66_up,Negative 3 | Without_Reference,Justified_no_work,Reliable,a0_11100,s30001_70000,Favorable,poor,Medium,High_income_profession,Promissing,a66_up,Positive 4 | Without_Reference,Stable,Unreliable,a11101_25900,s70001_more,Favorable,average,High,High_income_profession,Promissing,a16_21,Positive 5 | Aceptable,Unjustified_no_work,Unreliable,a25901_more,s70001_more,Unfavorable,average,Medium,Low_income_profession,Not_promissing,a22_65,Negative 6 | NoAceptable,Unjustified_no_work,Unreliable,a25901_more,s30001_70000,Unfavorable,poor,Medium,Low_income_profession,Not_promissing,a16_21,Negative 7 | Excellent,Unjustified_no_work,Reliable,a0_11100,s0_30000,Unfavorable,wealthy,High,Medium_income_profession,Promissing,a66_up,Positive 8 | Excellent,Justified_no_work,Reliable,a11101_25900,s30001_70000,Favorable,poor,Medium,Medium_income_profession,Not_promissing,a66_up,Positive 9 | Excellent,Unjustified_no_work,Reliable,a25901_more,s30001_70000,Unfavorable,poor,Medium,Low_income_profession,Not_promissing,a66_up,Negative 10 | Aceptable,Unstable,Reliable,a11101_25900,s0_30000,Unfavorable,poor,Low,High_income_profession,Promissing,a22_65,Positive 11 | NoAceptable,Unstable,Unreliable,a11101_25900,s30001_70000,Favorable,average,High,Medium_income_profession,Promissing,a16_21,Positive 12 | NoAceptable,Unjustified_no_work,Unreliable,a0_11100,s70001_more,Favorable,poor,High,Low_income_profession,Promissing,a66_up,Negative 13 | Excellent,Unjustified_no_work,Reliable,a0_11100,s0_30000,Favorable,wealthy,High,High_income_profession,Promissing,a16_21,Positive 14 | Excellent,Unjustified_no_work,Reliable,a25901_more,s0_30000,Unfavorable,wealthy,High,Low_income_profession,Promissing,a22_65,Positive 15 | Aceptable,Unjustified_no_work,Unreliable,a0_11100,s70001_more,Favorable,poor,High,Medium_income_profession,Not_promissing,a16_21,Negative 16 | Aceptable,Stable,Reliable,a0_11100,s30001_70000,Favorable,wealthy,High,Low_income_profession,Promissing,a22_65,Positive 17 | Without_Reference,Justified_no_work,Reliable,a11101_25900,s0_30000,Unfavorable,average,Low,Medium_income_profession,Not_promissing,a66_up,Negative 18 | NoAceptable,Justified_no_work,Unreliable,a0_11100,s30001_70000,Favorable,poor,Medium,Low_income_profession,Promissing,a16_21,Negative 19 | Without_Reference,Justified_no_work,Reliable,a0_11100,s0_30000,Unfavorable,poor,Low,Low_income_profession,Not_promissing,a16_21,Negative 20 | Without_Reference,Stable,Reliable,a11101_25900,s70001_more,Favorable,poor,High,Low_income_profession,Promissing,a66_up,Positive 21 | Excellent,Unjustified_no_work,Unreliable,a0_11100,s70001_more,Favorable,average,High,High_income_profession,Promissing,a66_up,Negative 22 | Excellent,Unjustified_no_work,Reliable,a25901_more,s0_30000,Unfavorable,poor,Low,High_income_profession,Promissing,a16_21,Positive 23 | Aceptable,Unstable,Reliable,a11101_25900,s0_30000,Unfavorable,wealthy,High,Low_income_profession,Promissing,a66_up,Positive 24 | NoAceptable,Justified_no_work,Unreliable,a11101_25900,s30001_70000,Unfavorable,average,High,High_income_profession,Promissing,a66_up,Negative 25 | Without_Reference,Unstable,Reliable,a11101_25900,s30001_70000,Favorable,average,Medium,Medium_income_profession,Not_promissing,a16_21,Positive 26 | NoAceptable,Stable,Unreliable,a0_11100,s30001_70000,Favorable,average,Medium,Medium_income_profession,Promissing,a16_21,Positive 27 | NoAceptable,Unjustified_no_work,Unreliable,a25901_more,s0_30000,Unfavorable,average,Low,Low_income_profession,Not_promissing,a66_up,Negative 28 | Without_Reference,Stable,Reliable,a0_11100,s0_30000,Unfavorable,wealthy,High,Low_income_profession,Not_promissing,a22_65,Negative 29 | NoAceptable,Unstable,Unreliable,a25901_more,s30001_70000,Unfavorable,poor,Medium,High_income_profession,Promissing,a66_up,Positive 30 | NoAceptable,Justified_no_work,Unreliable,a11101_25900,s70001_more,Favorable,average,High,High_income_profession,Promissing,a66_up,Negative 31 | Without_Reference,Unstable,Unreliable,a11101_25900,s30001_70000,Unfavorable,wealthy,High,High_income_profession,Promissing,a66_up,Negative 32 | Excellent,Justified_no_work,Reliable,a0_11100,s0_30000,Favorable,average,Low,Medium_income_profession,Not_promissing,a22_65,Positive 33 | NoAceptable,Justified_no_work,Unreliable,a25901_more,s30001_70000,Unfavorable,wealthy,High,Low_income_profession,Not_promissing,a66_up,Negative 34 | NoAceptable,Unstable,Unreliable,a11101_25900,s70001_more,Unfavorable,poor,High,High_income_profession,Promissing,a22_65,Positive 35 | NoAceptable,Unjustified_no_work,Unreliable,a11101_25900,s70001_more,Favorable,wealthy,High,Low_income_profession,Not_promissing,a66_up,Negative 36 | Without_Reference,Unstable,Unreliable,a0_11100,s70001_more,Favorable,poor,High,Low_income_profession,Not_promissing,a16_21,Negative 37 | Without_Reference,Unstable,Reliable,a25901_more,s30001_70000,Unfavorable,average,Medium,Low_income_profession,Not_promissing,a66_up,Negative 38 | Aceptable,Unstable,Unreliable,a25901_more,s0_30000,Unfavorable,poor,Medium,Low_income_profession,Not_promissing,a66_up,Negative 39 | Excellent,Unjustified_no_work,Reliable,a11101_25900,s30001_70000,Unfavorable,poor,Medium,Low_income_profession,Promissing,a22_65,Positive 40 | Aceptable,Justified_no_work,Reliable,a0_11100,s0_30000,Unfavorable,average,Low,High_income_profession,Promissing,a22_65,Positive 41 | NoAceptable,Justified_no_work,Unreliable,a0_11100,s70001_more,Favorable,poor,High,Low_income_profession,Promissing,a66_up,Positive 42 | Aceptable,Unjustified_no_work,Unreliable,a0_11100,s30001_70000,Favorable,poor,Medium,Medium_income_profession,Not_promissing,a66_up,Negative 43 | Excellent,Justified_no_work,Reliable,a25901_more,s0_30000,Unfavorable,wealthy,Low,Low_income_profession,Not_promissing,a16_21,Negative 44 | NoAceptable,Stable,Unreliable,a11101_25900,s70001_more,Unfavorable,average,Medium,High_income_profession,Promissing,a22_65,Negative 45 | NoAceptable,Unstable,Unreliable,a0_11100,s0_30000,Favorable,average,Low,Low_income_profession,Not_promissing,a22_65,Negative 46 | NoAceptable,Stable,Reliable,a0_11100,s0_30000,Favorable,average,Medium,High_income_profession,Promissing,a22_65,Positive 47 | NoAceptable,Unjustified_no_work,Unreliable,a25901_more,s0_30000,Unfavorable,wealthy,Medium,High_income_profession,Promissing,a22_65,Positive 48 | Without_Reference,Stable,Reliable,a25901_more,s0_30000,Unfavorable,wealthy,High,Medium_income_profession,Promissing,a66_up,Positive 49 | Excellent,Justified_no_work,Reliable,a11101_25900,s0_30000,Unfavorable,wealthy,Medium,High_income_profession,Promissing,a22_65,Positive 50 | Aceptable,Unjustified_no_work,Reliable,a25901_more,s70001_more,Unfavorable,poor,Medium,Medium_income_profession,Not_promissing,a22_65,Positive 51 | Aceptable,Justified_no_work,Unreliable,a25901_more,s0_30000,Unfavorable,average,Low,Low_income_profession,Not_promissing,a16_21,Negative 52 | NoAceptable,Justified_no_work,Unreliable,a11101_25900,s30001_70000,Unfavorable,poor,Medium,Medium_income_profession,Promissing,a22_65,Negative 53 | Aceptable,Justified_no_work,Reliable,a11101_25900,s70001_more,Favorable,average,High,High_income_profession,Promissing,a16_21,Negative 54 | Excellent,Unjustified_no_work,Reliable,a0_11100,s0_30000,Unfavorable,wealthy,High,High_income_profession,Promissing,a22_65,Positive 55 | NoAceptable,Justified_no_work,Unreliable,a11101_25900,s70001_more,Unfavorable,average,High,Medium_income_profession,Promissing,a22_65,Positive 56 | Without_Reference,Unstable,Unreliable,a25901_more,s0_30000,Unfavorable,wealthy,High,Medium_income_profession,Promissing,a66_up,Positive 57 | Excellent,Unstable,Unreliable,a0_11100,s70001_more,Favorable,wealthy,High,Low_income_profession,Not_promissing,a66_up,Negative 58 | Excellent,Unjustified_no_work,Reliable,a25901_more,s0_30000,Unfavorable,poor,Low,High_income_profession,Promissing,a16_21,Positive 59 | NoAceptable,Stable,Reliable,a11101_25900,s30001_70000,Unfavorable,average,High,High_income_profession,Promissing,a22_65,Positive 60 | Excellent,Justified_no_work,Reliable,a25901_more,s30001_70000,Unfavorable,wealthy,High,Low_income_profession,Promissing,a66_up,Positive 61 | Excellent,Unstable,Reliable,a25901_more,s30001_70000,Unfavorable,poor,Medium,Low_income_profession,Not_promissing,a66_up,Negative 62 | Without_Reference,Unstable,Unreliable,a0_11100,s30001_70000,Favorable,average,Medium,Low_income_profession,Not_promissing,a22_65,Negative 63 | Without_Reference,Stable,Unreliable,a11101_25900,s70001_more,Favorable,wealthy,High,High_income_profession,Promissing,a22_65,Negative 64 | Without_Reference,Stable,Unreliable,a0_11100,s0_30000,Favorable,average,Low,Low_income_profession,Not_promissing,a66_up,Negative 65 | NoAceptable,Unstable,Unreliable,a11101_25900,s30001_70000,Favorable,average,High,Low_income_profession,Promissing,a22_65,Positive 66 | NoAceptable,Justified_no_work,Unreliable,a0_11100,s30001_70000,Favorable,wealthy,High,Medium_income_profession,Promissing,a66_up,Positive 67 | NoAceptable,Stable,Unreliable,a11101_25900,s30001_70000,Favorable,wealthy,High,High_income_profession,Promissing,a66_up,Positive 68 | Without_Reference,Unjustified_no_work,Reliable,a25901_more,s0_30000,Unfavorable,poor,Low,High_income_profession,Promissing,a22_65,Positive 69 | NoAceptable,Unstable,Unreliable,a0_11100,s30001_70000,Favorable,wealthy,High,Medium_income_profession,Promissing,a16_21,Positive 70 | Excellent,Unjustified_no_work,Unreliable,a11101_25900,s0_30000,Unfavorable,poor,Low,High_income_profession,Promissing,a16_21,Positive 71 | Excellent,Stable,Reliable,a25901_more,s70001_more,Unfavorable,poor,High,Medium_income_profession,Promissing,a22_65,Positive 72 | Excellent,Unjustified_no_work,Reliable,a11101_25900,s0_30000,Unfavorable,poor,Low,Low_income_profession,Not_promissing,a22_65,Negative 73 | NoAceptable,Stable,Unreliable,a25901_more,s30001_70000,Unfavorable,poor,Medium,Low_income_profession,Not_promissing,a66_up,Negative 74 | Without_Reference,Unstable,Unreliable,a11101_25900,s0_30000,Unfavorable,poor,Low,High_income_profession,Promissing,a66_up,Negative 75 | Excellent,Stable,Reliable,a25901_more,s70001_more,Unfavorable,average,High,High_income_profession,Promissing,a22_65,Negative 76 | NoAceptable,Justified_no_work,Unreliable,a11101_25900,s30001_70000,Favorable,wealthy,High,Low_income_profession,Promissing,a16_21,Positive 77 | Without_Reference,Unstable,Reliable,a25901_more,s70001_more,Favorable,average,High,Medium_income_profession,Not_promissing,a16_21,Positive 78 | Excellent,Justified_no_work,Reliable,a25901_more,s70001_more,Favorable,wealthy,High,Medium_income_profession,Promissing,a22_65,Positive 79 | Excellent,Justified_no_work,Unreliable,a25901_more,s30001_70000,Unfavorable,poor,Medium,Medium_income_profession,Promissing,a16_21,Negative 80 | Excellent,Stable,Reliable,a25901_more,s70001_more,Favorable,average,High,High_income_profession,Promissing,a66_up,Positive 81 | Excellent,Stable,Reliable,a25901_more,s30001_70000,Unfavorable,average,Medium,Medium_income_profession,Not_promissing,a16_21,Negative 82 | NoAceptable,Unjustified_no_work,Unreliable,a11101_25900,s70001_more,Favorable,poor,High,Low_income_profession,Not_promissing,a16_21,Negative 83 | NoAceptable,Unstable,Unreliable,a11101_25900,s70001_more,Favorable,poor,High,Low_income_profession,Not_promissing,a66_up,Negative 84 | NoAceptable,Unjustified_no_work,Unreliable,a25901_more,s0_30000,Unfavorable,wealthy,High,High_income_profession,Promissing,a22_65,Negative 85 | NoAceptable,Justified_no_work,Reliable,a0_11100,s70001_more,Favorable,poor,Medium,Low_income_profession,Not_promissing,a66_up,Positive 86 | NoAceptable,Unjustified_no_work,Unreliable,a0_11100,s30001_70000,Favorable,poor,Low,Medium_income_profession,Promissing,a16_21,Negative 87 | Without_Reference,Justified_no_work,Unreliable,a25901_more,s30001_70000,Unfavorable,poor,Medium,High_income_profession,Promissing,a22_65,Positive 88 | Excellent,Justified_no_work,Reliable,a11101_25900,s0_30000,Unfavorable,poor,Low,Low_income_profession,Not_promissing,a66_up,Negative 89 | Excellent,Unstable,Unreliable,a11101_25900,s0_30000,Unfavorable,average,Low,High_income_profession,Promissing,a22_65,Positive 90 | Aceptable,Unjustified_no_work,Unreliable,a0_11100,s0_30000,Unfavorable,average,Medium,Low_income_profession,Not_promissing,a16_21,Negative 91 | NoAceptable,Stable,Unreliable,a25901_more,s70001_more,Favorable,average,High,High_income_profession,Promissing,a66_up,Negative 92 | Aceptable,Unjustified_no_work,Unreliable,a11101_25900,s70001_more,Favorable,poor,High,Low_income_profession,Promissing,a16_21,Negative 93 | Without_Reference,Unjustified_no_work,Unreliable,a25901_more,s30001_70000,Unfavorable,poor,Medium,High_income_profession,Promissing,a66_up,Negative 94 | NoAceptable,Unjustified_no_work,Unreliable,a11101_25900,s70001_more,Favorable,poor,High,Medium_income_profession,Promissing,a16_21,Positive 95 | Aceptable,Unstable,Reliable,a0_11100,s0_30000,Unfavorable,average,Low,High_income_profession,Not_promissing,a16_21,Positive 96 | Aceptable,Justified_no_work,Reliable,a0_11100,s70001_more,Favorable,poor,High,Medium_income_profession,Not_promissing,a66_up,Positive 97 | Excellent,Stable,Reliable,a25901_more,s0_30000,Unfavorable,average,Low,Low_income_profession,Not_promissing,a66_up,Positive 98 | Excellent,Unstable,Reliable,a25901_more,s0_30000,Unfavorable,wealthy,High,Low_income_profession,Not_promissing,a22_65,Positive 99 | Excellent,Stable,Reliable,a25901_more,s70001_more,Unfavorable,wealthy,High,Medium_income_profession,Promissing,a16_21,Negative 100 | Without_Reference,Justified_no_work,Unreliable,a25901_more,s70001_more,Unfavorable,poor,Medium,Medium_income_profession,Not_promissing,a66_up,Negative 101 | Excellent,Unjustified_no_work,Unreliable,a11101_25900,s70001_more,Favorable,wealthy,High,Medium_income_profession,Promissing,a66_up,Positive 102 | -------------------------------------------------------------------------------- /DBCluster.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# DB Cluster" 8 | ] 9 | }, 10 | { 11 | "cell_type": "code", 12 | "execution_count": 31, 13 | "metadata": {}, 14 | "outputs": [], 15 | "source": [ 16 | "import numpy as np\n", 17 | "import math\n", 18 | "import itertools" 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 32, 24 | "metadata": {}, 25 | "outputs": [], 26 | "source": [ 27 | "D = np.array([\n", 28 | " [0., 1., 3., 4., 7.],\n", 29 | " [1., 0., 4., 4., 8.],\n", 30 | " [3., 4., 0., 2., 8.],\n", 31 | " [4., 4., 2., 0., 7.],\n", 32 | " [7., 8., 8., 7., 0.]\n", 33 | "])" 34 | ] 35 | }, 36 | { 37 | "cell_type": "code", 38 | "execution_count": 33, 39 | "metadata": {}, 40 | "outputs": [], 41 | "source": [ 42 | "def get_div(cluster):\n", 43 | " for i in range(1, math.ceil((len(cluster)+1)/2)):\n", 44 | " for cluster_1 in list(itertools.combinations(cluster, i)):\n", 45 | " cluster_2 = [item for item in cluster if item not in cluster_1]\n", 46 | " yield list(cluster_1), cluster_2" 47 | ] 48 | }, 49 | { 50 | "cell_type": "code", 51 | "execution_count": 34, 52 | "metadata": {}, 53 | "outputs": [], 54 | "source": [ 55 | "def variabilidad(cluster):\n", 56 | " s = 0\n", 57 | " for i in cluster:\n", 58 | " for j in cluster:\n", 59 | " if j > i:\n", 60 | " s += pow(D[i,j], 2)\n", 61 | " return s/(2*(len(cluster)**2))\n", 62 | " " 63 | ] 64 | }, 65 | { 66 | "cell_type": "code", 67 | "execution_count": 35, 68 | "metadata": {}, 69 | "outputs": [], 70 | "source": [ 71 | "cluster = range(D.shape[0])\n", 72 | "def dbcluster(cluster):\n", 73 | " if len(cluster) == 1:\n", 74 | " return cluster\n", 75 | " \n", 76 | " vmin = None\n", 77 | " prev = None\n", 78 | " c1min = None\n", 79 | " c2min = None\n", 80 | " for c1,c2 in get_div(cluster):\n", 81 | " v = variabilidad(c1)*len(c1)+variabilidad(c2)*len(c2)\n", 82 | " if vmin == None or vmin > v:\n", 83 | " vmin = v\n", 84 | " prev = variabilidad(cluster)*len(cluster)\n", 85 | " c1min = c1\n", 86 | " c2min = c2\n", 87 | " \n", 88 | " return [prev, dbcluster(c1min), dbcluster(c2min)] " 89 | ] 90 | }, 91 | { 92 | "cell_type": "code", 93 | "execution_count": 36, 94 | "metadata": {}, 95 | "outputs": [ 96 | { 97 | "data": { 98 | "text/plain": [ 99 | "[28.799999999999997, [4], [7.75, [0.25, [0], [1]], [1.0, [2], [3]]]]" 100 | ] 101 | }, 102 | "execution_count": 36, 103 | "metadata": {}, 104 | "output_type": "execute_result" 105 | } 106 | ], 107 | "source": [ 108 | "Z = dbcluster(cluster)\n", 109 | "Z" 110 | ] 111 | }, 112 | { 113 | "cell_type": "code", 114 | "execution_count": 37, 115 | "metadata": {}, 116 | "outputs": [ 117 | { 118 | "data": { 119 | "image/png": "iVBORw0KGgoAAAANSUhEUgAAAlMAAAJFCAYAAAD5znJuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFHdJREFUeJzt3X2sZAdZx/HfYxfFUIgQbl/Ci2tIVVDCRTaNCTGu4kslMcUYDa2SajBL1CaS8E9jNBI1kT9U9A/ErJa0URYlCkKQqE21ISSEuNUrLSmC0QqVbbu+0qJWKY9/3KnZ1K53ep97OzO7n08ymZkzZ/Y82dtNv/ecM2equwMAwP58yaoHAADYZGIKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANHnsqNPfe5z+2jR48+lZsEANiXO++88x+7e2uv9faMqap6epIPJfmyxfq/190/U1XPSfK7SY4muTfJ93f3v/x/f9bRo0dz+vTpvacHAFixqvr7ZdZb5jDfI0m+tbtflmQ7yTVV9Y1Jbkpye3dfleT2xXMAgIvKnjHVux5ePH3a4tZJrk1y62L5rUlecygTAgCssaVOQK+qS6pqJ8mDSW7r7o8muby7zyTJ4v6y87z3RFWdrqrTZ8+ePai5AQDWwlIx1d2Pdvd2kucnubqqvn7ZDXT3ye4+1t3Htrb2PIcLAGCjPKlLI3T3vya5I8k1SR6oqiuTZHH/4IFPBwCw5vaMqaraqqqvWDz+8iTfluQTSd6f5IbFajcked9hDQkAsK6Wuc7UlUlurapLshtf7+7uD1TVR5K8u6pen+TTSb7vEOcEAFhLe8ZUd38sycufYPk/JXnVYQwFALApfJ0MAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMHBk1QMAh+vkyeTUqVVPAVyIrr8+OXFi1VOsnj1TcIE7dSrZ2Vn1FMCFZmfHL2qPsWcKLgLb28kdd6x6CuBCcvz4qidYH/ZMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAAN7xlRVvaCq/qyq7qmqj1fVTyyWv7mq/qGqdha3Vx/+uAAA6+XIEut8IcmbuvsvquqZSe6sqtsWr721u3/x8MYDAFhve8ZUd59Jcmbx+KGquifJ8w57MACATfCkzpmqqqNJXp7ko4tFN1bVx6rqHVX17PO850RVna6q02fPnh0NCwCwbpaOqaq6NMnvJ3ljd38uyduTvCjJdnb3XP3SE72vu09297HuPra1tXUAIwMArI+lYqqqnpbdkHpnd78nSbr7ge5+tLu/mOQ3klx9eGMCAKynZT7NV0luTnJPd//yOcuvPGe170ly98GPBwCw3pb5NN8rk7wuyV1VtbNY9pNJrquq7SSd5N4kbziUCQEA1tgyn+b7cJJ6gpc+ePDjAABsFldABwAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGNgzpqrqBVX1Z1V1T1V9vKp+YrH8OVV1W1V9anH/7MMfFwBgvSyzZ+oLSd7U3S9O8o1JfryqXpLkpiS3d/dVSW5fPAcAuKjsGVPdfaa7/2Lx+KEk9yR5XpJrk9y6WO3WJK85rCEBANbVkzpnqqqOJnl5ko8muby7zyS7wZXksvO850RVna6q02fPnp1NCwCwZpaOqaq6NMnvJ3ljd39u2fd198nuPtbdx7a2tvYzIwDA2loqpqrqadkNqXd293sWix+oqisXr1+Z5MHDGREAYH0t82m+SnJzknu6+5fPeen9SW5YPL4hyfsOfjwAgPV2ZIl1XpnkdUnuqqqdxbKfTPKWJO+uqtcn+XSS7zucEQEA1teeMdXdH05S53n5VQc7DgDAZnEFdACAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgIE9Y6qq3lFVD1bV3ecse3NV/UNV7Sxurz7cMQEA1tMye6ZuSXLNEyx/a3dvL24fPNixAAA2w54x1d0fSvLPT8EsAAAbZ3LO1I1V9bHFYcBnn2+lqjpRVaer6vTZs2cHmwMAWD/7jam3J3lRku0kZ5L80vlW7O6T3X2su49tbW3tc3MAAOtpXzHV3Q9096Pd/cUkv5Hk6oMdCwBgM+wrpqrqynOefk+Su8+3LgDAhezIXitU1buSHE/y3Kq6L8nPJDleVdtJOsm9Sd5wiDMCAKytPWOqu697gsU3H8IsAAAbxxXQAQAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADCwZ0xV1Tuq6sGquvucZc+pqtuq6lOL+2cf7pgAAOtpmT1TtyS55nHLbkpye3dfleT2xXMAgIvOnjHV3R9K8s+PW3xtklsXj29N8poDngsAYCPs95ypy7v7TJIs7i87uJEAADbHoZ+AXlUnqup0VZ0+e/bsYW8OAOAptd+YeqCqrkySxf2D51uxu09297HuPra1tbXPzQEArKf9xtT7k9yweHxDkvcdzDgAAJtlmUsjvCvJR5J8TVXdV1WvT/KWJN9eVZ9K8u2L5wAAF50je63Q3ded56VXHfAsAAAbxxXQAQAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMDAkVUPwGY4eefJnLrr1KrHYB927v+VJMnxW9644knYr+tfen1OvOLEqscAzkNMsZRTd53Kzv072b5ie9Wj8CRt3ySiNtnO/TtJIqZgjYkplrZ9xXbu+KE7Vj0GXFSO33J81SMAe3DOFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYODI5M1VdW+Sh5I8muQL3X3sIIYCANgUo5ha+Jbu/scD+HMAADaOw3wAAAPTmOokf1JVd1bViYMYCABgk0wP872yuz9bVZclua2qPtHdHzp3hUVknUiSF77whcPNAQCsl9Geqe7+7OL+wSTvTXL1E6xzsruPdfexra2tyeYAANbOvmOqqp5RVc987HGS70hy90ENBgCwCSaH+S5P8t6qeuzPOdXdf3QgUwEAbIh9x1R3/22Slx3gLAAAG8elEQAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwICYAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA2IKAGBATAEADIgpAIABMQUAMCCmAAAGxBQAwMCRVQ9woTh558mcuuvUqsc4NDv37yRJjt9yfLWDHJLrX3p9TrzixKrHAGAD2TN1QE7ddep/g+NCtH3Fdrav2F71GIdi5/6dCzqEAThc9kwdoO0rtnPHD92x6jF4ki7UvW0APDXsmQIAGBBTAAADYgoAYEBMAQAMiCkAgAExBQAwIKYAAAbEFADAgJgCABgQUwAAA75OBthovmR88/micTadPVPARvMl45vNF41zIRjtmaqqa5L8apJLkvxmd7/lQKYCeBJ8yfjmupD3uHHx2Peeqaq6JMnbknxXkpckua6qXnJQgwEAbILJYb6rk/xNd/9td/9Xkt9Jcu3BjAUAsBkmMfW8JJ855/l9i2UAABeNyTlT9QTL+v+sVHUiyWMf03i4qv56sM21Vz/8RH8tbAI/u83m57fZ/Pw2V13YP7qvXGalSUzdl+QF5zx/fpLPPn6l7j6Z5ORgOwAAa2tymO/Pk1xVVV9VVV+a5LVJ3n8wYwEAbIZ975nq7i9U1Y1J/ji7l0Z4R3d//MAmAwDYANX9f05zAgBgSa6ADgAwIKYAAAbEFADAgJgaqqovq6qbq+rvq+qhqvrLqvquVc/Fcqrqt6vqTFV9rqo+WVU/suqZWF5VPaeq3ltVn1/8G7x+1TOxnKq6sapOV9UjVXXLqudhf6rqqqr6z6r67VXPskqjLzomye7f4WeSfHOSTyd5dZJ3V9VLu/veVQ7GUn4hyeu7+5Gq+tokd1TVX3b3nasejKW8Lcl/Jbk8yXaSP6yqv/LJ4o3w2SQ/n+Q7k3z5imdh/96W3UslXdTsmRrq7s9395u7+97u/mJ3fyDJ3yV5xapnY2/d/fHufuSxp4vbi1Y4Ekuqqmck+d4kP93dD3f3h7N7rbvXrXYyltHd7+nuP0jyT6uehf2pqtcm+dckt696llUTUwesqi5P8tVJ/Ga8Iarq16rq35N8IsmZJB9c8Ugs56uTPNrdnzxn2V8l+boVzQMXjap6VpKfTfKmVc+yDsTUAaqqpyV5Z5Jbu/sTq56H5XT3jyV5ZpJvSvKeJI/8/+9gTVya5N8et+zfsvuzBA7XzyW5ubs/s+pB1oGYOiBV9SVJfiu752/cuOJxeJK6+9HFYaLnJ/nRVc/DUh5O8qzHLXtWkodWMAtcNKpqO8m3JXnrqmdZF05APwBVVUluzu5JsK/u7v9e8Ujs35E4Z2pTfDLJkaq6qrs/tVj2sjjEDofteJKjST69+7+/XJrkkqp6SXd/wwrnWhl7pg7G25O8OMl3d/d/rHoYllNVl1XVa6vq0qq6pKq+M8l1Sf501bOxt+7+fHYPy/5sVT2jql6Z5Nrs7iFmzVXVkap6ena/2/WSqnp6VfkFfzOczO4vnduL268n+cPsfjLzoiSmhqrqK5O8Ibv/Qd1fVQ8vbj+w4tHYW2f3kN59Sf4lyS8meWN3v2+lU/Fk/Fh2P1b/YJJ3JflRl0XYGD+V5D+S3JTkBxePf2qlE7GU7v737r7/sVt2D7n/Z3efXfVsq+KLjgEABuyZAgAYEFMAAANiCgBgQEwBAAyIKQCAATEFADAgpgAABsQUAMCAmAIAGPgf6H0eqaGK0MoAAAAASUVORK5CYII=\n", 120 | "text/plain": [ 121 | "
" 122 | ] 123 | }, 124 | "metadata": { 125 | "needs_background": "light" 126 | }, 127 | "output_type": "display_data" 128 | } 129 | ], 130 | "source": [ 131 | "X = [\n", 132 | " [2., 3., 1., 2.],\n", 133 | " [0., 1., 0.25, 2.],\n", 134 | " [5., 6., 7.75, 4.],\n", 135 | " [7., 4., 28.79, 5.]\n", 136 | "]\n", 137 | "from scipy.cluster.hierarchy import dendrogram, linkage\n", 138 | "from matplotlib import pyplot as plt\n", 139 | "\n", 140 | "fig = plt.figure(figsize=(10, 10))\n", 141 | "dn = dendrogram(X)\n", 142 | "plt.show()" 143 | ] 144 | }, 145 | { 146 | "cell_type": "markdown", 147 | "metadata": {}, 148 | "source": [ 149 | "# KMeans" 150 | ] 151 | }, 152 | { 153 | "cell_type": "code", 154 | "execution_count": 39, 155 | "metadata": {}, 156 | "outputs": [], 157 | "source": [ 158 | "from sklearn.datasets import load_iris\n", 159 | "\n", 160 | "X, Y = load_iris(return_X_y=True)" 161 | ] 162 | }, 163 | { 164 | "cell_type": "code", 165 | "execution_count": 40, 166 | "metadata": {}, 167 | "outputs": [], 168 | "source": [ 169 | "from sklearn.preprocessing import MinMaxScaler\n", 170 | "\n", 171 | "X = MinMaxScaler().fit_transform(X)" 172 | ] 173 | }, 174 | { 175 | "cell_type": "code", 176 | "execution_count": 50, 177 | "metadata": {}, 178 | "outputs": [ 179 | { 180 | "name": "stdout", 181 | "output_type": "stream", 182 | "text": [ 183 | "Score: 0.9733333333333334\n" 184 | ] 185 | } 186 | ], 187 | "source": [ 188 | "from sklearn.cluster import KMeans\n", 189 | "from sklearn.pipeline import Pipeline\n", 190 | "from scipy import stats\n", 191 | "\n", 192 | "k = 6\n", 193 | "l = 9\n", 194 | "kmeans = KMeans(n_clusters=k+l, random_state=0)\n", 195 | "kmeans.fit(X)\n", 196 | "Y_labels = kmeans.predict(X)\n", 197 | "\n", 198 | "Y_predict = np.zeros(Y.shape)\n", 199 | "\n", 200 | "for cluster in range(k+l):\n", 201 | " cluster_index = np.argwhere(Y_labels==cluster)\n", 202 | " Y_predict_mode = stats.mode(Y[cluster_index])[0][0][0] # la clase que predice el cluster\n", 203 | " Y_predict[cluster_index] = Y_predict_mode\n", 204 | "\n", 205 | "from sklearn.cluster import AgglomerativeClustering\n", 206 | "ward = AgglomerativeClustering(linkage=\"ward\", n_clusters=k)\n", 207 | "Z_labels = ward.fit_predict(Y_predict.reshape(-1, 1))\n", 208 | "\n", 209 | "ok = 0\n", 210 | "total = 0\n", 211 | "for cluster in range(k):\n", 212 | " cluster_index = np.argwhere(Z_labels==cluster)\n", 213 | " Z_predict = stats.mode(Y_predict[cluster_index])[0][0][0]\n", 214 | " ok += np.sum(Y[cluster_index] == Z_predict) # los elementos cuya del cluster cuya clase coincide la predicha\n", 215 | " total += len(Y[cluster_index])\n", 216 | "print(\"Score: \", ok/total)" 217 | ] 218 | }, 219 | { 220 | "cell_type": "code", 221 | "execution_count": null, 222 | "metadata": {}, 223 | "outputs": [], 224 | "source": [] 225 | } 226 | ], 227 | "metadata": { 228 | "kernelspec": { 229 | "display_name": "Python 3", 230 | "language": "python", 231 | "name": "python3" 232 | }, 233 | "language_info": { 234 | "codemirror_mode": { 235 | "name": "ipython", 236 | "version": 3 237 | }, 238 | "file_extension": ".py", 239 | "mimetype": "text/x-python", 240 | "name": "python", 241 | "nbconvert_exporter": "python", 242 | "pygments_lexer": "ipython3", 243 | "version": "3.7.5" 244 | } 245 | }, 246 | "nbformat": 4, 247 | "nbformat_minor": 2 248 | } 249 | -------------------------------------------------------------------------------- /Perceptron simple y ADALINE.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Perceptrón simple\n", 8 | "\n", 9 | "Clase del perceptrón simple" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 1, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import numpy as np\n", 19 | "from sklearn.preprocessing import MinMaxScaler\n", 20 | "\n", 21 | "class PerceptronSimple(object):\n", 22 | " def __init__(self,n_inputs,pesos=[],bias=0):\n", 23 | " self.bias = bias\n", 24 | " if len(pesos) == 0:\n", 25 | " self.pesos = np.random.random(n_inputs)\n", 26 | " self.pesos -= 0.5\n", 27 | " elif len(pesos) == n_inputs:\n", 28 | " self.pesos = pesos\n", 29 | " else:\n", 30 | " raise Exception()\n", 31 | " \n", 32 | " def predict(self,data):\n", 33 | " output = np.zeros(data.shape[0])\n", 34 | " for i,sample in enumerate(data):\n", 35 | " # Sumatorio de productos\n", 36 | " out = 0\n", 37 | " for j,inp in enumerate(sample):\n", 38 | " out += inp*self.pesos[j]\n", 39 | " out += self.bias\n", 40 | " # Funcion de activacion\n", 41 | " output[i] = np.sign(out)\n", 42 | " return output\n", 43 | " \n", 44 | " def get_params(self):\n", 45 | " return (self.pesos,self.bias)\n", 46 | " \n", 47 | " def train(self,x,y):\n", 48 | " fail = True\n", 49 | " while fail:\n", 50 | " print(self.get_params())\n", 51 | " fail = False\n", 52 | " # EPOCA\n", 53 | " output = self.predict(x)\n", 54 | " for i in range(x.shape[0]):\n", 55 | " if abs(output[i] - y[i,0]) > 0.1:\n", 56 | " for j in range(len(self.pesos)):\n", 57 | " w = y[i,0]*x[i,j]\n", 58 | " self.pesos[j] += w\n", 59 | " self.bias += y[i,0]\n", 60 | " fail = True\n", 61 | " \n", 62 | " \n", 63 | " \n", 64 | " \n", 65 | " \n", 66 | " " 67 | ] 68 | }, 69 | { 70 | "cell_type": "code", 71 | "execution_count": 2, 72 | "metadata": {}, 73 | "outputs": [ 74 | { 75 | "name": "stderr", 76 | "output_type": "stream", 77 | "text": [ 78 | "/opt/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by MinMaxScaler.\n", 79 | " warnings.warn(msg, DataConversionWarning)\n" 80 | ] 81 | } 82 | ], 83 | "source": [ 84 | "original = np.array([\n", 85 | " [1,1,1],\n", 86 | " [2,1,1],\n", 87 | " [2,2,1],\n", 88 | " [1,3,1],\n", 89 | " [-1,1,-1],\n", 90 | " [0,2,-1],\n", 91 | " [-1,3,-1]\n", 92 | "])\n", 93 | "data = np.zeros(original.shape)\n", 94 | "data[:,[0,1]] = MinMaxScaler().fit(original[:,[0,1]]).transform(original[:,[0,1]])\n", 95 | "data[:,[2]] = original[:,[2]]" 96 | ] 97 | }, 98 | { 99 | "cell_type": "code", 100 | "execution_count": 3, 101 | "metadata": {}, 102 | "outputs": [], 103 | "source": [ 104 | "p = PerceptronSimple(2,[0.75,1],-3)" 105 | ] 106 | }, 107 | { 108 | "cell_type": "code", 109 | "execution_count": 4, 110 | "metadata": {}, 111 | "outputs": [ 112 | { 113 | "name": "stdout", 114 | "output_type": "stream", 115 | "text": [ 116 | "([0.75, 1], -3)\n", 117 | "([4.083333333333333, 2.5], 5.0)\n", 118 | "([3.7499999999999996, 1.0], -1.0)\n", 119 | "([3.416666666666666, -0.5], -5.0)\n", 120 | "([6.75, 1.0], 3.0)\n", 121 | "([6.416666666666667, -0.5], -3.0)\n" 122 | ] 123 | } 124 | ], 125 | "source": [ 126 | "p.train(data[:,[0,1]],data[:,[2]])" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": 5, 132 | "metadata": {}, 133 | "outputs": [ 134 | { 135 | "data": { 136 | "text/plain": [ 137 | "array([ 1., 1., 1., 1., -1., -1., -1.])" 138 | ] 139 | }, 140 | "execution_count": 5, 141 | "metadata": {}, 142 | "output_type": "execute_result" 143 | } 144 | ], 145 | "source": [ 146 | "p.predict(data[:,[0,1]])" 147 | ] 148 | }, 149 | { 150 | "cell_type": "code", 151 | "execution_count": 6, 152 | "metadata": {}, 153 | "outputs": [ 154 | { 155 | "data": { 156 | "text/plain": [ 157 | "([6.416666666666667, -0.5], -3.0)" 158 | ] 159 | }, 160 | "execution_count": 6, 161 | "metadata": {}, 162 | "output_type": "execute_result" 163 | } 164 | ], 165 | "source": [ 166 | "p.get_params()" 167 | ] 168 | }, 169 | { 170 | "cell_type": "markdown", 171 | "metadata": {}, 172 | "source": [ 173 | "# Adaline\n", 174 | "[Dataset computer hardware](http://archive.ics.uci.edu/ml/datasets/Computer+Hardware)\n" 175 | ] 176 | }, 177 | { 178 | "cell_type": "code", 179 | "execution_count": 3, 180 | "metadata": {}, 181 | "outputs": [], 182 | "source": [ 183 | "import numpy as np\n", 184 | "import pandas as pd\n", 185 | "\n", 186 | "df = pd.read_csv(\"machine.data\",header=None)" 187 | ] 188 | }, 189 | { 190 | "cell_type": "code", 191 | "execution_count": 17, 192 | "metadata": {}, 193 | "outputs": [ 194 | { 195 | "name": "stderr", 196 | "output_type": "stream", 197 | "text": [ 198 | "/opt/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py:7: FutureWarning: reshape is deprecated and will raise in a subsequent release. Please use .values.reshape(...) instead\n", 199 | " import sys\n", 200 | "/opt/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py:475: DataConversionWarning: Data with input dtype int64 was converted to float64 by MinMaxScaler.\n", 201 | " warnings.warn(msg, DataConversionWarning)\n" 202 | ] 203 | } 204 | ], 205 | "source": [ 206 | "from sklearn.model_selection import train_test_split\n", 207 | "from sklearn.neural_network import MLPRegressor\n", 208 | "from sklearn.preprocessing import MinMaxScaler\n", 209 | "\n", 210 | "X = MinMaxScaler().fit(df[[2,3,4,5,6,7,8]]).transform(df[[2,3,4,5,6,7,8]])\n", 211 | "\n", 212 | "Y = MinMaxScaler().fit(df[9].reshape(-1,1)).transform(df[9].reshape(-1,1))\n", 213 | "\n", 214 | "x_train,x_test,y_train,y_test = train_test_split(X,Y,test_size=0.33)" 215 | ] 216 | }, 217 | { 218 | "cell_type": "code", 219 | "execution_count": 39, 220 | "metadata": {}, 221 | "outputs": [], 222 | "source": [ 223 | "adaline = MLPRegressor(hidden_layer_sizes=[],solver=\"sgd\",alpha=0.1,batch_size=1,max_iter=5000,momentum=0,verbose=True)" 224 | ] 225 | }, 226 | { 227 | "cell_type": "code", 228 | "execution_count": 44, 229 | "metadata": {}, 230 | "outputs": [ 231 | { 232 | "name": "stderr", 233 | "output_type": "stream", 234 | "text": [ 235 | "/opt/anaconda3/lib/python3.6/site-packages/sklearn/neural_network/multilayer_perceptron.py:1306: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n", 236 | " y = column_or_1d(y, warn=True)\n" 237 | ] 238 | }, 239 | { 240 | "name": "stdout", 241 | "output_type": "stream", 242 | "text": [ 243 | "Iteration 1, loss = 0.40959164\n", 244 | "Iteration 2, loss = 0.32092856\n", 245 | "Iteration 3, loss = 0.25509900\n", 246 | "Iteration 4, loss = 0.20605179\n", 247 | "Iteration 5, loss = 0.16934551\n", 248 | "Iteration 6, loss = 0.14173643\n", 249 | "Iteration 7, loss = 0.12081504\n", 250 | "Iteration 8, loss = 0.10484547\n", 251 | "Iteration 9, loss = 0.09261041\n", 252 | "Iteration 10, loss = 0.08309452\n", 253 | "Iteration 11, loss = 0.07560897\n", 254 | "Iteration 12, loss = 0.06963486\n", 255 | "Iteration 13, loss = 0.06479030\n", 256 | "Iteration 14, loss = 0.06077104\n", 257 | "Iteration 15, loss = 0.05739725\n", 258 | "Iteration 16, loss = 0.05450392\n", 259 | "Iteration 17, loss = 0.05197769\n", 260 | "Iteration 18, loss = 0.04974558\n", 261 | "Iteration 19, loss = 0.04773721\n", 262 | "Iteration 20, loss = 0.04589844\n", 263 | "Iteration 21, loss = 0.04420677\n", 264 | "Iteration 22, loss = 0.04263544\n", 265 | "Iteration 23, loss = 0.04115828\n", 266 | "Iteration 24, loss = 0.03976351\n", 267 | "Iteration 25, loss = 0.03844218\n", 268 | "Iteration 26, loss = 0.03718480\n", 269 | "Iteration 27, loss = 0.03598284\n", 270 | "Iteration 28, loss = 0.03483182\n", 271 | "Iteration 29, loss = 0.03372897\n", 272 | "Iteration 30, loss = 0.03266875\n", 273 | "Iteration 31, loss = 0.03164815\n", 274 | "Iteration 32, loss = 0.03066509\n", 275 | "Iteration 33, loss = 0.02971802\n", 276 | "Iteration 34, loss = 0.02880534\n", 277 | "Iteration 35, loss = 0.02792506\n", 278 | "Iteration 36, loss = 0.02707711\n", 279 | "Iteration 37, loss = 0.02625805\n", 280 | "Iteration 38, loss = 0.02546746\n", 281 | "Iteration 39, loss = 0.02470394\n", 282 | "Iteration 40, loss = 0.02396623\n", 283 | "Iteration 41, loss = 0.02325579\n", 284 | "Iteration 42, loss = 0.02256849\n", 285 | "Iteration 43, loss = 0.02190529\n", 286 | "Iteration 44, loss = 0.02126368\n", 287 | "Iteration 45, loss = 0.02064445\n", 288 | "Iteration 46, loss = 0.02004615\n", 289 | "Iteration 47, loss = 0.01946827\n", 290 | "Iteration 48, loss = 0.01890948\n", 291 | "Iteration 49, loss = 0.01836972\n", 292 | "Iteration 50, loss = 0.01784887\n", 293 | "Iteration 51, loss = 0.01734506\n", 294 | "Iteration 52, loss = 0.01685809\n", 295 | "Iteration 53, loss = 0.01638767\n", 296 | "Iteration 54, loss = 0.01593287\n", 297 | "Iteration 55, loss = 0.01549297\n", 298 | "Iteration 56, loss = 0.01506825\n", 299 | "Iteration 57, loss = 0.01465755\n", 300 | "Iteration 58, loss = 0.01426038\n", 301 | "Iteration 59, loss = 0.01387673\n", 302 | "Iteration 60, loss = 0.01350576\n", 303 | "Iteration 61, loss = 0.01314697\n", 304 | "Iteration 62, loss = 0.01280025\n", 305 | "Iteration 63, loss = 0.01246513\n", 306 | "Iteration 64, loss = 0.01214091\n", 307 | "Iteration 65, loss = 0.01182747\n", 308 | "Iteration 66, loss = 0.01152435\n", 309 | "Iteration 67, loss = 0.01123118\n", 310 | "Iteration 68, loss = 0.01094748\n", 311 | "Iteration 69, loss = 0.01067363\n", 312 | "Iteration 70, loss = 0.01040817\n", 313 | "Iteration 71, loss = 0.01015205\n", 314 | "Iteration 72, loss = 0.00990410\n", 315 | "Iteration 73, loss = 0.00966419\n", 316 | "Iteration 74, loss = 0.00943178\n", 317 | "Iteration 75, loss = 0.00920728\n", 318 | "Iteration 76, loss = 0.00898999\n", 319 | "Iteration 77, loss = 0.00878010\n", 320 | "Iteration 78, loss = 0.00857677\n", 321 | "Iteration 79, loss = 0.00838005\n", 322 | "Iteration 80, loss = 0.00818974\n", 323 | "Iteration 81, loss = 0.00800555\n", 324 | "Iteration 82, loss = 0.00782730\n", 325 | "Iteration 83, loss = 0.00765479\n", 326 | "Iteration 84, loss = 0.00748788\n", 327 | "Iteration 85, loss = 0.00732643\n", 328 | "Iteration 86, loss = 0.00717026\n", 329 | "Iteration 87, loss = 0.00701903\n", 330 | "Iteration 88, loss = 0.00687252\n", 331 | "Iteration 89, loss = 0.00673087\n", 332 | "Iteration 90, loss = 0.00659384\n", 333 | "Iteration 91, loss = 0.00646103\n", 334 | "Iteration 92, loss = 0.00633269\n", 335 | "Iteration 93, loss = 0.00620830\n", 336 | "Iteration 94, loss = 0.00608788\n", 337 | "Iteration 95, loss = 0.00597136\n", 338 | "Iteration 96, loss = 0.00585837\n", 339 | "Iteration 97, loss = 0.00574928\n", 340 | "Iteration 98, loss = 0.00564351\n", 341 | "Iteration 99, loss = 0.00554123\n", 342 | "Iteration 100, loss = 0.00544210\n", 343 | "Iteration 101, loss = 0.00534615\n", 344 | "Iteration 102, loss = 0.00525309\n", 345 | "Training loss did not improve more than tol=0.000100 for two consecutive epochs. Stopping.\n" 346 | ] 347 | }, 348 | { 349 | "data": { 350 | "text/plain": [ 351 | "MLPRegressor(activation='relu', alpha=0.1, batch_size=1, beta_1=0.9,\n", 352 | " beta_2=0.999, early_stopping=False, epsilon=1e-08,\n", 353 | " hidden_layer_sizes=[], learning_rate='constant',\n", 354 | " learning_rate_init=0.001, max_iter=5000, momentum=0,\n", 355 | " nesterovs_momentum=True, power_t=0.5, random_state=None,\n", 356 | " shuffle=True, solver='sgd', tol=0.0001, validation_fraction=0.1,\n", 357 | " verbose=True, warm_start=False)" 358 | ] 359 | }, 360 | "execution_count": 44, 361 | "metadata": {}, 362 | "output_type": "execute_result" 363 | } 364 | ], 365 | "source": [ 366 | "adaline.fit(x_train,y_train)" 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "execution_count": 45, 372 | "metadata": {}, 373 | "outputs": [], 374 | "source": [ 375 | "y_predict = adaline.predict(x_test)" 376 | ] 377 | }, 378 | { 379 | "cell_type": "code", 380 | "execution_count": 61, 381 | "metadata": {}, 382 | "outputs": [], 383 | "source": [ 384 | "ok_matrix = np.abs(y_predict - y_test[:,0]) < 0.1\n", 385 | "success = np.sum(ok_matrix)/ok_matrix.shape[0]" 386 | ] 387 | }, 388 | { 389 | "cell_type": "code", 390 | "execution_count": 63, 391 | "metadata": {}, 392 | "outputs": [ 393 | { 394 | "name": "stdout", 395 | "output_type": "stream", 396 | "text": [ 397 | "Tasa de acierto: 0.855072\n", 398 | "Tasa de error: 0.144928\n" 399 | ] 400 | } 401 | ], 402 | "source": [ 403 | "print(\"Tasa de acierto: %f\" % success)\n", 404 | "print(\"Tasa de error: %f\" % (1-success))" 405 | ] 406 | }, 407 | { 408 | "cell_type": "code", 409 | "execution_count": null, 410 | "metadata": {}, 411 | "outputs": [], 412 | "source": [] 413 | } 414 | ], 415 | "metadata": { 416 | "kernelspec": { 417 | "display_name": "Python 3", 418 | "language": "python", 419 | "name": "python3" 420 | }, 421 | "language_info": { 422 | "codemirror_mode": { 423 | "name": "ipython", 424 | "version": 3 425 | }, 426 | "file_extension": ".py", 427 | "mimetype": "text/x-python", 428 | "name": "python", 429 | "nbconvert_exporter": "python", 430 | "pygments_lexer": "ipython3", 431 | "version": "3.7.3" 432 | } 433 | }, 434 | "nbformat": 4, 435 | "nbformat_minor": 2 436 | } 437 | -------------------------------------------------------------------------------- /Perceptron Multicapa.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Perceptrón Multicapa\n", 8 | "\n", 9 | "## Computer Hardware" 10 | ] 11 | }, 12 | { 13 | "cell_type": "code", 14 | "execution_count": 1, 15 | "metadata": {}, 16 | "outputs": [], 17 | "source": [ 18 | "import numpy as np\n", 19 | "import pandas as pd\n", 20 | "from sklearn.preprocessing import MinMaxScaler\n", 21 | "from sklearn.model_selection import train_test_split" 22 | ] 23 | }, 24 | { 25 | "cell_type": "code", 26 | "execution_count": 2, 27 | "metadata": {}, 28 | "outputs": [], 29 | "source": [ 30 | "df = pd.read_csv(\"machine.data\",header=None)" 31 | ] 32 | }, 33 | { 34 | "cell_type": "code", 35 | "execution_count": 3, 36 | "metadata": {}, 37 | "outputs": [ 38 | { 39 | "name": "stderr", 40 | "output_type": "stream", 41 | "text": [ 42 | "/usr/lib/python3/dist-packages/sklearn/preprocessing/data.py:323: DataConversionWarning: Data with input dtype int64 were all converted to float64 by MinMaxScaler.\n", 43 | " return self.partial_fit(X, y)\n" 44 | ] 45 | } 46 | ], 47 | "source": [ 48 | "X = MinMaxScaler().fit(df[[2,3,4,5,6,7,8]]).transform(df[[2,3,4,5,6,7,8]])\n", 49 | "#Y = MinMaxScaler().fit_transform(df[[9]])\n", 50 | "Y = df[[9]].values" 51 | ] 52 | }, 53 | { 54 | "cell_type": "code", 55 | "execution_count": 4, 56 | "metadata": {}, 57 | "outputs": [], 58 | "source": [ 59 | "x_train, x_test, y_train, y_test = train_test_split(X,Y,test_size=0.33,random_state=42)\n", 60 | "y_train = y_train.ravel()\n", 61 | "y_test = y_test.ravel()" 62 | ] 63 | }, 64 | { 65 | "cell_type": "markdown", 66 | "metadata": {}, 67 | "source": [ 68 | "## Regresion Lineal" 69 | ] 70 | }, 71 | { 72 | "cell_type": "code", 73 | "execution_count": 5, 74 | "metadata": {}, 75 | "outputs": [ 76 | { 77 | "name": "stdout", 78 | "output_type": "stream", 79 | "text": [ 80 | "Aciertos 29\n", 81 | "Tasa acierto 0.420290\n" 82 | ] 83 | } 84 | ], 85 | "source": [ 86 | "from sklearn.linear_model import LinearRegression\n", 87 | "\n", 88 | "reg = LinearRegression()\n", 89 | "reg.fit(x_train,y_train)\n", 90 | "y_predict = reg.predict(x_test)\n", 91 | "\n", 92 | "\n", 93 | "aciertos = np.sum(np.abs(y_predict - y_test) < 0.15*y_test)\n", 94 | "print(\"Aciertos %d\" % aciertos)\n", 95 | "print(\"Tasa acierto %f\" % (aciertos/y_test.shape[0]))" 96 | ] 97 | }, 98 | { 99 | "cell_type": "markdown", 100 | "metadata": {}, 101 | "source": [ 102 | "## ADALINE\n" 103 | ] 104 | }, 105 | { 106 | "cell_type": "code", 107 | "execution_count": 6, 108 | "metadata": {}, 109 | "outputs": [ 110 | { 111 | "name": "stdout", 112 | "output_type": "stream", 113 | "text": [ 114 | "Aciertos 9\n", 115 | "Tasa acierto 0.130435\n" 116 | ] 117 | } 118 | ], 119 | "source": [ 120 | "from sklearn.neural_network import MLPRegressor\n", 121 | "\n", 122 | "reg = MLPRegressor(hidden_layer_sizes=[],solver=\"sgd\",alpha=0.1,batch_size=1,max_iter=5000,momentum=0,activation=\"identity\")\n", 123 | "reg.fit(x_train,y_train)\n", 124 | "y_predict = reg.predict(x_test)\n", 125 | "table = np.abs(y_predict - y_test) < 0.15*y_test\n", 126 | "aciertos = np.sum(table)\n", 127 | "print(\"Aciertos %d\" % aciertos)\n", 128 | "tasa = aciertos / y_test.shape[0]\n", 129 | "print(\"Tasa acierto %f\" % tasa)\n", 130 | "\n" 131 | ] 132 | }, 133 | { 134 | "cell_type": "markdown", 135 | "metadata": {}, 136 | "source": [ 137 | "## Perceptrón Multicapa" 138 | ] 139 | }, 140 | { 141 | "cell_type": "code", 142 | "execution_count": 7, 143 | "metadata": {}, 144 | "outputs": [ 145 | { 146 | "name": "stdout", 147 | "output_type": "stream", 148 | "text": [ 149 | "Iteration 1, loss = 4181.35068883\n", 150 | "Iteration 2, loss = 804.57036059\n", 151 | "Iteration 3, loss = 533.57169044\n", 152 | "Iteration 4, loss = 600.44910794\n", 153 | "Iteration 5, loss = 525.26333190\n", 154 | "Iteration 6, loss = 627.23297135\n", 155 | "Iteration 7, loss = 580.33225846\n", 156 | "Iteration 8, loss = 504.64431334\n", 157 | "Iteration 9, loss = 520.31682696\n", 158 | "Iteration 10, loss = 483.13485814\n", 159 | "Iteration 11, loss = 564.47808706\n", 160 | "Iteration 12, loss = 456.75146237\n", 161 | "Iteration 13, loss = 506.98598905\n", 162 | "Iteration 14, loss = 470.22960497\n", 163 | "Iteration 15, loss = 609.31741247\n", 164 | "Iteration 16, loss = 476.65775864\n", 165 | "Iteration 17, loss = 508.51183801\n", 166 | "Iteration 18, loss = 510.71285060\n", 167 | "Iteration 19, loss = 479.11361510\n", 168 | "Iteration 20, loss = 575.36517460\n", 169 | "Iteration 21, loss = 554.32712928\n", 170 | "Iteration 22, loss = 456.11765346\n", 171 | "Iteration 23, loss = 494.07399593\n", 172 | "Iteration 24, loss = 579.50401898\n", 173 | "Iteration 25, loss = 485.93976066\n", 174 | "Iteration 26, loss = 573.59072115\n", 175 | "Iteration 27, loss = 561.84243348\n", 176 | "Iteration 28, loss = 666.79635090\n", 177 | "Iteration 29, loss = 455.31575492\n", 178 | "Iteration 30, loss = 642.99984788\n", 179 | "Iteration 31, loss = 592.96677833\n", 180 | "Iteration 32, loss = 544.62864296\n", 181 | "Iteration 33, loss = 499.34106807\n", 182 | "Iteration 34, loss = 518.02726806\n", 183 | "Iteration 35, loss = 424.63356713\n", 184 | "Iteration 36, loss = 572.87819316\n", 185 | "Iteration 37, loss = 434.17923142\n", 186 | "Iteration 38, loss = 614.74181673\n", 187 | "Iteration 39, loss = 717.67647027\n", 188 | "Iteration 40, loss = 595.02568137\n", 189 | "Iteration 41, loss = 585.23234900\n", 190 | "Iteration 42, loss = 523.58550889\n", 191 | "Iteration 43, loss = 387.26992478\n", 192 | "Iteration 44, loss = 452.21252345\n", 193 | "Iteration 45, loss = 555.77515128\n", 194 | "Iteration 46, loss = 497.15288071\n", 195 | "Iteration 47, loss = 541.70337487\n", 196 | "Iteration 48, loss = 386.05107217\n", 197 | "Iteration 49, loss = 475.72270874\n", 198 | "Iteration 50, loss = 581.67659225\n", 199 | "Iteration 51, loss = 459.74911639\n", 200 | "Iteration 52, loss = 391.07565790\n", 201 | "Iteration 53, loss = 638.50153230\n", 202 | "Iteration 54, loss = 520.76204511\n", 203 | "Iteration 55, loss = 546.41525168\n", 204 | "Iteration 56, loss = 556.08582667\n", 205 | "Iteration 57, loss = 445.77280090\n", 206 | "Iteration 58, loss = 452.63154134\n", 207 | "Iteration 59, loss = 524.31418667\n", 208 | "Training loss did not improve more than tol=0.000100 for 10 consecutive epochs. Stopping.\n", 209 | "Aciertos 21\n", 210 | "Tasa acierto 0.304348\n" 211 | ] 212 | } 213 | ], 214 | "source": [ 215 | "reg = MLPRegressor(hidden_layer_sizes=(10),solver=\"sgd\",alpha=0.1,batch_size=1,max_iter=5000,verbose=True,activation=\"identity\",momentum=0)\n", 216 | "reg.fit(x_train,y_train)\n", 217 | "y_predict = reg.predict(x_test)\n", 218 | "table = np.abs(y_predict - y_test) < 0.15*y_test\n", 219 | "aciertos = np.sum(table)\n", 220 | "print(\"Aciertos %d\" % aciertos)\n", 221 | "tasa = aciertos / y_test.shape[0]\n", 222 | "print(\"Tasa acierto %f\" % tasa)" 223 | ] 224 | }, 225 | { 226 | "cell_type": "code", 227 | "execution_count": 8, 228 | "metadata": {}, 229 | "outputs": [ 230 | { 231 | "name": "stdout", 232 | "output_type": "stream", 233 | "text": [ 234 | "Iteration 1, loss = 3878.58545303\n", 235 | "Iteration 2, loss = 747.79859266\n", 236 | "Iteration 3, loss = 554.61219412\n", 237 | "Iteration 4, loss = 553.41008396\n", 238 | "Iteration 5, loss = 441.48072549\n", 239 | "Iteration 6, loss = 659.49635317\n", 240 | "Iteration 7, loss = 544.51704098\n", 241 | "Iteration 8, loss = 607.89957127\n", 242 | "Iteration 9, loss = 1046.64887193\n", 243 | "Iteration 10, loss = 554.47994192\n", 244 | "Iteration 11, loss = 509.58860341\n", 245 | "Iteration 12, loss = 534.14596795\n", 246 | "Iteration 13, loss = 568.37691963\n", 247 | "Iteration 14, loss = 561.66336095\n", 248 | "Iteration 15, loss = 480.28283503\n", 249 | "Iteration 16, loss = 461.10581719\n", 250 | "Training loss did not improve more than tol=0.000100 for 10 consecutive epochs. Stopping.\n", 251 | "Aciertos 28\n", 252 | "Tasa acierto 0.405797\n" 253 | ] 254 | } 255 | ], 256 | "source": [ 257 | "reg = MLPRegressor(hidden_layer_sizes=(15),solver=\"sgd\",alpha=0.1,batch_size=1,max_iter=5000,verbose=True,activation=\"identity\",momentum=0)\n", 258 | "reg.fit(x_train,y_train)\n", 259 | "y_predict = reg.predict(x_test)\n", 260 | "table = np.abs(y_predict - y_test) < 0.15*y_test\n", 261 | "aciertos = np.sum(table)\n", 262 | "print(\"Aciertos %d\" % aciertos)\n", 263 | "tasa = aciertos / y_test.shape[0]\n", 264 | "print(\"Tasa acierto %f\" % tasa)" 265 | ] 266 | }, 267 | { 268 | "cell_type": "code", 269 | "execution_count": 9, 270 | "metadata": {}, 271 | "outputs": [ 272 | { 273 | "name": "stdout", 274 | "output_type": "stream", 275 | "text": [ 276 | "Iteration 1, loss = 4153.27621840\n", 277 | "Iteration 2, loss = 1235.71074734\n", 278 | "Iteration 3, loss = 732.05244152\n", 279 | "Iteration 4, loss = 685.11288733\n", 280 | "Iteration 5, loss = 601.45178412\n", 281 | "Iteration 6, loss = 458.87432799\n", 282 | "Iteration 7, loss = 591.37699431\n", 283 | "Iteration 8, loss = 553.47942674\n", 284 | "Iteration 9, loss = 542.65490134\n", 285 | "Iteration 10, loss = 528.84933774\n", 286 | "Iteration 11, loss = 553.08615258\n", 287 | "Iteration 12, loss = 390.81543706\n", 288 | "Iteration 13, loss = 519.39453655\n", 289 | "Iteration 14, loss = 536.73142435\n", 290 | "Iteration 15, loss = 363.56424151\n", 291 | "Iteration 16, loss = 570.34667441\n", 292 | "Iteration 17, loss = 506.70555214\n", 293 | "Iteration 18, loss = 512.60412260\n", 294 | "Iteration 19, loss = 446.78768912\n", 295 | "Iteration 20, loss = 543.43532538\n", 296 | "Iteration 21, loss = 543.21304462\n", 297 | "Iteration 22, loss = 465.33570272\n", 298 | "Iteration 23, loss = 535.03596014\n", 299 | "Iteration 24, loss = 493.40537087\n", 300 | "Iteration 25, loss = 574.71933675\n", 301 | "Iteration 26, loss = 487.43111770\n", 302 | "Training loss did not improve more than tol=0.000100 for 10 consecutive epochs. Stopping.\n", 303 | "Aciertos 18\n", 304 | "Tasa acierto 0.260870\n" 305 | ] 306 | } 307 | ], 308 | "source": [ 309 | "reg = MLPRegressor(hidden_layer_sizes=(20),solver=\"sgd\",batch_size=1,alpha=0.1,max_iter=5000,verbose=True,activation=\"identity\",momentum=0)\n", 310 | "reg.fit(x_train,y_train)\n", 311 | "y_predict = reg.predict(x_test)\n", 312 | "table = np.abs(y_predict - y_test) < 0.15*y_test\n", 313 | "aciertos = np.sum(table)\n", 314 | "print(\"Aciertos %d\" % aciertos)\n", 315 | "tasa = aciertos / y_test.shape[0]\n", 316 | "print(\"Tasa acierto %f\" % tasa)" 317 | ] 318 | }, 319 | { 320 | "cell_type": "code", 321 | "execution_count": 10, 322 | "metadata": {}, 323 | "outputs": [ 324 | { 325 | "name": "stdout", 326 | "output_type": "stream", 327 | "text": [ 328 | "Iteration 1, loss = 3541.87021600\n", 329 | "Iteration 2, loss = 901.36435854\n", 330 | "Iteration 3, loss = 677.38131365\n", 331 | "Iteration 4, loss = 570.81888791\n", 332 | "Iteration 5, loss = 623.97259709\n", 333 | "Iteration 6, loss = 552.13463194\n", 334 | "Iteration 7, loss = 635.72257273\n", 335 | "Iteration 8, loss = 592.30997469\n", 336 | "Iteration 9, loss = 582.74307878\n", 337 | "Iteration 10, loss = 540.14807179\n", 338 | "Iteration 11, loss = 508.90926717\n", 339 | "Iteration 12, loss = 481.21165939\n", 340 | "Iteration 13, loss = 532.73419313\n", 341 | "Iteration 14, loss = 527.05719199\n", 342 | "Iteration 15, loss = 546.67066553\n", 343 | "Iteration 16, loss = 525.40831423\n", 344 | "Iteration 17, loss = 537.95840729\n", 345 | "Iteration 18, loss = 499.09678264\n", 346 | "Iteration 19, loss = 539.00547885\n", 347 | "Iteration 20, loss = 602.47236542\n", 348 | "Iteration 21, loss = 557.62597060\n", 349 | "Iteration 22, loss = 596.59392383\n", 350 | "Iteration 23, loss = 420.37369227\n", 351 | "Iteration 24, loss = 503.56712800\n", 352 | "Iteration 25, loss = 519.45988284\n", 353 | "Iteration 26, loss = 435.62288528\n", 354 | "Iteration 27, loss = 623.76349770\n", 355 | "Iteration 28, loss = 596.83937791\n", 356 | "Iteration 29, loss = 498.90921842\n", 357 | "Iteration 30, loss = 568.10772361\n", 358 | "Iteration 31, loss = 545.81675391\n", 359 | "Iteration 32, loss = 490.37917096\n", 360 | "Iteration 33, loss = 577.65590526\n", 361 | "Iteration 34, loss = 422.80710803\n", 362 | "Training loss did not improve more than tol=0.000100 for 10 consecutive epochs. Stopping.\n", 363 | "Aciertos 8\n", 364 | "Tasa acierto 0.115942\n" 365 | ] 366 | } 367 | ], 368 | "source": [ 369 | "reg = MLPRegressor(hidden_layer_sizes=(25),solver=\"sgd\",batch_size=1,alpha=0.1,max_iter=5000,verbose=True,activation=\"identity\",momentum=0)\n", 370 | "reg.fit(x_train,y_train)\n", 371 | "y_predict = reg.predict(x_test)\n", 372 | "table = np.abs(y_predict - y_test) < 0.15*y_test\n", 373 | "aciertos = np.sum(table)\n", 374 | "print(\"Aciertos %d\" % aciertos)\n", 375 | "tasa = aciertos / y_test.shape[0]\n", 376 | "print(\"Tasa acierto %f\" % tasa)" 377 | ] 378 | }, 379 | { 380 | "cell_type": "markdown", 381 | "metadata": {}, 382 | "source": [ 383 | "|Regresión lineal|ADALINE|MLP(10)|MLP(15)|MLP(20)|MLP(25)|\n", 384 | "|----------------|-------|-------|-------|-------|-------|\n", 385 | "|0.4202|0.1449|0.5072|0.4927|0.2898|0.3333|" 386 | ] 387 | }, 388 | { 389 | "cell_type": "markdown", 390 | "metadata": {}, 391 | "source": [ 392 | "# Wine" 393 | ] 394 | }, 395 | { 396 | "cell_type": "code", 397 | "execution_count": 15, 398 | "metadata": {}, 399 | "outputs": [], 400 | "source": [ 401 | "df = pd.read_csv(\"wine.data\",header=None)" 402 | ] 403 | }, 404 | { 405 | "cell_type": "code", 406 | "execution_count": 17, 407 | "metadata": {}, 408 | "outputs": [], 409 | "source": [ 410 | "Y = df[[0]]\n", 411 | "X = df[[1,2,3,4,5,6,7,8,9,10,11,12,13]]" 412 | ] 413 | }, 414 | { 415 | "cell_type": "code", 416 | "execution_count": 26, 417 | "metadata": { 418 | "scrolled": true 419 | }, 420 | "outputs": [], 421 | "source": [ 422 | "X = MinMaxScaler().fit_transform(X)\n", 423 | "Y = Y.values.ravel()" 424 | ] 425 | }, 426 | { 427 | "cell_type": "code", 428 | "execution_count": 20, 429 | "metadata": {}, 430 | "outputs": [], 431 | "source": [ 432 | "from sklearn.model_selection import StratifiedKFold\n", 433 | "from sklearn.neural_network import MLPClassifier" 434 | ] 435 | }, 436 | { 437 | "cell_type": "code", 438 | "execution_count": 39, 439 | "metadata": {}, 440 | "outputs": [ 441 | { 442 | "name": "stdout", 443 | "output_type": "stream", 444 | "text": [ 445 | "Tasa de aciertos = 0.9722222222222223\n" 446 | ] 447 | } 448 | ], 449 | "source": [ 450 | "# Perceptrón Multicapa\n", 451 | "score = 0\n", 452 | "skf = StratifiedKFold(n_splits=10)\n", 453 | "for train_index, test_index in skf.split(X,Y):\n", 454 | " reg = MLPClassifier(hidden_layer_sizes=(10),solver=\"sgd\",alpha=0.1,batch_size=1,max_iter=5000,verbose=False,activation=\"identity\",momentum=0)\n", 455 | " reg.fit(X[train_index],Y[train_index])\n", 456 | " score += reg.score(X[test_index],Y[test_index])\n", 457 | "print(\"Tasa de aciertos =\",score/10)\n", 458 | " " 459 | ] 460 | }, 461 | { 462 | "cell_type": "code", 463 | "execution_count": 35, 464 | "metadata": {}, 465 | "outputs": [], 466 | "source": [ 467 | "from sklearn.linear_model import LogisticRegression\n", 468 | "from sklearn.metrics import accuracy_score" 469 | ] 470 | }, 471 | { 472 | "cell_type": "code", 473 | "execution_count": 40, 474 | "metadata": {}, 475 | "outputs": [ 476 | { 477 | "name": "stdout", 478 | "output_type": "stream", 479 | "text": [ 480 | "Tasa de aciertos = 0.9833333333333334\n" 481 | ] 482 | } 483 | ], 484 | "source": [ 485 | "# Reg Logistica\n", 486 | "score = 0\n", 487 | "skf = StratifiedKFold(n_splits=10)\n", 488 | "for train_index, test_index in skf.split(X,Y):\n", 489 | " reg = LogisticRegression(solver='lbfgs',multi_class='multinomial')\n", 490 | " reg.fit(X[train_index],Y[train_index])\n", 491 | " y_p = reg.predict(X[test_index])\n", 492 | " score += accuracy_score(Y[test_index],y_p)\n", 493 | "print(\"Tasa de aciertos =\", score/10)" 494 | ] 495 | } 496 | ], 497 | "metadata": { 498 | "kernelspec": { 499 | "display_name": "Python 3", 500 | "language": "python", 501 | "name": "python3" 502 | }, 503 | "language_info": { 504 | "codemirror_mode": { 505 | "name": "ipython", 506 | "version": 3 507 | }, 508 | "file_extension": ".py", 509 | "mimetype": "text/x-python", 510 | "name": "python", 511 | "nbconvert_exporter": "python", 512 | "pygments_lexer": "ipython3", 513 | "version": "3.7.3" 514 | } 515 | }, 516 | "nbformat": 4, 517 | "nbformat_minor": 2 518 | } 519 | -------------------------------------------------------------------------------- /house-votes-84.csv: -------------------------------------------------------------------------------- 1 | v16,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,party 2 | 1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 3 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 4 | -1,-1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,democrat 5 | 1,-1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,1,-1,-1,democrat 6 | 1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,1,democrat 7 | 1,-1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,democrat 8 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,democrat 9 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,-1,republican 10 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 11 | -1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 12 | -1,-1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,-1,republican 13 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,republican 14 | -1,-1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,-1,democrat 15 | -1,1,1,1,-1,-1,1,1,1,-1,1,1,-1,-1,-1,1,democrat 16 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,-1,-1,-1,republican 17 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,-1,-1,republican 18 | 1,1,-1,1,-1,-1,1,-1,1,-1,1,1,1,-1,-1,-1,democrat 19 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,democrat 20 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,-1,republican 21 | 1,1,1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 22 | 1,1,1,1,-1,-1,-1,1,1,-1,-1,1,-1,-1,-1,1,democrat 23 | 1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 24 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 25 | 1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 26 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 27 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 28 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 29 | 1,1,1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 30 | 1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,1,1,-1,republican 31 | 1,1,1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 32 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 33 | -1,1,1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 34 | 1,1,1,1,-1,-1,-1,1,1,1,1,-1,-1,1,-1,1,democrat 35 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 36 | 1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 37 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 38 | 1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,1,-1,republican 39 | 1,1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,-1,republican 40 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 41 | 1,1,-1,1,-1,-1,-1,1,1,1,1,1,-1,1,-1,1,democrat 42 | -1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 43 | -1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 44 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 45 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 46 | -1,1,1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,-1,democrat 47 | -1,1,1,1,-1,-1,-1,1,1,-1,-1,1,-1,-1,-1,1,democrat 48 | 1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 49 | -1,1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,democrat 50 | 1,1,1,1,-1,-1,-1,1,1,-1,-1,-1,-1,-1,1,-1,democrat 51 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 52 | 1,1,1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 53 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 54 | -1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 55 | -1,1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 56 | -1,1,1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,1,-1,democrat 57 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,1,1,1,1,-1,republican 58 | 1,-1,1,-1,1,1,1,-1,-1,-1,1,1,1,1,1,-1,republican 59 | 1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 60 | 1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 61 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 62 | -1,1,1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 63 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 64 | -1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 65 | 1,1,1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,-1,democrat 66 | 1,1,1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,-1,democrat 67 | 1,1,1,-1,1,1,1,1,-1,-1,-1,-1,1,1,1,-1,republican 68 | 1,-1,1,-1,1,1,1,1,-1,-1,-1,1,1,1,1,-1,republican 69 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 70 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,democrat 71 | 1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 72 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,democrat 73 | 1,1,1,1,1,-1,-1,1,1,1,1,1,-1,-1,1,-1,republican 74 | -1,1,1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 75 | 1,1,-1,1,1,1,-1,1,-1,1,1,-1,-1,1,1,-1,republican 76 | 1,1,-1,1,-1,-1,1,1,1,1,1,1,-1,-1,1,1,democrat 77 | -1,-1,1,1,1,1,1,-1,-1,-1,1,1,-1,1,1,-1,democrat 78 | -1,-1,1,1,-1,1,1,-1,-1,-1,1,1,1,1,1,-1,democrat 79 | 1,-1,1,1,1,1,1,-1,1,1,1,1,1,1,1,-1,democrat 80 | 1,1,1,1,-1,1,1,-1,-1,-1,1,1,-1,1,1,-1,democrat 81 | -1,-1,-1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,1,-1,republican 82 | -1,1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,1,-1,democrat 83 | 1,1,-1,1,-1,-1,-1,1,1,-1,1,1,1,-1,1,-1,democrat 84 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 85 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 86 | -1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 87 | 1,-1,-1,1,-1,1,1,-1,-1,-1,1,1,1,1,1,-1,democrat 88 | -1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 89 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 90 | 1,-1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1,-1,democrat 91 | -1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,-1,1,1,-1,republican 92 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 93 | 1,1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,democrat 94 | 1,1,1,1,-1,-1,-1,1,1,-1,1,1,-1,-1,-1,1,democrat 95 | 1,1,-1,1,-1,-1,-1,1,-1,1,1,1,-1,-1,-1,1,democrat 96 | 1,1,-1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,democrat 97 | 1,1,-1,1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,1,democrat 98 | 1,-1,-1,-1,-1,1,1,-1,-1,-1,-1,1,1,1,1,-1,democrat 99 | 1,1,-1,-1,-1,1,1,1,-1,-1,1,1,-1,-1,1,-1,democrat 100 | 1,1,1,1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,democrat 101 | -1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 102 | 1,1,-1,-1,-1,1,1,-1,-1,-1,-1,1,1,-1,1,-1,democrat 103 | 1,1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,-1,1,-1,democrat 104 | -1,1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,democrat 105 | -1,1,-1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,democrat 106 | -1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,1,1,-1,democrat 107 | 1,1,1,1,-1,-1,-1,-1,1,1,-1,1,-1,-1,-1,1,democrat 108 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 109 | -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,-1,republican 110 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 111 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 112 | 1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 113 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 114 | -1,-1,-1,1,-1,-1,1,1,1,-1,1,-1,-1,-1,-1,1,democrat 115 | -1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 116 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 117 | 1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 118 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 119 | 1,1,1,1,1,1,-1,1,-1,-1,-1,-1,1,1,1,-1,republican 120 | 1,-1,1,1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,democrat 121 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 122 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 123 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 124 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,1,-1,republican 125 | 1,1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,1,1,-1,republican 126 | 1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 127 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 128 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 129 | 1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,1,1,democrat 130 | 1,-1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,-1,-1,1,democrat 131 | -1,-1,-1,1,-1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,democrat 132 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 133 | 1,-1,-1,1,-1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,democrat 134 | -1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 135 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 136 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 137 | -1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 138 | 1,-1,1,-1,1,1,1,-1,-1,-1,1,1,1,1,-1,-1,republican 139 | 1,-1,-1,1,-1,-1,1,1,1,1,1,-1,-1,-1,1,1,democrat 140 | 1,-1,-1,1,-1,-1,1,1,1,1,1,-1,-1,-1,1,-1,democrat 141 | 1,1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,1,democrat 142 | 1,-1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,republican 143 | 1,-1,-1,-1,1,1,1,1,1,1,1,-1,1,1,1,-1,republican 144 | 1,-1,-1,-1,1,1,1,1,1,1,1,-1,1,1,1,-1,republican 145 | 1,-1,1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,1,1,democrat 146 | -1,-1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,-1,democrat 147 | 1,-1,-1,1,-1,-1,1,1,1,1,1,-1,-1,-1,1,-1,democrat 148 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 149 | 1,-1,-1,-1,-1,-1,-1,1,1,1,1,-1,1,1,1,1,democrat 150 | 1,-1,1,-1,1,1,1,-1,-1,-1,1,1,1,1,1,-1,republican 151 | 1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,1,-1,1,democrat 152 | 1,1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 153 | -1,1,1,-1,1,1,1,-1,-1,1,-1,1,-1,1,1,-1,democrat 154 | 1,-1,1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,1,democrat 155 | 1,-1,-1,1,-1,-1,1,1,1,1,1,1,-1,1,1,-1,democrat 156 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 157 | -1,1,1,-1,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,republican 158 | -1,1,1,-1,1,1,1,1,-1,-1,-1,-1,1,1,1,-1,republican 159 | -1,-1,1,1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,-1,democrat 160 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 161 | -1,-1,1,1,-1,-1,1,1,1,1,1,1,-1,-1,-1,-1,democrat 162 | 1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,1,1,1,1,democrat 163 | 1,-1,-1,-1,-1,1,1,1,-1,-1,-1,-1,1,1,1,-1,democrat 164 | 1,-1,1,1,-1,1,1,1,-1,-1,-1,1,1,1,1,-1,democrat 165 | 1,-1,1,-1,1,1,1,1,-1,-1,-1,-1,1,1,1,-1,republican 166 | -1,1,1,-1,-1,1,1,-1,-1,-1,1,1,1,1,1,-1,democrat 167 | -1,-1,1,1,-1,-1,1,1,1,1,1,1,-1,1,-1,1,democrat 168 | 1,1,-1,1,1,1,1,1,1,-1,1,-1,1,-1,1,1,republican 169 | 1,1,-1,1,1,1,1,1,1,-1,1,1,1,-1,1,1,republican 170 | -1,-1,-1,1,1,1,1,-1,-1,1,-1,-1,-1,1,1,1,democrat 171 | 1,1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,1,-1,democrat 172 | -1,1,-1,1,-1,-1,-1,-1,1,1,-1,-1,-1,-1,-1,1,democrat 173 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 174 | 1,-1,1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 175 | 1,-1,-1,-1,-1,1,1,-1,-1,-1,1,1,1,1,1,-1,democrat 176 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 177 | 1,-1,1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 178 | 1,-1,-1,1,1,-1,-1,1,1,1,1,-1,-1,-1,1,1,republican 179 | 1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,democrat 180 | -1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,democrat 181 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 182 | -1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 183 | 1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,democrat 184 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 185 | -1,-1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,democrat 186 | 1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,democrat 187 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 188 | 1,-1,1,1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,democrat 189 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 190 | -1,1,-1,-1,1,1,1,1,1,-1,-1,-1,1,-1,1,-1,republican 191 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 192 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 193 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 194 | 1,-1,-1,-1,-1,-1,1,1,1,1,-1,1,-1,-1,1,1,democrat 195 | 1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 196 | 1,-1,-1,1,-1,-1,1,1,-1,1,1,1,-1,-1,-1,1,democrat 197 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 198 | -1,-1,-1,1,-1,-1,1,1,1,1,-1,1,1,-1,1,1,democrat 199 | 1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,-1,-1,1,-1,republican 200 | -1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,democrat 201 | -1,1,1,-1,-1,-1,-1,1,1,-1,-1,1,-1,-1,-1,1,democrat 202 | 1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,1,1,democrat 203 | 1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 204 | 1,1,-1,1,-1,-1,1,1,1,1,1,1,-1,-1,-1,1,democrat 205 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 206 | 1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,1,1,1,-1,republican 207 | 1,-1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,-1,-1,democrat 208 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,1,-1,republican 209 | 1,1,-1,-1,1,1,1,1,-1,-1,1,-1,1,1,1,-1,republican 210 | 1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 211 | 1,1,1,1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,democrat 212 | 1,-1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,1,democrat 213 | 1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 214 | 1,-1,-1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 215 | 1,-1,1,1,-1,-1,1,-1,1,1,-1,1,-1,1,-1,1,democrat 216 | 1,1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 217 | -1,-1,1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,democrat 218 | -1,1,1,1,-1,1,1,-1,-1,-1,1,-1,-1,-1,1,1,democrat 219 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 220 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 221 | 1,-1,1,1,-1,-1,-1,-1,1,1,-1,1,-1,-1,1,1,democrat 222 | -1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 223 | -1,-1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,-1,-1,1,democrat 224 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 225 | 1,-1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,-1,republican 226 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,-1,1,1,-1,republican 227 | 1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 228 | 1,-1,-1,1,-1,-1,1,1,1,1,-1,1,-1,-1,1,1,democrat 229 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 230 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,-1,-1,republican 231 | 1,-1,1,1,1,1,1,1,-1,1,1,-1,1,1,1,-1,republican 232 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 233 | 1,-1,1,-1,1,1,1,-1,-1,1,1,-1,1,1,1,-1,republican 234 | -1,-1,1,1,-1,-1,-1,1,1,-1,-1,1,-1,-1,-1,1,democrat 235 | 1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 236 | -1,-1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,1,1,democrat 237 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,1,-1,republican 238 | 1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 239 | 1,1,-1,1,-1,-1,1,1,1,-1,-1,-1,1,1,-1,-1,democrat 240 | -1,1,1,1,-1,-1,-1,1,1,-1,1,-1,-1,-1,-1,1,democrat 241 | 1,-1,-1,-1,1,1,1,1,-1,-1,1,-1,-1,-1,1,1,republican 242 | 1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,1,1,1,-1,republican 243 | 1,1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,1,1,democrat 244 | 1,-1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,republican 245 | 1,-1,1,1,-1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,democrat 246 | 1,1,-1,1,-1,-1,-1,-1,1,1,1,-1,-1,-1,-1,1,democrat 247 | 1,1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,democrat 248 | 1,-1,-1,1,-1,1,-1,1,1,1,-1,-1,-1,-1,1,-1,democrat 249 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,-1,republican 250 | -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,republican 251 | 1,1,-1,1,-1,-1,-1,1,1,-1,-1,1,-1,-1,-1,1,democrat 252 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 253 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 254 | 1,1,1,1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,1,democrat 255 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 256 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,democrat 257 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,1,democrat 258 | -1,-1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,republican 259 | 1,-1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,-1,republican 260 | 1,-1,-1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 261 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 262 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,democrat 263 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 264 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 265 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 266 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 267 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,democrat 268 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,1,-1,republican 269 | 1,1,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,republican 270 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 271 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 272 | 1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 273 | 1,-1,1,1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 274 | -1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 275 | 1,-1,-1,-1,1,1,-1,1,1,-1,1,-1,1,1,1,-1,republican 276 | 1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,1,1,republican 277 | -1,-1,-1,1,-1,1,1,-1,-1,-1,-1,-1,-1,1,1,-1,democrat 278 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,republican 279 | 1,-1,-1,1,1,1,1,1,1,-1,1,-1,-1,-1,1,-1,republican 280 | 1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 281 | -1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 282 | 1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,democrat 283 | -1,1,-1,1,1,1,1,1,1,-1,-1,-1,-1,-1,1,-1,republican 284 | -1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,-1,1,1,-1,republican 285 | 1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 286 | 1,-1,-1,1,-1,-1,1,1,1,1,1,1,-1,-1,-1,-1,democrat 287 | 1,-1,-1,1,-1,-1,1,1,1,1,1,1,-1,-1,-1,1,democrat 288 | -1,-1,-1,1,-1,-1,1,-1,1,-1,1,1,1,-1,1,1,democrat 289 | 1,1,1,1,-1,-1,1,1,1,1,-1,1,-1,1,-1,-1,democrat 290 | 1,1,1,1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,democrat 291 | -1,1,1,1,-1,1,1,-1,1,-1,1,1,-1,1,1,-1,democrat 292 | 1,1,-1,1,-1,-1,1,-1,1,1,1,-1,-1,1,1,-1,democrat 293 | 1,1,-1,1,-1,-1,1,1,1,1,1,-1,-1,-1,1,-1,democrat 294 | 1,1,-1,1,-1,-1,1,1,1,-1,1,1,-1,1,1,1,democrat 295 | 1,1,1,1,-1,-1,1,1,1,1,1,1,-1,1,1,1,democrat 296 | -1,-1,1,1,-1,-1,1,1,1,-1,1,1,-1,1,1,-1,democrat 297 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,-1,-1,republican 298 | 1,-1,-1,1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,republican 299 | -1,1,1,1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,1,democrat 300 | 1,-1,1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,democrat 301 | 1,-1,1,1,-1,-1,1,1,1,1,1,-1,-1,1,1,1,democrat 302 | 1,-1,-1,-1,1,1,-1,1,1,1,1,-1,1,1,1,-1,republican 303 | 1,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,1,democrat 304 | 1,-1,-1,-1,1,1,1,1,-1,-1,1,-1,1,1,1,-1,republican 305 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 306 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 307 | -1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 308 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 309 | -1,1,-1,1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,-1,democrat 310 | -1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 311 | 1,1,-1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,1,democrat 312 | -1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,1,republican 313 | 1,-1,-1,1,-1,-1,1,1,1,1,1,-1,-1,1,-1,-1,democrat 314 | 1,1,1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 315 | 1,-1,1,1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 316 | 1,-1,1,-1,1,1,1,1,1,-1,-1,1,1,1,1,1,republican 317 | -1,-1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,republican 318 | -1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,1,1,1,1,democrat 319 | 1,1,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 320 | -1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 321 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 322 | 1,-1,1,1,-1,-1,1,-1,1,1,1,-1,-1,1,1,-1,democrat 323 | 1,1,1,1,-1,-1,-1,1,1,1,1,-1,-1,1,-1,-1,democrat 324 | -1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,1,1,-1,democrat 325 | -1,1,1,1,-1,1,1,-1,1,-1,1,-1,-1,1,1,-1,democrat 326 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,republican 327 | 1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,democrat 328 | 1,1,1,-1,1,-1,-1,1,1,1,-1,1,-1,-1,1,-1,democrat 329 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 330 | 1,1,1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,-1,democrat 331 | -1,1,-1,1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,1,democrat 332 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 333 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 334 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 335 | 1,-1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 336 | 1,-1,1,1,-1,-1,1,1,1,-1,-1,1,1,-1,-1,1,democrat 337 | -1,-1,-1,-1,1,1,1,-1,-1,-1,1,1,1,1,1,-1,republican 338 | 1,-1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,1,-1,democrat 339 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,democrat 340 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,1,1,democrat 341 | -1,1,-1,-1,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,republican 342 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,1,1,-1,1,-1,republican 343 | 1,-1,-1,1,-1,-1,1,1,1,1,1,1,-1,-1,-1,1,democrat 344 | 1,-1,1,1,-1,1,-1,1,-1,-1,1,1,-1,1,-1,1,democrat 345 | 1,-1,-1,-1,1,1,-1,1,-1,1,1,-1,-1,-1,1,-1,republican 346 | 1,-1,-1,1,-1,-1,-1,1,1,1,1,1,-1,-1,-1,1,democrat 347 | 1,-1,-1,-1,1,1,1,1,-1,-1,1,-1,1,-1,1,1,republican 348 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 349 | -1,1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 350 | -1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,-1,-1,1,democrat 351 | 1,-1,1,1,1,1,1,1,1,1,-1,-1,1,1,1,-1,republican 352 | 1,-1,1,-1,-1,-1,1,1,-1,1,-1,1,-1,-1,-1,1,democrat 353 | 1,-1,-1,1,1,1,1,1,1,1,1,-1,1,1,1,1,republican 354 | -1,-1,1,-1,1,-1,1,1,1,1,-1,1,-1,1,-1,1,democrat 355 | 1,-1,-1,1,1,1,1,1,-1,-1,1,1,1,1,1,-1,republican 356 | 1,-1,1,1,-1,-1,1,1,1,1,1,-1,-1,-1,-1,1,democrat 357 | 1,1,-1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,1,1,republican 358 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 359 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 360 | -1,1,1,1,-1,-1,1,1,1,1,1,1,1,1,1,-1,democrat 361 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 362 | 1,1,-1,1,-1,-1,1,1,1,1,1,-1,-1,1,-1,-1,democrat 363 | -1,1,-1,1,-1,1,1,1,-1,1,1,-1,-1,1,1,-1,democrat 364 | 1,1,1,1,-1,-1,1,1,1,1,1,1,1,1,-1,-1,democrat 365 | -1,1,1,-1,1,1,1,-1,-1,-1,1,1,-1,1,-1,-1,republican 366 | 1,1,1,-1,1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,republican 367 | -1,-1,1,-1,-1,1,1,-1,-1,-1,1,1,-1,1,1,-1,democrat 368 | -1,1,-1,1,-1,-1,-1,1,1,-1,1,1,-1,-1,-1,-1,democrat 369 | -1,1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,1,democrat 370 | 1,-1,1,1,-1,-1,1,1,1,-1,1,-1,-1,-1,-1,1,democrat 371 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,-1,republican 372 | 1,1,1,1,-1,-1,1,1,1,-1,1,-1,-1,-1,-1,1,democrat 373 | -1,1,1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 374 | -1,-1,1,1,1,1,1,-1,-1,-1,-1,1,1,-1,1,-1,democrat 375 | 1,-1,1,1,-1,1,1,-1,1,-1,1,-1,-1,1,1,-1,democrat 376 | 1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 377 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,1,1,-1,1,-1,democrat 378 | 1,1,-1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 379 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,republican 380 | 1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 381 | 1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 382 | 1,1,1,1,-1,-1,1,-1,1,1,-1,1,-1,1,-1,1,democrat 383 | -1,1,1,1,-1,1,1,1,1,1,1,1,-1,1,1,-1,democrat 384 | -1,1,1,-1,1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,democrat 385 | 1,1,1,1,-1,1,1,-1,1,1,1,1,-1,-1,-1,-1,democrat 386 | 1,1,1,1,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,democrat 387 | -1,1,1,-1,-1,1,1,-1,-1,-1,-1,1,1,1,1,1,democrat 388 | -1,-1,-1,1,-1,1,1,-1,1,-1,-1,1,-1,-1,-1,-1,democrat 389 | -1,1,1,1,-1,1,1,-1,1,1,-1,1,-1,-1,1,-1,democrat 390 | -1,-1,1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,democrat 391 | -1,1,-1,1,-1,-1,-1,1,1,1,-1,1,-1,-1,-1,1,democrat 392 | -1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,1,1,-1,1,-1,democrat 393 | -1,1,1,-1,-1,-1,-1,-1,1,1,-1,1,-1,-1,-1,1,democrat 394 | 1,1,1,-1,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,republican 395 | -1,-1,-1,-1,-1,-1,1,-1,1,1,-1,-1,1,1,-1,-1,republican 396 | 1,1,1,-1,-1,-1,1,-1,-1,-1,-1,1,-1,1,-1,-1,democrat 397 | 1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,-1,-1,1,democrat 398 | 1,1,1,1,-1,1,1,-1,1,-1,-1,1,-1,1,-1,1,democrat 399 | 1,1,1,-1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,democrat 400 | 1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,-1,democrat 401 | -1,-1,1,-1,1,-1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 402 | -1,-1,1,-1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,republican 403 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,1,1,1,1,-1,republican 404 | 1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,-1,1,-1,republican 405 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,-1,1,-1,republican 406 | 1,1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 407 | 1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 408 | 1,1,-1,1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,democrat 409 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,democrat 410 | 1,1,-1,1,-1,-1,1,1,1,1,-1,-1,1,-1,1,1,democrat 411 | -1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 412 | 1,-1,-1,-1,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,republican 413 | 1,1,-1,1,-1,-1,1,1,1,1,1,1,-1,-1,-1,-1,democrat 414 | 1,-1,-1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 415 | 1,1,1,1,1,1,1,1,1,-1,1,-1,-1,-1,1,-1,republican 416 | 1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 417 | 1,-1,1,1,-1,-1,1,1,1,-1,1,-1,-1,-1,-1,-1,democrat 418 | 1,1,1,-1,1,1,1,-1,-1,-1,1,-1,-1,1,1,-1,republican 419 | 1,1,1,1,-1,-1,-1,1,1,1,1,1,-1,1,-1,-1,democrat 420 | 1,1,1,1,-1,-1,-1,1,1,-1,1,-1,-1,-1,-1,-1,democrat 421 | 1,1,1,1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,-1,democrat 422 | 1,1,1,1,1,1,1,1,1,-1,1,-1,-1,1,1,-1,republican 423 | 1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1,-1,1,democrat 424 | 1,-1,-1,1,-1,-1,1,1,1,1,-1,1,-1,-1,-1,1,democrat 425 | 1,-1,1,1,-1,-1,1,1,1,1,-1,1,-1,-1,1,1,democrat 426 | 1,-1,1,1,-1,-1,-1,1,1,1,1,1,-1,-1,1,1,democrat 427 | -1,-1,-1,1,-1,-1,-1,1,1,-1,1,1,-1,-1,-1,1,democrat 428 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,democrat 429 | 1,-1,-1,-1,1,1,1,1,1,-1,1,-1,1,1,1,-1,republican 430 | 1,-1,-1,-1,-1,-1,-1,1,1,1,1,-1,-1,1,-1,1,democrat 431 | 1,1,-1,1,-1,-1,-1,1,1,1,1,-1,1,-1,-1,1,democrat 432 | 1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1,1,1,-1,republican 433 | 1,-1,-1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,-1,democrat 434 | 1,-1,-1,-1,1,1,1,-1,-1,-1,-1,1,1,1,1,-1,republican 435 | 1,-1,-1,-1,1,1,1,-1,-1,-1,-1,-1,1,1,1,-1,republican 436 | -1,-1,1,-1,1,1,1,-1,-1,-1,1,-1,1,1,1,-1,republican 437 | -------------------------------------------------------------------------------- /ThoraricSurgery.arff: -------------------------------------------------------------------------------- 1 | @relation 'Thoracic_Surgery_Data' 2 | 3 | @attribute DGN {DGN3,DGN2,DGN4,DGN6,DGN5,DGN8,DGN1} 4 | @attribute PRE4 numeric 5 | @attribute PRE5 numeric 6 | @attribute PRE6 {PRZ2,PRZ1,PRZ0} 7 | @attribute PRE7 {T,F} 8 | @attribute PRE8 {T,F} 9 | @attribute PRE9 {T,F} 10 | @attribute PRE10 {T,F} 11 | @attribute PRE11 {T,F} 12 | @attribute PRE14 {OC11,OC14,OC12,OC13} 13 | @attribute PRE17 {T,F} 14 | @attribute PRE19 {T,F} 15 | @attribute PRE25 {T,F} 16 | @attribute PRE30 {T,F} 17 | @attribute PRE32 {T,F} 18 | @attribute AGE numeric 19 | @attribute Risk1Yr {T,F} 20 | 21 | @data 22 | DGN2,2.88,2.16,PRZ1,F,F,F,T,T,OC14,F,F,F,T,F,60,F 23 | DGN3,3.4,1.88,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,51,F 24 | DGN3,2.76,2.08,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,59,F 25 | DGN3,3.68,3.04,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,54,F 26 | DGN3,2.44,0.96,PRZ2,F,T,F,T,T,OC11,F,F,F,T,F,73,T 27 | DGN3,2.48,1.88,PRZ1,F,F,F,T,F,OC11,F,F,F,F,F,51,F 28 | DGN3,4.36,3.28,PRZ1,F,F,F,T,F,OC12,T,F,F,T,F,59,T 29 | DGN2,3.19,2.5,PRZ1,F,F,F,T,F,OC11,F,F,T,T,F,66,T 30 | DGN3,3.16,2.64,PRZ2,F,F,F,T,T,OC11,F,F,F,T,F,68,F 31 | DGN3,2.32,2.16,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,54,F 32 | DGN3,2.56,2.32,PRZ0,F,T,F,T,F,OC12,F,F,F,F,F,60,F 33 | DGN3,4.28,4.44,PRZ1,F,F,F,F,F,OC12,F,F,F,T,F,58,F 34 | DGN3,3,2.36,PRZ1,F,F,F,T,T,OC11,F,F,F,T,F,68,F 35 | DGN2,3.98,3.06,PRZ2,F,F,F,T,T,OC14,F,F,F,T,F,80,T 36 | DGN3,1.96,1.4,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,77,F 37 | DGN3,4.68,4.16,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,62,F 38 | DGN2,2.21,1.88,PRZ0,F,T,F,F,F,OC12,F,F,F,T,F,56,F 39 | DGN2,2.96,1.67,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,61,F 40 | DGN3,2.6,1.68,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,70,F 41 | DGN3,2.88,2.48,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,71,F 42 | DGN3,4.48,3.48,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,51,F 43 | DGN4,3.32,2.84,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,62,F 44 | DGN3,2.36,1.68,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,62,F 45 | DGN3,3.68,2.32,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,62,F 46 | DGN8,4.32,3.2,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,58,T 47 | DGN5,4.56,72.8,PRZ0,T,T,F,T,F,OC12,F,F,F,T,F,57,F 48 | DGN3,3.24,3.08,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,60,F 49 | DGN3,3.4,3.06,PRZ1,F,F,F,T,T,OC11,F,F,F,T,F,68,T 50 | DGN3,3.16,2.69,PRZ1,F,F,F,T,T,OC11,F,F,F,T,F,56,F 51 | DGN6,3.96,3.28,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,61,F 52 | DGN3,3.24,2.4,PRZ1,T,T,F,F,F,OC14,F,F,F,T,F,55,T 53 | DGN3,4.44,3.48,PRZ1,F,F,F,T,F,OC12,F,F,F,F,F,52,F 54 | DGN5,2.48,1.95,PRZ1,T,F,F,F,F,OC12,T,F,F,F,F,72,F 55 | DGN3,1.81,1.4,PRZ1,F,F,F,T,F,OC12,T,F,F,F,F,68,F 56 | DGN2,2.76,2.2,PRZ1,F,F,F,T,F,OC11,F,F,F,F,F,76,F 57 | DGN3,2.36,1.6,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,58,F 58 | DGN3,2.2,1.96,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,71,F 59 | DGN3,3.68,2.44,PRZ1,F,T,T,F,F,OC12,T,F,F,F,F,61,F 60 | DGN3,4.2,3.08,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,56,F 61 | DGN3,4.6,3.52,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,52,F 62 | DGN5,3.8,2.98,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,60,T 63 | DGN2,3.24,2.52,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,63,T 64 | DGN3,3.2,2.82,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,68,F 65 | DGN5,2.68,2.12,PRZ0,F,F,F,T,F,OC12,F,F,F,T,F,51,T 66 | DGN3,3.56,2.68,PRZ1,T,F,F,T,F,OC12,F,F,F,T,F,60,F 67 | DGN3,2.48,2.08,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,60,F 68 | DGN3,4.16,3.28,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,67,F 69 | DGN3,2.64,2.12,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,72,T 70 | DGN3,4.44,3.12,PRZ2,F,F,F,T,T,OC12,F,F,F,T,F,59,F 71 | DGN3,4.56,3.92,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,55,F 72 | DGN3,2.52,1.96,PRZ1,F,F,F,T,F,OC12,F,F,F,F,F,79,F 73 | DGN3,4,2.88,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,69,F 74 | DGN3,3.2,2.52,PRZ2,T,T,T,T,F,OC12,F,F,F,T,F,68,F 75 | DGN4,3.76,2.52,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,75,F 76 | DGN3,3.68,3.08,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,63,F 77 | DGN4,3.28,2.36,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,65,F 78 | DGN3,3.72,2.88,PRZ1,F,F,T,T,F,OC11,F,F,F,F,F,37,F 79 | DGN3,3.4,2.8,PRZ1,T,F,F,T,T,OC11,T,F,F,T,F,64,T 80 | DGN4,5.12,4.28,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,62,F 81 | DGN3,3.84,3.72,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,58,F 82 | DGN3,3.52,2.28,PRZ0,F,F,F,F,F,OC13,F,F,F,T,F,51,T 83 | DGN3,3.04,2.04,PRZ2,F,F,F,T,T,OC12,F,F,F,T,F,77,F 84 | DGN3,4.96,3.6,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,56,F 85 | DGN3,3.72,2.84,PRZ0,F,F,F,F,F,OC11,T,F,F,F,F,55,F 86 | DGN2,3.15,2.76,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,59,F 87 | DGN3,2.88,2.6,PRZ1,F,F,F,T,F,OC12,F,F,F,F,F,54,F 88 | DGN3,2.36,2,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,39,F 89 | DGN4,2.32,1.76,PRZ1,F,T,F,T,T,OC11,F,F,F,T,F,62,T 90 | DGN3,2.72,2.2,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,61,F 91 | DGN3,3.08,1.8,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,70,F 92 | DGN3,3.48,2.72,PRZ1,F,T,F,F,F,OC11,F,F,F,F,F,53,F 93 | DGN3,3.6,2.6,PRZ1,F,F,F,T,F,OC12,T,F,F,T,F,71,F 94 | DGN3,3.52,2.92,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,63,F 95 | DGN4,6.3,5.48,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,45,F 96 | DGN3,4.6,3.28,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,55,F 97 | DGN3,3.4,2.8,PRZ1,F,F,F,T,F,OC14,F,F,F,T,F,41,T 98 | DGN3,1.84,1.28,PRZ1,F,F,F,T,T,OC11,F,F,F,T,F,66,F 99 | DGN3,3.04,3.6,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,62,T 100 | DGN3,2.2,1.44,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,54,F 101 | DGN3,3.04,2.16,PRZ1,F,F,F,T,F,OC12,F,F,F,F,F,78,F 102 | DGN3,3.68,2.88,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,58,F 103 | DGN3,1.96,1.68,PRZ1,F,F,F,T,F,OC14,F,F,F,T,F,59,F 104 | DGN3,3.24,1.64,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,63,F 105 | DGN3,2.84,2.36,PRZ1,F,F,F,T,F,OC11,T,F,F,F,F,62,F 106 | DGN3,4.28,3.28,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,51,F 107 | DGN3,3.76,2.72,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,58,F 108 | DGN3,4.9,4.19,PRZ0,F,F,T,T,F,OC12,F,F,F,F,F,52,F 109 | DGN3,2.36,2,PRZ1,F,F,T,F,F,OC12,F,F,T,T,F,67,F 110 | DGN5,2.68,1.76,PRZ2,F,T,F,T,T,OC11,F,F,F,T,F,76,F 111 | DGN3,2.83,66.4,PRZ1,T,T,T,T,F,OC12,F,F,F,T,F,75,F 112 | DGN4,3.52,2.72,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,80,F 113 | DGN3,2.6,2,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,73,F 114 | DGN3,3.6,2.48,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,60,T 115 | DGN3,6.08,4.92,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,50,F 116 | DGN3,1.88,1.44,PRZ2,F,F,F,T,T,OC12,F,F,F,T,F,87,F 117 | DGN3,4.56,3.6,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,54,F 118 | DGN4,2.68,2,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,70,T 119 | DGN6,3.04,2.4,PRZ2,F,F,F,T,F,OC11,F,F,F,T,F,76,F 120 | DGN3,2.63,67.3,PRZ1,F,F,T,T,F,OC11,F,F,F,T,F,54,F 121 | DGN3,4.6,2.92,PRZ1,F,T,T,T,F,OC12,F,F,F,T,F,57,T 122 | DGN3,3.36,2.67,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,72,F 123 | DGN3,1.84,1.64,PRZ1,F,F,F,T,T,OC12,T,F,F,T,F,72,F 124 | DGN4,4.32,3.24,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,76,F 125 | DGN3,2.35,1.64,PRZ1,F,F,F,T,F,OC11,F,F,F,F,T,59,F 126 | DGN3,2.84,1.88,PRZ1,F,F,F,T,F,OC11,F,F,F,F,F,53,F 127 | DGN5,4.95,4.12,PRZ1,F,F,F,F,T,OC11,F,F,F,F,F,57,F 128 | DGN3,2.48,2.08,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,55,F 129 | DGN3,3.6,2.6,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,54,F 130 | DGN3,3.16,2.96,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,63,F 131 | DGN3,3.24,2.36,PRZ1,F,F,T,T,F,OC12,F,F,F,T,F,74,F 132 | DGN2,4.48,4.2,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,55,F 133 | DGN3,4,2.6,PRZ1,F,F,F,T,F,OC12,T,F,F,T,F,58,F 134 | DGN3,3.68,64.1,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,60,F 135 | DGN3,4.68,3.48,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,52,F 136 | DGN3,4.52,3.32,PRZ0,F,F,F,T,F,OC12,F,F,F,T,F,58,F 137 | DGN4,2.76,1.76,PRZ1,F,T,F,T,F,OC11,T,F,F,T,F,61,T 138 | DGN4,2.88,2.24,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,73,F 139 | DGN3,2.84,2.16,PRZ1,F,F,F,T,F,OC12,T,F,F,T,F,53,F 140 | DGN4,3.48,2.56,PRZ1,F,F,F,F,F,OC11,F,F,F,T,F,57,F 141 | DGN3,2.56,1.6,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,75,F 142 | DGN2,3.84,2.56,PRZ1,F,F,F,T,F,OC11,F,F,F,F,F,59,F 143 | DGN3,3.56,2.76,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,74,F 144 | DGN2,2.8,2.12,PRZ1,F,F,T,T,F,OC13,F,F,F,T,F,80,F 145 | DGN4,3.3,2.56,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,67,F 146 | DGN3,3.36,2.8,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,76,F 147 | DGN3,2.83,1.96,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,71,F 148 | DGN3,4.56,2.68,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,62,F 149 | DGN3,2,1,PRZ1,F,T,F,T,T,OC11,T,F,F,T,F,73,T 150 | DGN4,3.31,2,PRZ2,F,F,T,T,F,OC12,F,F,F,T,F,81,T 151 | DGN2,5.6,4.64,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,45,F 152 | DGN3,3.32,2.87,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,63,F 153 | DGN2,2.12,1.72,PRZ1,F,F,F,F,F,OC12,F,F,F,T,F,74,F 154 | DGN2,2.5,71.1,PRZ0,F,F,T,F,F,OC13,F,F,F,T,F,64,T 155 | DGN3,2,1.44,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,63,F 156 | DGN3,4.84,3.48,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,56,F 157 | DGN3,2.92,2.28,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,63,F 158 | DGN2,3.76,3.08,PRZ1,F,F,F,T,F,OC13,F,F,F,T,F,54,F 159 | DGN3,2.08,1.52,PRZ1,F,F,F,T,F,OC14,F,F,F,T,F,49,T 160 | DGN3,2.44,2.08,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,57,F 161 | DGN3,3.72,3.12,PRZ1,F,T,F,F,F,OC12,F,F,F,F,F,52,F 162 | DGN2,2.16,1.56,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,63,F 163 | DGN3,4.2,3.24,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,73,F 164 | DGN3,5.17,4.3,PRZ1,F,F,F,F,F,OC11,F,F,F,F,F,47,F 165 | DGN4,2.08,1.76,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,69,T 166 | DGN2,3.64,2.48,PRZ2,F,F,F,T,T,OC11,F,F,F,T,F,70,F 167 | DGN3,3.96,2.96,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,60,F 168 | DGN3,3.92,3.08,PRZ1,F,F,F,T,F,OC11,F,F,F,F,F,70,F 169 | DGN3,2.92,2.2,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,68,F 170 | DGN3,3.64,2.76,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,74,F 171 | DGN3,2.72,2.36,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,71,F 172 | DGN3,2.6,2.24,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,56,F 173 | DGN3,3.88,2.84,PRZ1,F,T,F,T,F,OC11,F,F,F,T,F,66,T 174 | DGN3,2.72,2.04,PRZ1,T,F,F,F,F,OC12,F,F,F,F,F,76,T 175 | DGN3,3.44,3.13,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,78,F 176 | DGN3,3.12,3.24,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,68,F 177 | DGN3,2.6,2.32,PRZ1,F,F,F,F,T,OC12,T,F,F,F,F,66,F 178 | DGN3,3.28,2.32,PRZ1,F,F,T,T,F,OC13,F,F,F,T,F,67,F 179 | DGN3,2.76,1.6,PRZ1,F,F,F,T,T,OC12,F,T,F,T,F,60,F 180 | DGN3,3.08,2.32,PRZ1,F,T,F,T,T,OC12,F,F,T,T,F,61,F 181 | DGN3,2.2,1.7,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,58,F 182 | DGN3,2.92,1.88,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,76,F 183 | DGN3,2.88,2.36,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,56,F 184 | DGN3,3.2,2.28,PRZ1,T,T,F,T,F,OC12,F,F,F,T,F,67,F 185 | DGN2,2.4,1.96,PRZ1,F,F,F,T,F,OC12,F,F,F,F,F,73,F 186 | DGN2,3,2.4,PRZ1,F,F,F,T,F,OC14,F,F,F,T,F,58,F 187 | DGN3,3.2,2.21,PRZ1,F,T,T,T,F,OC12,F,F,F,T,F,54,F 188 | DGN2,3.4,2.12,PRZ1,F,F,F,T,T,OC11,F,F,F,T,F,62,F 189 | DGN3,2.57,1.72,PRZ1,F,F,F,T,T,OC11,F,F,F,T,F,81,F 190 | DGN3,2.28,2.08,PRZ0,F,F,F,F,F,OC11,T,F,F,T,F,56,F 191 | DGN3,2.44,1.96,PRZ1,F,T,T,T,F,OC13,F,F,F,F,F,60,T 192 | DGN3,4.04,1.88,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,66,F 193 | DGN2,2.88,2.2,PRZ0,F,F,F,F,F,OC12,T,F,F,T,F,62,F 194 | DGN2,3.16,2.56,PRZ1,F,T,T,T,F,OC12,F,F,T,T,F,62,F 195 | DGN3,2.6,2.36,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,55,T 196 | DGN3,1.44,1.04,PRZ1,F,F,F,T,T,OC11,F,F,F,T,F,62,F 197 | DGN3,3.68,2.36,PRZ0,F,F,T,T,F,OC12,F,F,F,T,F,71,T 198 | DGN3,3.2,2.72,PRZ2,F,F,F,T,F,OC14,F,F,F,T,F,52,F 199 | DGN3,3.04,2.32,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,59,F 200 | DGN3,4.32,4.32,PRZ1,F,T,F,T,T,OC12,F,F,F,T,F,48,F 201 | DGN3,3,2.36,PRZ2,F,F,F,T,T,OC12,F,F,F,T,F,60,F 202 | DGN3,3.64,2.88,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,61,F 203 | DGN3,5.08,4.08,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,59,F 204 | DGN3,3.16,2.36,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,64,F 205 | DGN3,2.8,3.36,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,56,F 206 | DGN3,2.52,2.08,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,58,F 207 | DGN5,3.52,2.56,PRZ0,F,F,T,F,F,OC12,F,F,F,F,F,81,T 208 | DGN3,3.32,2.15,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,64,F 209 | DGN4,3.28,1.64,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,62,F 210 | DGN3,2.28,1.24,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,72,F 211 | DGN4,4.92,3.72,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,60,F 212 | DGN3,2.6,1.56,PRZ0,F,F,F,F,F,OC12,F,F,F,T,T,61,F 213 | DGN3,2.68,2.4,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,60,T 214 | DGN2,3.08,2.48,PRZ1,F,F,F,T,F,OC11,F,F,F,F,F,49,F 215 | DGN3,3.84,3.36,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,53,F 216 | DGN3,3.52,2.8,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,58,F 217 | DGN3,2.73,2.11,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,61,T 218 | DGN3,2.84,2.24,PRZ1,T,T,F,F,F,OC12,F,F,F,T,F,68,T 219 | DGN3,2.98,2.64,PRZ1,F,F,F,T,F,OC12,F,F,F,F,F,60,F 220 | DGN3,3.52,2.72,PRZ1,F,F,F,F,F,OC11,F,F,F,T,F,72,F 221 | DGN4,2.44,1.64,PRZ1,F,F,F,T,T,OC11,F,F,F,T,F,72,F 222 | DGN3,2.36,2.08,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,57,F 223 | DGN3,2.76,2.28,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,51,F 224 | DGN2,4.08,2.56,PRZ1,T,T,F,F,F,OC13,F,F,F,T,F,54,F 225 | DGN2,3.6,3.92,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,56,F 226 | DGN3,3.12,2.9,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,77,F 227 | DGN3,2.24,1.76,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,64,F 228 | DGN3,3.96,2.88,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,57,F 229 | DGN3,2.6,1.92,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,66,F 230 | DGN3,4.2,3.24,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,70,F 231 | DGN2,2.8,1.6,PRZ1,F,T,F,T,T,OC12,F,F,F,T,F,53,T 232 | DGN3,4.72,4.56,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,51,F 233 | DGN3,3.58,2.64,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,58,T 234 | DGN3,2.44,2.12,PRZ1,T,T,T,F,F,OC11,F,F,F,T,F,58,F 235 | DGN3,2.22,1.36,PRZ0,F,F,F,F,F,OC12,T,F,F,T,F,63,T 236 | DGN3,2.96,2.32,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,51,F 237 | DGN2,2.66,8.56,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,61,F 238 | DGN2,3.24,1.88,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,61,F 239 | DGN3,4.52,3.6,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,76,F 240 | DGN3,4,3.08,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,71,F 241 | DGN3,2.84,2.12,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,69,F 242 | DGN5,2.87,2.08,PRZ1,F,F,F,T,F,OC13,F,F,F,T,F,56,T 243 | DGN4,4.24,3.68,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,67,F 244 | DGN3,4.8,3.41,PRZ1,F,F,T,T,F,OC12,F,F,F,T,F,54,F 245 | DGN3,3.72,3.04,PRZ0,F,F,F,F,F,OC11,F,F,T,T,F,63,F 246 | DGN3,4.96,3.48,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,47,F 247 | DGN4,2.76,2.16,PRZ1,T,F,F,F,F,OC12,T,F,F,T,F,62,F 248 | DGN3,2.96,2.44,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,65,F 249 | DGN3,2.64,2.44,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,63,T 250 | DGN3,2.4,1.64,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,64,F 251 | DGN3,2.64,2.08,PRZ1,F,F,F,T,F,OC12,T,F,F,T,F,65,T 252 | DGN3,4.76,3.31,PRZ1,F,F,T,T,F,OC11,F,F,F,T,F,51,F 253 | DGN5,2.88,2.52,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,56,F 254 | DGN3,2.32,1.76,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,70,F 255 | DGN3,2.6,2,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,58,F 256 | DGN3,2.46,1.76,PRZ1,F,F,F,T,T,OC11,F,F,F,T,F,67,F 257 | DGN3,4.16,3.64,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,62,F 258 | DGN3,3.2,1.8,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,74,F 259 | DGN3,3.24,2.64,PRZ0,F,F,F,T,F,OC11,F,F,F,T,F,69,F 260 | DGN5,3.4,2.08,PRZ1,F,F,F,F,T,OC11,F,F,F,T,F,55,T 261 | DGN3,3.52,2.52,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,60,T 262 | DGN3,4.36,3.76,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,72,F 263 | DGN3,5.52,3.56,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,64,F 264 | DGN2,4.88,3.44,PRZ0,F,T,F,T,F,OC14,F,F,F,T,F,75,T 265 | DGN3,4.36,3.92,PRZ1,F,F,F,F,F,OC11,F,F,F,T,F,47,F 266 | DGN3,3.56,2.64,PRZ1,F,F,F,T,F,OC11,F,T,F,T,F,57,F 267 | DGN3,5.49,2.97,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,56,F 268 | DGN4,5.56,4.32,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,68,F 269 | DGN3,4.08,3.2,PRZ0,F,F,F,T,F,OC12,F,F,F,T,F,55,F 270 | DGN4,4.56,3.68,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,62,F 271 | DGN3,2.56,1.8,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,73,F 272 | DGN3,3.8,2.82,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,68,F 273 | DGN3,3.04,2.24,PRZ2,F,F,F,T,T,OC11,F,F,F,T,F,75,T 274 | DGN3,3.81,2.94,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,63,F 275 | DGN3,3.92,2.36,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,61,F 276 | DGN3,3.44,3.52,PRZ1,T,F,F,F,F,OC11,F,F,F,T,F,62,F 277 | DGN3,3.72,78.3,PRZ0,T,F,F,T,F,OC12,F,F,F,T,F,44,F 278 | DGN3,2.8,1.88,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,56,F 279 | DGN3,2.92,2.32,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,54,F 280 | DGN3,3.72,2.48,PRZ1,F,T,F,T,F,OC11,F,F,F,T,F,57,F 281 | DGN3,3.64,2.52,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,56,F 282 | DGN3,2.72,2.09,PRZ0,F,F,F,F,F,OC14,F,F,F,F,F,69,T 283 | DGN3,1.84,1.12,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,72,F 284 | DGN3,2.96,1.72,PRZ0,F,T,F,T,F,OC11,F,F,F,T,F,59,F 285 | DGN4,3.04,2.88,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,70,F 286 | DGN3,2.6,1.92,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,64,F 287 | DGN3,2.92,2.52,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,61,F 288 | DGN3,3.8,2.84,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,72,F 289 | DGN3,3.32,2.92,PRZ2,F,F,F,T,T,OC13,F,F,F,T,F,63,F 290 | DGN3,2.52,1.72,PRZ2,F,F,T,T,T,OC12,F,F,F,T,F,74,T 291 | DGN3,4.28,3.28,PRZ1,T,F,F,T,F,OC11,F,F,F,T,F,71,F 292 | DGN3,2.52,1.72,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,71,T 293 | DGN5,3,2.16,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,72,F 294 | DGN3,2.07,1.6,PRZ0,F,T,F,F,F,OC12,F,F,F,F,F,77,F 295 | DGN4,3.36,2.72,PRZ2,F,F,F,T,T,OC11,T,F,F,T,F,72,F 296 | DGN2,4.04,2.76,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,55,T 297 | DGN3,1.7,1.36,PRZ1,F,F,F,F,T,OC12,F,F,F,T,F,65,F 298 | DGN3,3.04,2.04,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,67,F 299 | DGN3,3.36,2.64,PRZ1,F,F,F,T,F,OC12,T,F,F,T,F,69,F 300 | DGN3,4.57,4.57,PRZ1,F,F,F,T,F,OC11,F,F,F,F,F,55,F 301 | DGN3,4.12,2.32,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,51,F 302 | DGN3,2,1.36,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,64,F 303 | DGN3,3.8,3.68,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,63,F 304 | DGN3,3.16,2.6,PRZ1,T,F,F,T,F,OC12,F,F,F,F,F,69,F 305 | DGN2,2.32,1.68,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,64,F 306 | DGN3,2.32,1.92,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,59,F 307 | DGN3,2.48,1.4,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,73,F 308 | DGN4,4.9,3.96,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,55,F 309 | DGN3,2.96,2.2,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,63,F 310 | DGN3,2.96,1.88,PRZ1,F,F,F,T,T,OC14,F,F,F,T,F,60,F 311 | DGN3,3.52,2.36,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,74,F 312 | DGN3,4.12,3.16,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,65,F 313 | DGN3,2.68,2.32,PRZ1,F,F,F,T,T,OC11,T,F,F,T,F,79,F 314 | DGN1,3.8,2.8,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,62,F 315 | DGN3,4.12,2.88,PRZ1,F,F,F,T,F,OC12,F,F,T,T,F,71,F 316 | DGN2,2.64,1.92,PRZ1,F,F,F,T,F,OC11,T,F,F,T,F,63,F 317 | DGN3,3.68,2.96,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,67,F 318 | DGN3,2.48,1.84,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,55,T 319 | DGN3,4.36,3.24,PRZ1,T,F,T,T,F,OC12,F,F,F,T,F,54,T 320 | DGN3,4.32,2.72,PRZ2,F,T,F,T,T,OC11,F,F,F,T,F,77,F 321 | DGN3,3.4,1.92,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,58,F 322 | DGN3,4.24,3.04,PRZ1,F,T,F,T,T,OC12,F,F,F,T,F,64,F 323 | DGN3,3.28,1.96,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,61,F 324 | DGN3,4.59,3.02,PRZ2,T,F,F,T,T,OC13,F,F,F,F,F,62,T 325 | DGN3,4.16,3.44,PRZ1,F,T,F,T,T,OC12,F,F,F,T,F,67,F 326 | DGN3,5.16,4.28,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,56,F 327 | DGN3,2.76,1.8,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,70,T 328 | DGN5,3.3,2.4,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,70,F 329 | DGN3,2.8,2.32,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,57,F 330 | DGN3,2.32,1.96,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,61,F 331 | DGN3,1.98,1.57,PRZ1,F,F,F,F,T,OC11,F,F,F,T,F,77,F 332 | DGN4,3.4,2.92,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,63,F 333 | DGN3,2.4,1.64,PRZ1,F,T,F,T,T,OC12,F,F,F,F,F,62,F 334 | DGN3,3.12,2.52,PRZ1,T,F,F,T,F,OC12,F,F,F,T,F,59,T 335 | DGN3,2.6,1.84,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,70,F 336 | DGN4,2.12,1.36,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,71,F 337 | DGN2,3.4,2.76,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,56,F 338 | DGN3,3.6,2.64,PRZ1,F,F,F,T,F,OC12,F,F,F,F,F,57,F 339 | DGN3,2.48,2.12,PRZ1,F,F,T,T,F,OC12,F,F,F,T,F,78,F 340 | DGN3,2.4,1.96,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,64,F 341 | DGN3,2.1,69.1,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,62,F 342 | DGN3,5.12,4,PRZ1,F,F,F,T,F,OC14,F,F,F,T,F,49,F 343 | DGN3,4.65,3.78,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,77,T 344 | DGN3,2.72,2.36,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,64,F 345 | DGN2,2.58,1.64,PRZ2,F,T,F,T,T,OC12,F,F,F,T,F,63,F 346 | DGN4,5.16,4.96,PRZ1,F,F,F,F,F,OC11,F,F,F,T,F,54,F 347 | DGN4,5.03,79.3,PRZ1,F,F,T,F,F,OC11,F,F,F,F,F,38,F 348 | DGN3,3.2,2.52,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,75,F 349 | DGN3,2.52,1.92,PRZ2,F,T,F,T,T,OC11,F,F,F,T,F,70,F 350 | DGN3,1.96,1.48,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,59,F 351 | DGN4,2.08,1.84,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,77,F 352 | DGN2,2.94,76,PRZ1,F,T,T,T,F,OC12,F,F,F,F,F,61,F 353 | DGN3,3.52,3.12,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,64,F 354 | DGN3,2.6,1.92,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,59,F 355 | DGN4,2.2,1.8,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,71,F 356 | DGN2,4,3.12,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,67,T 357 | DGN3,2.4,1.8,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,64,F 358 | DGN3,2.32,1.32,PRZ1,F,T,F,T,T,OC11,F,F,F,T,F,68,F 359 | DGN4,3.24,2.6,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,69,F 360 | DGN3,4,3.08,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,64,F 361 | DGN3,2.96,2,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,59,F 362 | DGN3,3.88,2.92,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,67,T 363 | DGN3,2.36,1.76,PRZ1,F,T,F,F,F,OC12,F,F,F,T,F,74,F 364 | DGN4,2.5,1.4,PRZ1,F,T,F,T,F,OC11,F,F,F,T,F,77,F 365 | DGN3,2.96,2.44,PRZ1,F,F,F,T,T,OC11,F,F,F,T,F,60,F 366 | DGN3,3.64,3.12,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,64,F 367 | DGN2,3.12,2.72,PRZ2,F,F,F,T,T,OC14,F,F,F,T,F,70,F 368 | DGN2,3.48,2.84,PRZ1,F,F,F,F,T,OC11,F,F,F,T,F,58,F 369 | DGN3,4.16,3.44,PRZ1,T,F,F,T,F,OC13,F,F,F,T,F,59,F 370 | DGN2,4.2,3.6,PRZ1,F,F,F,F,T,OC11,F,F,F,T,F,39,T 371 | DGN4,1.82,86.3,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,67,F 372 | DGN3,2.64,2.16,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,71,T 373 | DGN3,3.05,1.3,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,70,F 374 | DGN3,2.94,73.3,PRZ1,F,T,T,F,F,OC12,F,F,F,F,F,60,F 375 | DGN3,3.24,52.3,PRZ0,F,F,F,F,F,OC12,T,F,F,T,F,55,F 376 | DGN3,4.28,3.52,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,60,F 377 | DGN3,3.68,3.2,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,55,F 378 | DGN3,2.8,2.44,PRZ1,F,F,T,T,F,OC12,F,F,F,T,F,55,F 379 | DGN3,2,1.36,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,70,T 380 | DGN3,2.4,2.04,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,63,F 381 | DGN4,2.84,2.12,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,64,F 382 | DGN3,2.6,2.12,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,55,F 383 | DGN3,2.84,2.4,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,49,F 384 | DGN3,3.08,1.72,PRZ1,F,F,F,T,T,OC12,T,F,F,T,F,58,T 385 | DGN3,2.2,1.6,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,59,F 386 | DGN3,2.32,1.72,PRZ2,F,F,F,T,T,OC11,F,F,F,T,F,56,F 387 | DGN3,2.04,1.8,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,64,F 388 | DGN3,2.56,2.2,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,62,F 389 | DGN5,2.38,1.72,PRZ1,F,T,F,T,F,OC12,T,F,T,T,F,87,T 390 | DGN6,3.88,2.72,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,77,F 391 | DGN3,3.8,3.16,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,59,F 392 | DGN3,2.88,2.16,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,59,F 393 | DGN3,2.32,1.76,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,55,F 394 | DGN3,2.92,2.4,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,46,F 395 | DGN3,2,1.52,PRZ0,F,T,F,T,F,OC14,T,F,F,T,F,60,F 396 | DGN3,2.4,2.16,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,69,F 397 | DGN3,4.56,3.84,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,74,F 398 | DGN3,4.03,3.09,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,59,F 399 | DGN3,2.16,1.88,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,63,F 400 | DGN3,4.52,3.36,PRZ1,F,F,F,F,T,OC12,F,F,F,T,F,63,F 401 | DGN4,2.72,2.04,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,75,F 402 | DGN3,3.76,1,PRZ0,F,T,F,F,F,OC12,F,F,F,T,F,52,F 403 | DGN3,5,3.88,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,51,F 404 | DGN4,3.4,2.16,PRZ1,T,T,F,T,F,OC12,F,F,F,F,F,68,F 405 | DGN3,2.4,1.88,PRZ1,F,F,F,T,F,OC11,F,F,F,F,F,53,F 406 | DGN3,2,1.64,PRZ1,F,F,F,T,F,OC12,F,F,F,F,F,61,F 407 | DGN3,2.52,1.96,PRZ1,F,F,F,T,F,OC12,T,F,F,T,F,72,F 408 | DGN3,4.4,3.56,PRZ1,F,F,T,T,T,OC11,F,F,F,T,F,60,T 409 | DGN4,4.2,3.32,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,58,F 410 | DGN3,1.96,1.4,PRZ1,F,F,F,T,F,OC13,F,F,F,T,F,69,F 411 | DGN2,3.8,2.67,PRZ1,F,F,F,T,F,OC14,F,F,F,T,F,48,F 412 | DGN3,2.92,2.28,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,75,F 413 | DGN2,1.84,1.36,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,57,F 414 | DGN4,3.56,2.6,PRZ1,F,F,F,T,F,OC13,F,F,F,T,F,68,F 415 | DGN3,3.72,3,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,61,F 416 | DGN4,3.96,2.44,PRZ1,F,F,F,T,T,OC11,F,F,F,T,F,44,F 417 | DGN4,3.04,3.68,PRZ1,F,F,F,T,F,OC11,T,F,F,T,F,64,F 418 | DGN3,2.76,2.08,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,21,F 419 | DGN3,4.56,3.48,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,60,F 420 | DGN2,2.96,2.33,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,72,F 421 | DGN3,2.7,1.9,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,65,F 422 | DGN3,2.48,1.6,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,61,F 423 | DGN3,3.56,2.8,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,69,F 424 | DGN3,2.96,2.2,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,53,F 425 | DGN3,4.04,2.56,PRZ1,F,T,F,T,F,OC12,F,F,F,T,F,55,F 426 | DGN2,2.96,2.24,PRZ0,F,F,F,T,F,OC12,F,F,F,T,F,57,T 427 | DGN6,5.36,3.96,PRZ1,F,F,F,T,F,OC12,F,F,F,F,F,62,F 428 | DGN3,3.44,2.92,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,56,F 429 | DGN2,2.72,2.08,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,67,F 430 | DGN3,3.08,2.24,PRZ1,F,F,F,T,F,OC12,T,F,F,T,F,59,F 431 | DGN3,2.64,2.15,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,59,F 432 | DGN2,2.48,2,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,60,T 433 | DGN3,4.64,4.16,PRZ1,T,F,F,T,F,OC13,F,F,F,T,F,56,F 434 | DGN3,3.32,2.52,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,56,F 435 | DGN2,2.48,2.08,PRZ1,F,T,F,F,F,OC12,F,F,F,T,F,60,F 436 | DGN3,1.46,1,PRZ1,F,T,F,T,F,OC11,F,F,F,T,F,68,F 437 | DGN3,3.4,2.39,PRZ0,F,F,F,F,F,OC11,F,F,F,F,F,63,F 438 | DGN3,3.44,2.4,PRZ1,F,F,F,T,T,OC11,T,F,F,T,F,77,F 439 | DGN3,5.16,4.28,PRZ1,F,F,F,F,F,OC12,F,F,F,T,F,52,F 440 | DGN2,2.6,2.04,PRZ0,T,T,F,F,F,OC12,F,F,F,F,F,70,F 441 | DGN4,2.44,2.08,PRZ2,F,F,F,T,T,OC12,F,F,F,T,F,72,T 442 | DGN5,4.96,4.16,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,62,T 443 | DGN2,3.76,2.96,PRZ1,F,F,F,T,F,OC14,T,F,F,F,F,64,T 444 | DGN3,2.68,2.16,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,70,F 445 | DGN3,5,4.04,PRZ0,F,T,F,T,F,OC12,F,F,F,F,F,60,F 446 | DGN4,2.81,2.31,PRZ1,T,F,F,F,F,OC12,F,F,F,T,F,58,F 447 | DGN3,3.18,2.73,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,47,F 448 | DGN3,2.48,2.08,PRZ1,F,F,F,T,F,OC13,F,F,F,T,F,54,T 449 | DGN3,3.44,2.72,PRZ1,T,T,F,T,F,OC11,F,F,F,F,F,73,F 450 | DGN3,3.12,2.12,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,62,F 451 | DGN3,3.48,2.52,PRZ1,F,F,F,T,F,OC14,T,F,F,T,F,72,F 452 | DGN3,3.87,2.68,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,63,F 453 | DGN3,1.44,1.2,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,58,F 454 | DGN3,2.28,1.82,PRZ0,F,F,F,F,F,OC11,T,F,F,F,F,69,F 455 | DGN3,4.28,2.72,PRZ1,T,T,F,T,F,OC11,F,F,F,T,F,66,F 456 | DGN3,3.08,2.28,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,57,F 457 | DGN3,2.96,2.04,PRZ1,F,F,F,T,F,OC11,F,F,F,T,F,56,F 458 | DGN3,4.8,3.32,PRZ1,F,F,T,T,F,OC12,F,F,F,T,F,54,F 459 | DGN3,4.08,3.2,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,40,F 460 | DGN5,3.67,76.8,PRZ0,T,T,F,T,F,OC12,F,F,F,F,F,61,F 461 | DGN3,2.36,1.6,PRZ1,F,F,F,T,T,OC11,F,F,T,T,F,54,F 462 | DGN3,3,2.44,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,65,F 463 | DGN2,4.44,3.64,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,62,F 464 | DGN2,4.08,2.24,PRZ1,F,F,T,T,F,OC12,F,F,F,F,F,61,F 465 | DGN3,4.12,3.2,PRZ2,F,F,F,T,T,OC11,F,F,F,F,F,76,F 466 | DGN3,2.56,60.9,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,50,F 467 | DGN3,2.72,1.76,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,63,F 468 | DGN8,5.2,4.1,PRZ0,F,F,F,F,F,OC12,F,F,F,F,F,49,F 469 | DGN2,4.4,3.72,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,52,F 470 | DGN3,2.96,2.24,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,69,F 471 | DGN3,2.84,1.88,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,53,T 472 | DGN3,2.28,1.68,PRZ2,F,F,F,T,T,OC11,F,F,F,F,F,77,F 473 | DGN4,3.04,2.36,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,59,F 474 | DGN3,2.8,2.24,PRZ1,T,F,F,T,F,OC13,F,F,F,T,F,70,F 475 | DGN3,2.84,2.32,PRZ1,F,T,F,T,T,OC11,F,F,F,T,F,72,F 476 | DGN3,3.24,2.76,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,70,F 477 | DGN4,2.92,1.92,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,70,F 478 | DGN3,2.4,1.24,PRZ1,F,F,F,T,F,OC12,F,F,F,T,F,62,F 479 | DGN3,4.56,3.2,PRZ0,F,F,F,T,F,OC11,F,F,F,T,F,61,F 480 | DGN3,3.6,3,PRZ1,F,F,F,T,F,OC11,F,F,F,F,F,46,F 481 | DGN3,4.28,3.16,PRZ0,F,F,F,T,F,OC12,F,F,F,F,F,66,F 482 | DGN4,4.65,3.78,PRZ1,F,F,F,T,F,OC12,F,F,F,F,F,55,F 483 | DGN3,1.84,1.56,PRZ1,T,T,F,T,F,OC12,F,F,F,F,F,72,F 484 | DGN3,2.12,1.68,PRZ2,T,T,F,F,F,OC11,F,F,F,T,F,74,F 485 | DGN4,3.44,2.16,PRZ1,F,F,F,T,T,OC12,T,F,F,T,F,57,T 486 | DGN3,3.08,2.16,PRZ1,F,F,F,T,T,OC13,F,F,F,T,F,79,F 487 | DGN2,3.88,2.12,PRZ1,F,F,F,T,F,OC13,F,F,F,T,F,63,F 488 | DGN3,3.76,3.12,PRZ0,F,F,F,F,F,OC11,F,F,F,T,F,61,F 489 | DGN3,3.04,2.08,PRZ1,F,F,F,T,F,OC13,F,F,F,F,F,52,F 490 | DGN3,1.96,1.68,PRZ1,F,F,F,T,T,OC12,F,F,F,T,F,79,F 491 | DGN3,4.72,3.56,PRZ0,F,F,F,F,F,OC12,F,F,F,T,F,51,F 492 | --------------------------------------------------------------------------------