├── Datasets ├── __init__.py ├── IrisLoader.py ├── SwissRollLoader.py ├── AutoMpgLoader.py ├── MnistLoader.py └── AutoMPG │ └── auto-mpg.csv ├── DimensionalityReduction ├── __init__.py ├── PCA.py ├── LLE.py ├── LTSA.py ├── Isomap.py ├── Hessian_LLE.py ├── Modified_LLE.py ├── Laplacian_Eigenmaps.py ├── Kernel_PCA.py ├── TSNE.py └── MDS.py ├── LICENSE ├── .gitignore ├── README.md ├── IrisComparison.py ├── AutoMpgComparison.py ├── MnistComparison.py └── SwissRollComparison.py /Datasets/__init__.py: -------------------------------------------------------------------------------- 1 | class __init__(object): 2 | """Provides loaders for the datasets needed for the comparison.""" 3 | 4 | 5 | -------------------------------------------------------------------------------- /DimensionalityReduction/__init__.py: -------------------------------------------------------------------------------- 1 | class __init__(object): 2 | """Provides the algorithms for the dimensionality reduction.""" 3 | 4 | 5 | -------------------------------------------------------------------------------- /Datasets/IrisLoader.py: -------------------------------------------------------------------------------- 1 | from sklearn import datasets 2 | 3 | def load_iris(): 4 | ''' Gets the Iris plants dataset. Returns a tuple (data, target) containing the dataset and the labels. 5 | 6 | data: The 150 x 4 data matrix containing the single plants. (n_samples = 150, n_features = 4) 7 | target: The 150 x 1 label vector containing the classes for the plants (Iris-Setosa, Iris-Versicolour or Iris-Virginica) 8 | 9 | http://scikit-learn.org/stable/datasets/index.html#iris-plants-dataset 10 | ''' 11 | return datasets.load_iris(return_X_y = True) -------------------------------------------------------------------------------- /Datasets/SwissRollLoader.py: -------------------------------------------------------------------------------- 1 | from sklearn import datasets 2 | 3 | def load_swissroll(n_datapoints=1000, noice=0.0): 4 | ''' Loads the Swiss roll dataset with 1000, zero-varianced datapoints. Returns a tuple (data, target) containing the dataset and the labels. 5 | 6 | data: The 1000 x 3 data matrix containing the points. 7 | target: The univariate position of the sample according to the main dimension of the points in the manifold. Can be used as the color. 8 | 9 | http://scikit-learn.org/stable/modules/generated/sklearn.datasets.make_swiss_roll.html 10 | ''' 11 | return datasets.make_swiss_roll(n_samples=n_datapoints, noise=noice, random_state=None); -------------------------------------------------------------------------------- /DimensionalityReduction/PCA.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from time import time 3 | from sklearn import decomposition 4 | 5 | def fit_transform(X_highdimensional): 6 | ''' 7 | Performs PCA on the given highdimensional dataset. The data needs to be a numpy array of the form (n_samples, n_features). 8 | 9 | X_highdimensional: (n_samples, n_features) matrix containing the highdimensional datapoints. 10 | 11 | Returns a tuple (X_low, time) with the lowdimensional representation and the time the execution took. 12 | ''' 13 | pca = decomposition.PCA(n_components=2) 14 | t0 = time() 15 | X_low = pca.fit_transform(X_highdimensional) 16 | return X_low, (time() - t0) -------------------------------------------------------------------------------- /DimensionalityReduction/LLE.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from time import time 3 | from sklearn import manifold 4 | 5 | def fit_transform(X_highdimensional, n_neighbors=5): 6 | ''' 7 | Performs LLE on the given highdimensional dataset. The data needs to be a numpy array of the form (n_samples, n_features). 8 | 9 | X_highdimensional: (n_samples, n_features) matrix containing the highdimensional datapoints. 10 | n_neighbors: The number of neighbours to consider for each point. Default: 5 11 | 12 | Returns a tuple (X_low, time, err) with the lowdimensional representation, the time the execution took and the error. 13 | ''' 14 | lle = manifold.LocallyLinearEmbedding(n_neighbors, n_components=2, method='standard', eigen_solver='dense') 15 | t0 = time() 16 | X_low = lle.fit_transform(X_highdimensional) 17 | return X_low, (time() - t0), lle.reconstruction_error_ -------------------------------------------------------------------------------- /DimensionalityReduction/LTSA.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from time import time 3 | from sklearn import manifold 4 | 5 | def fit_transform(X_highdimensional, n_neighbors=5): 6 | ''' 7 | Performs LTSA on the given highdimensional dataset. The data needs to be a numpy array of the form (n_samples, n_features). 8 | 9 | X_highdimensional: (n_samples, n_features) matrix containing the highdimensional datapoints. 10 | n_neighbors: The number of neighbours to consider for each point. Default: 5 11 | 12 | Returns a tuple (X_low, time, err) with the lowdimensional representation, the time the execution took and the error. 13 | ''' 14 | ltsa = manifold.LocallyLinearEmbedding(n_neighbors, n_components=2, method='ltsa', eigen_solver="dense") 15 | t0 = time() 16 | X_low = ltsa.fit_transform(X_highdimensional) 17 | return X_low, (time() - t0), ltsa.reconstruction_error_ -------------------------------------------------------------------------------- /DimensionalityReduction/Isomap.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from time import time 3 | from sklearn import manifold 4 | 5 | def fit_transform(X_highdimensional, n_neighbors=5): 6 | ''' 7 | Performs Isomap on the given highdimensional dataset. The data needs to be a numpy array of the form (n_samples, n_features). 8 | 9 | X_highdimensional: (n_samples, n_features) matrix containing the highdimensional datapoints. 10 | n_neighbors: The number of neighbours to consider for each point. Default: 5 11 | 12 | Returns a tuple (X_low, time, error) with the lowdimensional representation and the time the execution took, and the reconstruction error. 13 | ''' 14 | isomap = manifold.Isomap(n_neighbors, n_components=2, eigen_solver="dense") 15 | t0 = time() 16 | X_low = isomap.fit_transform(X_highdimensional); 17 | return X_low, (time() - t0), isomap.reconstruction_error() -------------------------------------------------------------------------------- /DimensionalityReduction/Hessian_LLE.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from time import time 3 | from sklearn import manifold 4 | 5 | def fit_transform(X_highdimensional, n_neighbors=5): 6 | ''' 7 | Performs Hessian LLE on the given highdimensional dataset. The data needs to be a numpy array of the form (n_samples, n_features). 8 | 9 | X_highdimensional: (n_samples, n_features) matrix containing the highdimensional datapoints. 10 | n_neighbors: The number of neighbours to consider for each point. Default: 5 11 | 12 | Returns a tuple (X_low, time, err) with the lowdimensional representation, the time the execution took and the error. 13 | ''' 14 | hlle = manifold.LocallyLinearEmbedding(n_neighbors, n_components=2, method='hessian', eigen_solver="dense") 15 | t0 = time() 16 | X_low = hlle.fit_transform(X_highdimensional) 17 | return X_low, (time() - t0), hlle.reconstruction_error_ -------------------------------------------------------------------------------- /DimensionalityReduction/Modified_LLE.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from time import time 3 | from sklearn import manifold 4 | 5 | def fit_transform(X_highdimensional, n_neighbors=5): 6 | ''' 7 | Performs Modified LLE on the given highdimensional dataset. The data needs to be a numpy array of the form (n_samples, n_features). 8 | 9 | X_highdimensional: (n_samples, n_features) matrix containing the highdimensional datapoints. 10 | n_neighbors: The number of neighbours to consider for each point. Default: 5 11 | 12 | Returns a tuple (X_low, time, err) with the lowdimensional representation, the time the execution took and the error. 13 | ''' 14 | mlle = manifold.LocallyLinearEmbedding(n_neighbors, n_components=2, method='modified', eigen_solver='dense') 15 | t0 = time() 16 | X_low = mlle.fit_transform(X_highdimensional) 17 | return X_low, (time() - t0), mlle.reconstruction_error_ -------------------------------------------------------------------------------- /DimensionalityReduction/Laplacian_Eigenmaps.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from time import time 3 | from sklearn import manifold 4 | 5 | def fit_transform(X_highdimensional, n_neighbors=12): 6 | ''' 7 | Performs Laplacian Eigenmaps on the given highdimensional dataset. The data needs to be a numpy array of the form (n_samples, n_features). 8 | 9 | X_highdimensional: (n_samples, n_features) matrix containing the highdimensional datapoints. 10 | n_neighbors: The number of neighbours to consider for each point. Default: 12 11 | 12 | Returns a tuple (X_low, time) with the lowdimensional representation and the time the execution took. 13 | ''' 14 | laplacian_eigenmaps = manifold.SpectralEmbedding(n_components=2, affinity ="nearest_neighbors", 15 | random_state=None, n_neighbors=n_neighbors) 16 | t0 = time() 17 | X_low = laplacian_eigenmaps.fit_transform(X_highdimensional) 18 | return X_low, (time() - t0) -------------------------------------------------------------------------------- /Datasets/AutoMpgLoader.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | from sklearn import datasets 3 | 4 | def load_autompg(): 5 | ''' Gets the Auto MPG dataset. Returns a tuple (data, target) containing the dataset and the labels. 6 | 7 | data: The 392 x 8 data matrix containing the features. (n_samples = 392, n_features = 8) 8 | Order: (mpg, cylinders, displacement, horsepower, weight, acceleration, model year, origin) 9 | target: The 392 x 1 label vector containing the names of the cars, each being unique 10 | 11 | https://archive.ics.uci.edu/ml/datasets/auto+mpg 12 | 13 | NOTE: The horsepower feature has 6 missing values which are marked with '?' in the original dataset. 14 | The original dataset has 398 entries but we only use the complete entries (392). 15 | ''' 16 | data = pd.read_csv('Datasets/AutoMPG/auto-mpg.csv', index_col='name') 17 | data = data[data.horsepower != '?'] 18 | data.horsepower = data.horsepower.astype('float') 19 | return data.values, data.index -------------------------------------------------------------------------------- /DimensionalityReduction/Kernel_PCA.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from time import time 3 | from sklearn import decomposition 4 | 5 | def fit_transform(X_highdimensional, t_kernel="linear"): 6 | ''' 7 | Performs Kernel PCA on the given highdimensional dataset. The data needs to be a numpy array of the form (n_samples, n_features). 8 | 9 | X_highdimensional: (n_samples, n_features) matrix containing the highdimensional datapoints. 10 | t_kernel: The type of kernel to be used. May be "linear" | "poly" | "rbf" | "sigmoid" | "cosine" | "precomputed" 11 | For more details, see http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.KernelPCA.html 12 | Default: linear, so the result is similar to PCA. 13 | 14 | Returns a tuple (X_low, time) with the lowdimensional representation and the time the execution took. 15 | ''' 16 | kernel_pca = decomposition.KernelPCA(n_components=2, kernel=t_kernel) 17 | t0 = time() 18 | X_low = kernel_pca.fit_transform(X_highdimensional) 19 | return X_low, (time() - t0) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Marcus Rottschäfer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /DimensionalityReduction/TSNE.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from time import time 3 | from sklearn import manifold 4 | 5 | def fit_transform(X_highdimensional, perplexity=30.0): 6 | ''' 7 | Performs t-SNE on the given highdimensional dataset. The data needs to be a numpy array of the form (n_samples, n_features). 8 | 9 | X_highdimensional: (n_samples, n_features) matrix containing the highdimensional datapoints. 10 | perplexity: Quoting from https://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html: 11 | "The perplexity is related to the number of nearest neighbors that is used in other manifold 12 | learning algorithms. Larger datasets usually require a larger perplexity. Consider selecting 13 | a value between 5 and 50. The choice is not extremely critical since t-SNE is quite 14 | insensitive to this parameter." Default: 30.0 15 | 16 | Returns a tuple (X_low, time) with the lowdimensional representation and the time the execution took. 17 | ''' 18 | tsne = manifold.TSNE(n_components=2, perplexity=perplexity, random_state=None) 19 | t0 = time() 20 | X_low = tsne.fit_transform(X_highdimensional) 21 | return X_low, (time() - t0) -------------------------------------------------------------------------------- /DimensionalityReduction/MDS.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from time import time 3 | from sklearn import manifold 4 | 5 | def fit_transform(X_highdimensional, n_different_init=4, max_iteration=200, is_metric=True): 6 | ''' 7 | Performs (Non-) Metric MDS on the given highdimensional dataset. The data needs to be a numpy array of the form (n_samples, n_features). 8 | 9 | X_highdimensional: (n_samples, n_features) matrix containing the highdimensional datapoints. 10 | n_different_init: The number of times, the algorithm will be started with different initialization. The best result 11 | of the runs (the one with the lowest STRESS) will be taken. Default: 4 12 | max_iteration: Maximal number of iterations the algorithm will take in a single run. Default: 200 13 | is_metric: The boolean value determining whether to use Metric MDS or Non-Metric MDS. 14 | 15 | Returns a tuple (X_low, time, STRESS) with the lowdimensional representation, the time the execution took and the STRESS value. 16 | ''' 17 | mds = manifold.MDS(n_components=2, metric=is_metric, n_init=n_different_init, max_iter=max_iteration, random_state=None) 18 | t0 = time() 19 | X_low = mds.fit_transform(X_highdimensional) 20 | return X_low, (time() - t0), mds.stress_ -------------------------------------------------------------------------------- /Datasets/MnistLoader.py: -------------------------------------------------------------------------------- 1 | import struct 2 | import numpy as np 3 | from sklearn.utils import shuffle 4 | 5 | def load_mnist(n_samples=1000): 6 | ''' Gets the MNIST dataset. Returns a tuple (data, target) containing the dataset and the labels. 7 | 8 | data: The 1000 x 784 data matrix containing the images. (n_samples = 1000, n_features =784) 9 | target: The 1000 x 1 label vector containing the labels for the images 10 | 11 | http://yann.lecun.com/exdb/mnist/ 12 | 13 | NOTE: The dataset consists of 60.000 training images and 10.000 test images. 14 | ''' 15 | # 1) Download at least the two training .gz from http://yann.lecun.com/exdb/mnist/ 16 | # 2) Don't rename them 17 | # 3) Unpack them to the path 'Datasets/MNIST/' 18 | X_train_all = read_idx('Datasets/MNIST/train-images.idx3-ubyte') # load training images 19 | X_train_all = np.reshape(X_train_all, (60000, 784)) 20 | Y_train_all = read_idx('Datasets/MNIST/train-labels.idx1-ubyte') # load training labels 21 | X_train, Y_train = shuffle(X_train_all, Y_train_all, n_samples=n_samples, random_state=1) 22 | return X_train, Y_train 23 | 24 | def read_idx(filename): 25 | """ A function that can read MNIST's idx file format into numpy arrays. 26 | Credits to https://gist.github.com/tylerneylon/ce60e8a06e7506ac45788443f7269e40 27 | """ 28 | with open(filename, 'rb') as f: 29 | zero, data_type, dims = struct.unpack('>HBB', f.read(4)) 30 | shape = tuple(struct.unpack('>I', f.read(4))[0] for d in range(dims)) 31 | return np.fromstring(f.read(), dtype=np.uint8).reshape(shape) -------------------------------------------------------------------------------- /.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 | Datasets/MNIST/train-labels.idx1-ubyte 106 | Datasets/MNIST/train-labels-idx1-ubyte.gz 107 | Datasets/MNIST/train-images.idx3-ubyte 108 | Datasets/MNIST/train-images-idx3-ubyte.gz 109 | Datasets/MNIST/t10k-labels.idx1-ubyte 110 | Datasets/MNIST/t10k-labels-idx1-ubyte.gz 111 | Datasets/MNIST/t10k-images.idx3-ubyte 112 | Datasets/MNIST/t10k-images-idx3-ubyte.gz 113 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Comparison of Dimensionalty Reduction techniques 2 | 3 | Here you find an implementation of a **comparison of various dimensionalty reduction techniques from scikit-learn**. The comparison comprises the following techniques: **PCA, t-SNE, LLE, Hessian LLE, Modified LLE, Isomap, Kernel PCA, Laplacian Eigenmaps, LTSA and (Non-)Metric MDS**. 4 | 5 | These techniques will be compared against each other in their performance on four different datasets. Those datasets are **[Auto MPG](https://archive.ics.uci.edu/ml/datasets/auto+mpg), [Iris](https://archive.ics.uci.edu/ml/datasets/iris), [Swiss Roll](http://people.cs.uchicago.edu/~dinoj/manifold/swissroll.html)** and **[MNIST](http://yann.lecun.com/exdb/mnist/)**. Except for MNIST, no additional dataset needs to be downloaded. 6 | 7 | The results of the comparison will be nicely visualized. The objective is to reach a 2-dimensional visualization of the different datasets with the given dimensionality reduction algorithms. All of the algorithms are chosen from scikit-learn. 8 | 9 | ## How to start it? 10 | 11 | Just choose a dataset, e.g. Iris, and start the Python-script: `python IrisComparison.py`. The projections of the various algorithms will be shown in a 2D plot. To see the performance of the algorithms on the other datasets, start the other `...comparison.py` file, respectively. 12 | 13 | ## Prerequisites 14 | 15 | You need to have the following installed: 16 | - **[numpy](http://www.numpy.org/)** 17 | - **[matplotlib](https://matplotlib.org/)** 18 | - **[scikit-learn](https://scikit-learn.org/stable/)** 19 | - **[pandas](https://pandas.pydata.org/)** 20 | 21 | Just go for `pip install xy`. The code was tested with Python 3.6.6. To see the performance on the MNIST dataset, you need to download it first: 22 | 1. Go to http://yann.lecun.com/exdb/mnist/ 23 | 2. Download at least the two training .gz files, don't rename them 24 | 3. Unpack the files to Datasets/MNIST/ 25 | 26 | ## Visualization 27 | The visualizations at the end of each comparison show the results of a 2D mapping for that specific dataset. The coloring is chosen to be reasonable: In case of classification datasets (e.g. Iris), its according to the *ground-truth* class labels. In case of regression, its the attribute that is tried to be predicted, (e.g. the MPG value for Auto MPG). This makes it easier to compare specific points across the different visualizations and to see, if that specific algorithm is good at recognizing clusters. 28 | 29 | ## Please Note: 30 | Although carefully chosen, the parameters of the different dimensionality reduction algorithms (e.g. which kernel to choose, the number of neighbours to consider, etc.) may not be the 100% perfect choice for the given dataset. The parameters as they are archieve an adequate, although barely perfect projection of the datasets. If you think the projection for a specific technique can be improved with some specific parameters, feel free to notify me. I would be thankful! 31 | 32 | 33 | ## Authors 34 | * **Marcus Rottschäfer** - [GitHub profile](https://github.com/shukali) 35 | * **Valentino Sabbatino** 36 | * **Steven Söhnel** 37 | 38 | If you find any errors, have any ideas or questions regarding the code, feel free to contact us! 39 | 40 | 41 | ## License 42 | This project is licensed under the MIT License. See the [LICENSE.md](LICENSE) file for details. 43 | -------------------------------------------------------------------------------- /IrisComparison.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import DimensionalityReduction.Hessian_LLE as Hessian_LLE 4 | import DimensionalityReduction.Isomap as Isomap 5 | import DimensionalityReduction.Kernel_PCA as Kernel_PCA 6 | import DimensionalityReduction.Laplacian_Eigenmaps as Laplacian_Eigenmaps 7 | import DimensionalityReduction.LLE as LLE 8 | import DimensionalityReduction.LTSA as LTSA 9 | import DimensionalityReduction.MDS as MDS 10 | import DimensionalityReduction.Modified_LLE as Modified_LLE 11 | import DimensionalityReduction.PCA as PCA 12 | import DimensionalityReduction.TSNE as TSNE 13 | 14 | from Datasets import IrisLoader 15 | from matplotlib.ticker import NullFormatter 16 | 17 | # LOAD DATA 18 | X, Y = IrisLoader.load_iris() 19 | 20 | # VISUALISATION 21 | def plot_low_dimensional_embedding(X_low, name="", time=0, error=0): 22 | ''' 23 | Plots the low dimensional embedding given by the matrix X_low (n_samples, n_features). 24 | 25 | X_low: The low-dimensional representation. 26 | name: The (string) name of the technique used for the low-dimensional embedding. 27 | time: Time the execution took. 28 | error: The error of the representation. 29 | ''' 30 | plt.figure() 31 | ax = plt.subplot(111) 32 | ax.scatter(X_low[:, 0], X_low[:, 1], c=Y, s=20, cmap=plt.cm.rainbow) 33 | ax.xaxis.set_major_formatter(NullFormatter()) 34 | ax.yaxis.set_major_formatter(NullFormatter()) 35 | ax.axis('tight') 36 | if error != 0: 37 | plt.title("{}, time: {:.3f}s, error: {:.3e}".format(name, time, error)) 38 | else: 39 | plt.title("{}, time: {:.3f}s".format(name, time)) 40 | 41 | num_neighbors = 50 42 | # PCA 43 | X_pca, tpca = PCA.fit_transform(X) 44 | plot_low_dimensional_embedding(X_pca, "PCA", tpca) 45 | # LLE 46 | X_lle, tlle, err_lle = LLE.fit_transform(X, num_neighbors) 47 | plot_low_dimensional_embedding(X_lle, "LLE", tlle, err_lle) 48 | # Hessian LLE 49 | X_hlle, thlle, err_hlle = Hessian_LLE.fit_transform(X, num_neighbors) 50 | plot_low_dimensional_embedding(X_hlle, "Hessian LLE", thlle, err_hlle) 51 | # Modified LLE 52 | X_mlle, tmlle, err_mlle = Modified_LLE.fit_transform(X, num_neighbors) 53 | plot_low_dimensional_embedding(X_mlle, "Modified LLE", tmlle, err_mlle) 54 | # LTSA 55 | X_ltsa, tltsa, err_ltsa = LTSA.fit_transform(X, num_neighbors) 56 | plot_low_dimensional_embedding(X_ltsa, "LTSA", tltsa, err_ltsa) 57 | # Isomap 58 | X_isomap, tisomap, err_isomap = Isomap.fit_transform(X, n_neighbors=25) 59 | plot_low_dimensional_embedding(X_isomap, "Isomap", tisomap, err_isomap) 60 | # Kernel PCA 61 | X_kpca, tkpca = Kernel_PCA.fit_transform(X, t_kernel="poly") 62 | plot_low_dimensional_embedding(X_kpca, "Kernel PCA", tkpca) 63 | # Laplacian Eigenmaps 64 | X_laplacian, tlaplacian = Laplacian_Eigenmaps.fit_transform(X, n_neighbors=25) 65 | plot_low_dimensional_embedding(X_laplacian, "Laplacian Eigenmaps", tlaplacian) 66 | # Metric MDS 67 | X_mmds, tmmds, stress_m = MDS.fit_transform(X, is_metric=True) 68 | plot_low_dimensional_embedding(X_mmds, "Metric MDS", tmmds, stress_m) 69 | # Non-metric MDS 70 | X_nmmds, tnmmds, stress_nm = MDS.fit_transform(X, is_metric=False) 71 | plot_low_dimensional_embedding(X_nmmds, "Non-metric MDS", tnmmds, stress_nm) 72 | # t-SNE 73 | X_tsne, ttsne = TSNE.fit_transform(X) 74 | plot_low_dimensional_embedding(X_tsne, "t-SNE", ttsne) 75 | 76 | plt.show(); -------------------------------------------------------------------------------- /AutoMpgComparison.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import DimensionalityReduction.Hessian_LLE as Hessian_LLE 4 | import DimensionalityReduction.Isomap as Isomap 5 | import DimensionalityReduction.Kernel_PCA as Kernel_PCA 6 | import DimensionalityReduction.Laplacian_Eigenmaps as Laplacian_Eigenmaps 7 | import DimensionalityReduction.LLE as LLE 8 | import DimensionalityReduction.LTSA as LTSA 9 | import DimensionalityReduction.MDS as MDS 10 | import DimensionalityReduction.Modified_LLE as Modified_LLE 11 | import DimensionalityReduction.PCA as PCA 12 | import DimensionalityReduction.TSNE as TSNE 13 | 14 | from matplotlib.ticker import NullFormatter 15 | from Datasets import AutoMpgLoader 16 | 17 | # LOAD DATA 18 | X, Y = AutoMpgLoader.load_autompg() 19 | 20 | # VISUALISATION 21 | def plot_low_dimensional_embedding(X_low, name="", time=0, error=0): 22 | ''' 23 | Plots the low dimensional embedding given by the matrix X_low (n_samples, n_features). 24 | 25 | X_low: The low-dimensional representation. 26 | name: The (string) name of the technique used for the low-dimensional embedding. 27 | time: Time the execution took. 28 | error: The error of the representation. 29 | ''' 30 | plt.figure() 31 | ax = plt.subplot(111) 32 | # plot the MPG value color-coded 33 | sc = ax.scatter(X_low[:, 0], X_low[:, 1], c=X[:, 0], s=20, cmap=plt.cm.rainbow) 34 | cb = plt.colorbar(sc) 35 | cb.set_label('MPG') 36 | ax.xaxis.set_major_formatter(NullFormatter()) 37 | ax.yaxis.set_major_formatter(NullFormatter()) 38 | ax.axis('tight') 39 | if error != 0: 40 | plt.title("{}, time: {:.3f}s, error: {:.3e}".format(name, time, error)) 41 | else: 42 | plt.title("{}, time: {:.3f}s".format(name, time)) 43 | 44 | num_neighbors = 100 45 | # PCA 46 | X_pca, tpca = PCA.fit_transform(X) 47 | plot_low_dimensional_embedding(X_pca, "PCA", tpca) 48 | # LLE 49 | X_lle, tlle, err_lle = LLE.fit_transform(X, num_neighbors) 50 | plot_low_dimensional_embedding(X_lle, "LLE", tlle, err_lle) 51 | # Hessian LLE 52 | X_hlle, thlle, err_hlle = Hessian_LLE.fit_transform(X, num_neighbors) 53 | plot_low_dimensional_embedding(X_hlle, "Hessian LLE", thlle, err_hlle) 54 | # Modified LLE 55 | X_mlle, tmlle, err_mlle = Modified_LLE.fit_transform(X, num_neighbors) 56 | plot_low_dimensional_embedding(X_mlle, "Modified LLE", tmlle, err_mlle) 57 | # LTSA 58 | X_ltsa, tltsa, err_ltsa = LTSA.fit_transform(X, num_neighbors) 59 | plot_low_dimensional_embedding(X_ltsa, "LTSA", tltsa, err_ltsa) 60 | # Isomap 61 | X_isomap, tisomap, err_isomap = Isomap.fit_transform(X, n_neighbors=50) 62 | plot_low_dimensional_embedding(X_isomap, "Isomap", tisomap, err_isomap) 63 | # Kernel PCA 64 | X_kpca, tkpca = Kernel_PCA.fit_transform(X, t_kernel="poly") 65 | plot_low_dimensional_embedding(X_kpca, "Kernel PCA", tkpca) 66 | # Laplacian Eigenmaps 67 | X_laplacian, tlaplacian = Laplacian_Eigenmaps.fit_transform(X, n_neighbors=100) 68 | plot_low_dimensional_embedding(X_laplacian, "Laplacian Eigenmaps", tlaplacian) 69 | # Metric MDS 70 | X_mmds, tmmds, stress_m = MDS.fit_transform(X, is_metric=True) 71 | plot_low_dimensional_embedding(X_mmds, "Metric MDS", tmmds, stress_m) 72 | # Non-metric MDS 73 | X_nmmds, tnmmds, stress_nm = MDS.fit_transform(X, is_metric=False) 74 | plot_low_dimensional_embedding(X_nmmds, "Non-metric MDS", tnmmds, stress_nm) 75 | # t-SNE 76 | X_tsne, ttsne = TSNE.fit_transform(X) 77 | plot_low_dimensional_embedding(X_tsne, "t-SNE", ttsne) 78 | 79 | plt.show(); -------------------------------------------------------------------------------- /MnistComparison.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import DimensionalityReduction.Hessian_LLE as Hessian_LLE 4 | import DimensionalityReduction.Isomap as Isomap 5 | import DimensionalityReduction.Kernel_PCA as Kernel_PCA 6 | import DimensionalityReduction.Laplacian_Eigenmaps as Laplacian_Eigenmaps 7 | import DimensionalityReduction.LLE as LLE 8 | import DimensionalityReduction.LTSA as LTSA 9 | import DimensionalityReduction.MDS as MDS 10 | import DimensionalityReduction.Modified_LLE as Modified_LLE 11 | import DimensionalityReduction.PCA as PCA 12 | import DimensionalityReduction.TSNE as TSNE 13 | 14 | from Datasets import MnistLoader 15 | from sklearn import datasets 16 | 17 | # LOAD DATA 18 | X, Y = MnistLoader.load_mnist(n_samples=300) 19 | 20 | # VISUALISATION 21 | def plot_low_dimensional_embedding(X_low, name="", time=0, error=0): 22 | ''' 23 | Plots the low dimensional embedding given by the matrix X_low (n_samples, n_features). 24 | 25 | X_low: The low-dimensional representation. 26 | name: The (string) name of the technique used for the low-dimensional embedding. 27 | time: Time the execution took. 28 | error: The error of the representation. 29 | ''' 30 | X_low = (X_low - np.min(X_low, 0)) / ( np.max(X_low, 0) - np.min(X_low, 0)) 31 | plt.figure() 32 | ax = plt.subplot(111) 33 | for i in range(X.shape[0]): 34 | plt.text(X_low[i, 0], X_low[i, 1], str(Y[i]), 35 | color=plt.cm.Set1(Y[i] / 10.), 36 | fontdict={'weight': 'bold', 'size': 8}) 37 | 38 | plt.xticks([]), plt.yticks([]) 39 | if error != 0: 40 | plt.title("{}, time: {:.3f}s, error: {:.3e}".format(name, time, error)) 41 | else: 42 | plt.title("{}, time: {:.3f}s".format(name, time)) 43 | 44 | num_neighbors = 275 45 | # PCA 46 | X_pca, tpca = PCA.fit_transform(X) 47 | plot_low_dimensional_embedding(X_pca, "PCA", tpca) 48 | # LLE 49 | X_lle, tlle, err_lle = LLE.fit_transform(X, num_neighbors) 50 | plot_low_dimensional_embedding(X_lle, "LLE", tlle, err_lle) 51 | # Hessian LLE 52 | X_hlle, thlle, err_hlle = Hessian_LLE.fit_transform(X, num_neighbors) 53 | plot_low_dimensional_embedding(X_hlle, "Hessian LLE", thlle, err_hlle) 54 | # Modified LLE 55 | X_mlle, tmlle, err_mlle = Modified_LLE.fit_transform(X, num_neighbors) 56 | plot_low_dimensional_embedding(X_mlle, "Modified LLE", tmlle, err_mlle) 57 | # LTSA 58 | X_ltsa, tltsa, err_ltsa = LTSA.fit_transform(X, num_neighbors) 59 | plot_low_dimensional_embedding(X_ltsa, "LTSA", tltsa, err_ltsa) 60 | # Isomap 61 | X_isomap, tisomap, err_isomap = Isomap.fit_transform(X, n_neighbors=275) 62 | plot_low_dimensional_embedding(X_isomap, "Isomap", tisomap, err_isomap) 63 | # Kernel PCA 64 | X_kpca, tkpca = Kernel_PCA.fit_transform(X, t_kernel="poly") 65 | plot_low_dimensional_embedding(X_kpca, "Kernel PCA", tkpca) 66 | # Laplacian Eigenmaps 67 | X_laplacian, tlaplacian = Laplacian_Eigenmaps.fit_transform(X, n_neighbors=275) 68 | plot_low_dimensional_embedding(X_laplacian, "Laplacian Eigenmaps", tlaplacian) 69 | # Metric MDS 70 | X_mmds, tmmds, stress_m = MDS.fit_transform(X, is_metric=True) 71 | plot_low_dimensional_embedding(X_mmds, "Metric MDS", tmmds, stress_m) 72 | # Non-metric MDS 73 | X_nmmds, tnmmds, stress_nm = MDS.fit_transform(X, is_metric=False) 74 | plot_low_dimensional_embedding(X_nmmds, "Non-metric MDS", tnmmds, stress_nm) 75 | # t-SNE 76 | X_tsne, ttsne = TSNE.fit_transform(X) 77 | plot_low_dimensional_embedding(X_tsne, "t-SNE", ttsne) 78 | 79 | plt.show(); -------------------------------------------------------------------------------- /SwissRollComparison.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import DimensionalityReduction.Hessian_LLE as Hessian_LLE 4 | import DimensionalityReduction.Isomap as Isomap 5 | import DimensionalityReduction.Kernel_PCA as Kernel_PCA 6 | import DimensionalityReduction.Laplacian_Eigenmaps as Laplacian_Eigenmaps 7 | import DimensionalityReduction.LLE as LLE 8 | import DimensionalityReduction.LTSA as LTSA 9 | import DimensionalityReduction.MDS as MDS 10 | import DimensionalityReduction.Modified_LLE as Modified_LLE 11 | import DimensionalityReduction.PCA as PCA 12 | import DimensionalityReduction.TSNE as TSNE 13 | 14 | from mpl_toolkits.mplot3d import Axes3D 15 | from matplotlib.ticker import NullFormatter 16 | from Datasets import SwissRollLoader 17 | 18 | # LOAD DATA 19 | X, colors = SwissRollLoader.load_swissroll(n_datapoints=1000) 20 | 21 | # VISUALISATION 22 | def plot_original_swissroll(): 23 | ''' 24 | Plots the original Swiss roll dataset. 25 | ''' 26 | fig = plt.figure() 27 | ax = fig.add_subplot(111, projection='3d') 28 | ax.scatter(X[:,0], X[:,1] ,X[:,2], c=colors, cmap=plt.cm.Spectral) 29 | ax.set_title("Original Swiss Roll dataset") 30 | 31 | # VISUALISATION 32 | def plot_low_dimensional_embedding(X_low, name="", time=0, error=0): 33 | ''' 34 | Plots the low dimensional embedding given by the matrix X_low (n_samples, n_features). 35 | 36 | X_low: The low-dimensional representation. 37 | name: The (string) name of the technique used for the low-dimensional embedding. 38 | time: Time the execution took. 39 | error: The error of the representation. 40 | ''' 41 | plt.figure() 42 | ax = plt.subplot(111) 43 | ax.scatter(X_low[:, 0], X_low[:, 1], c=colors, s=20, cmap=plt.cm.Spectral) 44 | ax.xaxis.set_major_formatter(NullFormatter()) 45 | ax.yaxis.set_major_formatter(NullFormatter()) 46 | ax.axis('tight') 47 | if error != 0: 48 | plt.title("{}, time: {:.3f}s, error: {:.3e}".format(name, time, error)) 49 | else: 50 | plt.title("{}, time: {:.3f}s".format(name, time)) 51 | 52 | num_neighbors = 12 53 | # PCA 54 | X_pca, tpca = PCA.fit_transform(X) 55 | plot_low_dimensional_embedding(X_pca, "PCA", tpca) 56 | # LLE 57 | X_lle, tlle, err_lle = LLE.fit_transform(X, num_neighbors) 58 | plot_low_dimensional_embedding(X_lle, "LLE", tlle, err_lle) 59 | # Hessian LLE 60 | X_hlle, thlle, err_hlle = Hessian_LLE.fit_transform(X, num_neighbors) 61 | plot_low_dimensional_embedding(X_hlle, "Hessian LLE", thlle, err_hlle) 62 | # Modified LLE 63 | X_mlle, tmlle, err_mlle = Modified_LLE.fit_transform(X, num_neighbors) 64 | plot_low_dimensional_embedding(X_mlle, "Modified LLE", tmlle, err_mlle) 65 | # LTSA 66 | X_ltsa, tltsa, err_ltsa = LTSA.fit_transform(X, num_neighbors) 67 | plot_low_dimensional_embedding(X_ltsa, "LTSA", tltsa, err_ltsa) 68 | # Isomap 69 | X_isomap, tisomap, err_isomap = Isomap.fit_transform(X, n_neighbors=12) 70 | plot_low_dimensional_embedding(X_isomap, "Isomap", tisomap, err_isomap) 71 | # Kernel PCA 72 | X_kpca, tkpca = Kernel_PCA.fit_transform(X, t_kernel="sigmoid") 73 | plot_low_dimensional_embedding(X_kpca, "Kernel PCA", tkpca) 74 | # Laplacian Eigenmaps 75 | X_laplacian, tlaplacian = Laplacian_Eigenmaps.fit_transform(X, n_neighbors=12) 76 | plot_low_dimensional_embedding(X_laplacian, "Laplacian Eigenmaps", tlaplacian) 77 | # Metric MDS 78 | X_mmds, tmmds, stress_m = MDS.fit_transform(X, is_metric=True) 79 | plot_low_dimensional_embedding(X_mmds, "Metric MDS", tmmds, stress_m) 80 | # Non-metric MDS 81 | X_nmmds, tnmmds, stress_nm = MDS.fit_transform(X, is_metric=False) 82 | plot_low_dimensional_embedding(X_nmmds, "Non-metric MDS", tnmmds, stress_nm) 83 | # t-SNE 84 | X_tsne, ttsne = TSNE.fit_transform(X) 85 | plot_low_dimensional_embedding(X_tsne, "t-SNE", ttsne) 86 | 87 | plot_original_swissroll() 88 | plt.show(); -------------------------------------------------------------------------------- /Datasets/AutoMPG/auto-mpg.csv: -------------------------------------------------------------------------------- 1 | mpg,cylinders,displacement,horsepower,weight,acceleration,model_year,origin,name 2 | 18,8,307,130,3504,12,70,1,chevrolet chevelle malibu 3 | 15,8,350,165,3693,11.5,70,1,buick skylark 320 4 | 18,8,318,150,3436,11,70,1,plymouth satellite 5 | 16,8,304,150,3433,12,70,1,amc rebel sst 6 | 17,8,302,140,3449,10.5,70,1,ford torino 7 | 15,8,429,198,4341,10,70,1,ford galaxie 500 8 | 14,8,454,220,4354,9,70,1,chevrolet impala 9 | 14,8,440,215,4312,8.5,70,1,plymouth fury iii 10 | 14,8,455,225,4425,10,70,1,pontiac catalina 11 | 15,8,390,190,3850,8.5,70,1,amc ambassador dpl 12 | 15,8,383,170,3563,10,70,1,dodge challenger se 13 | 14,8,340,160,3609,8,70,1,plymouth 'cuda 340 14 | 15,8,400,150,3761,9.5,70,1,chevrolet monte carlo 15 | 14,8,455,225,3086,10,70,1,buick estate wagon (sw) 16 | 24,4,113,95,2372,15,70,3,toyota corona mark ii 17 | 22,6,198,95,2833,15.5,70,1,plymouth duster 18 | 18,6,199,97,2774,15.5,70,1,amc hornet 19 | 21,6,200,85,2587,16,70,1,ford maverick 20 | 27,4,97,88,2130,14.5,70,3,datsun pl510 21 | 26,4,97,46,1835,20.5,70,2,volkswagen 1131 deluxe sedan 22 | 25,4,110,87,2672,17.5,70,2,peugeot 504 23 | 24,4,107,90,2430,14.5,70,2,audi 100 ls 24 | 25,4,104,95,2375,17.5,70,2,saab 99e 25 | 26,4,121,113,2234,12.5,70,2,bmw 2002 26 | 21,6,199,90,2648,15,70,1,amc gremlin 27 | 10,8,360,215,4615,14,70,1,ford f250 28 | 10,8,307,200,4376,15,70,1,chevy c20 29 | 11,8,318,210,4382,13.5,70,1,dodge d200 30 | 9,8,304,193,4732,18.5,70,1,hi 1200d 31 | 27,4,97,88,2130,14.5,71,3,datsun pl510 32 | 28,4,140,90,2264,15.5,71,1,chevrolet vega 2300 33 | 25,4,113,95,2228,14,71,3,toyota corona 34 | 25,4,98,?,2046,19,71,1,ford pinto 35 | 19,6,232,100,2634,13,71,1,amc gremlin 36 | 16,6,225,105,3439,15.5,71,1,plymouth satellite custom 37 | 17,6,250,100,3329,15.5,71,1,chevrolet chevelle malibu 38 | 19,6,250,88,3302,15.5,71,1,ford torino 500 39 | 18,6,232,100,3288,15.5,71,1,amc matador 40 | 14,8,350,165,4209,12,71,1,chevrolet impala 41 | 14,8,400,175,4464,11.5,71,1,pontiac catalina brougham 42 | 14,8,351,153,4154,13.5,71,1,ford galaxie 500 43 | 14,8,318,150,4096,13,71,1,plymouth fury iii 44 | 12,8,383,180,4955,11.5,71,1,dodge monaco (sw) 45 | 13,8,400,170,4746,12,71,1,ford country squire (sw) 46 | 13,8,400,175,5140,12,71,1,pontiac safari (sw) 47 | 18,6,258,110,2962,13.5,71,1,amc hornet sportabout (sw) 48 | 22,4,140,72,2408,19,71,1,chevrolet vega (sw) 49 | 19,6,250,100,3282,15,71,1,pontiac firebird 50 | 18,6,250,88,3139,14.5,71,1,ford mustang 51 | 23,4,122,86,2220,14,71,1,mercury capri 2000 52 | 28,4,116,90,2123,14,71,2,opel 1900 53 | 30,4,79,70,2074,19.5,71,2,peugeot 304 54 | 30,4,88,76,2065,14.5,71,2,fiat 124b 55 | 31,4,71,65,1773,19,71,3,toyota corolla 1200 56 | 35,4,72,69,1613,18,71,3,datsun 1200 57 | 27,4,97,60,1834,19,71,2,volkswagen model 111 58 | 26,4,91,70,1955,20.5,71,1,plymouth cricket 59 | 24,4,113,95,2278,15.5,72,3,toyota corona hardtop 60 | 25,4,97.5,80,2126,17,72,1,dodge colt hardtop 61 | 23,4,97,54,2254,23.5,72,2,volkswagen type 3 62 | 20,4,140,90,2408,19.5,72,1,chevrolet vega 63 | 21,4,122,86,2226,16.5,72,1,ford pinto runabout 64 | 13,8,350,165,4274,12,72,1,chevrolet impala 65 | 14,8,400,175,4385,12,72,1,pontiac catalina 66 | 15,8,318,150,4135,13.5,72,1,plymouth fury iii 67 | 14,8,351,153,4129,13,72,1,ford galaxie 500 68 | 17,8,304,150,3672,11.5,72,1,amc ambassador sst 69 | 11,8,429,208,4633,11,72,1,mercury marquis 70 | 13,8,350,155,4502,13.5,72,1,buick lesabre custom 71 | 12,8,350,160,4456,13.5,72,1,oldsmobile delta 88 royale 72 | 13,8,400,190,4422,12.5,72,1,chrysler newport royal 73 | 19,3,70,97,2330,13.5,72,3,mazda rx2 coupe 74 | 15,8,304,150,3892,12.5,72,1,amc matador (sw) 75 | 13,8,307,130,4098,14,72,1,chevrolet chevelle concours (sw) 76 | 13,8,302,140,4294,16,72,1,ford gran torino (sw) 77 | 14,8,318,150,4077,14,72,1,plymouth satellite custom (sw) 78 | 18,4,121,112,2933,14.5,72,2,volvo 145e (sw) 79 | 22,4,121,76,2511,18,72,2,volkswagen 411 (sw) 80 | 21,4,120,87,2979,19.5,72,2,peugeot 504 (sw) 81 | 26,4,96,69,2189,18,72,2,renault 12 (sw) 82 | 22,4,122,86,2395,16,72,1,ford pinto (sw) 83 | 28,4,97,92,2288,17,72,3,datsun 510 (sw) 84 | 23,4,120,97,2506,14.5,72,3,toyouta corona mark ii (sw) 85 | 28,4,98,80,2164,15,72,1,dodge colt (sw) 86 | 27,4,97,88,2100,16.5,72,3,toyota corolla 1600 (sw) 87 | 13,8,350,175,4100,13,73,1,buick century 350 88 | 14,8,304,150,3672,11.5,73,1,amc matador 89 | 13,8,350,145,3988,13,73,1,chevrolet malibu 90 | 14,8,302,137,4042,14.5,73,1,ford gran torino 91 | 15,8,318,150,3777,12.5,73,1,dodge coronet custom 92 | 12,8,429,198,4952,11.5,73,1,mercury marquis brougham 93 | 13,8,400,150,4464,12,73,1,chevrolet caprice classic 94 | 13,8,351,158,4363,13,73,1,ford ltd 95 | 14,8,318,150,4237,14.5,73,1,plymouth fury gran sedan 96 | 13,8,440,215,4735,11,73,1,chrysler new yorker brougham 97 | 12,8,455,225,4951,11,73,1,buick electra 225 custom 98 | 13,8,360,175,3821,11,73,1,amc ambassador brougham 99 | 18,6,225,105,3121,16.5,73,1,plymouth valiant 100 | 16,6,250,100,3278,18,73,1,chevrolet nova custom 101 | 18,6,232,100,2945,16,73,1,amc hornet 102 | 18,6,250,88,3021,16.5,73,1,ford maverick 103 | 23,6,198,95,2904,16,73,1,plymouth duster 104 | 26,4,97,46,1950,21,73,2,volkswagen super beetle 105 | 11,8,400,150,4997,14,73,1,chevrolet impala 106 | 12,8,400,167,4906,12.5,73,1,ford country 107 | 13,8,360,170,4654,13,73,1,plymouth custom suburb 108 | 12,8,350,180,4499,12.5,73,1,oldsmobile vista cruiser 109 | 18,6,232,100,2789,15,73,1,amc gremlin 110 | 20,4,97,88,2279,19,73,3,toyota carina 111 | 21,4,140,72,2401,19.5,73,1,chevrolet vega 112 | 22,4,108,94,2379,16.5,73,3,datsun 610 113 | 18,3,70,90,2124,13.5,73,3,maxda rx3 114 | 19,4,122,85,2310,18.5,73,1,ford pinto 115 | 21,6,155,107,2472,14,73,1,mercury capri v6 116 | 26,4,98,90,2265,15.5,73,2,fiat 124 sport coupe 117 | 15,8,350,145,4082,13,73,1,chevrolet monte carlo s 118 | 16,8,400,230,4278,9.5,73,1,pontiac grand prix 119 | 29,4,68,49,1867,19.5,73,2,fiat 128 120 | 24,4,116,75,2158,15.5,73,2,opel manta 121 | 20,4,114,91,2582,14,73,2,audi 100ls 122 | 19,4,121,112,2868,15.5,73,2,volvo 144ea 123 | 15,8,318,150,3399,11,73,1,dodge dart custom 124 | 24,4,121,110,2660,14,73,2,saab 99le 125 | 20,6,156,122,2807,13.5,73,3,toyota mark ii 126 | 11,8,350,180,3664,11,73,1,oldsmobile omega 127 | 20,6,198,95,3102,16.5,74,1,plymouth duster 128 | 21,6,200,?,2875,17,74,1,ford maverick 129 | 19,6,232,100,2901,16,74,1,amc hornet 130 | 15,6,250,100,3336,17,74,1,chevrolet nova 131 | 31,4,79,67,1950,19,74,3,datsun b210 132 | 26,4,122,80,2451,16.5,74,1,ford pinto 133 | 32,4,71,65,1836,21,74,3,toyota corolla 1200 134 | 25,4,140,75,2542,17,74,1,chevrolet vega 135 | 16,6,250,100,3781,17,74,1,chevrolet chevelle malibu classic 136 | 16,6,258,110,3632,18,74,1,amc matador 137 | 18,6,225,105,3613,16.5,74,1,plymouth satellite sebring 138 | 16,8,302,140,4141,14,74,1,ford gran torino 139 | 13,8,350,150,4699,14.5,74,1,buick century luxus (sw) 140 | 14,8,318,150,4457,13.5,74,1,dodge coronet custom (sw) 141 | 14,8,302,140,4638,16,74,1,ford gran torino (sw) 142 | 14,8,304,150,4257,15.5,74,1,amc matador (sw) 143 | 29,4,98,83,2219,16.5,74,2,audi fox 144 | 26,4,79,67,1963,15.5,74,2,volkswagen dasher 145 | 26,4,97,78,2300,14.5,74,2,opel manta 146 | 31,4,76,52,1649,16.5,74,3,toyota corona 147 | 32,4,83,61,2003,19,74,3,datsun 710 148 | 28,4,90,75,2125,14.5,74,1,dodge colt 149 | 24,4,90,75,2108,15.5,74,2,fiat 128 150 | 26,4,116,75,2246,14,74,2,fiat 124 tc 151 | 24,4,120,97,2489,15,74,3,honda civic 152 | 26,4,108,93,2391,15.5,74,3,subaru 153 | 31,4,79,67,2000,16,74,2,fiat x1.9 154 | 19,6,225,95,3264,16,75,1,plymouth valiant custom 155 | 18,6,250,105,3459,16,75,1,chevrolet nova 156 | 15,6,250,72,3432,21,75,1,mercury monarch 157 | 15,6,250,72,3158,19.5,75,1,ford maverick 158 | 16,8,400,170,4668,11.5,75,1,pontiac catalina 159 | 15,8,350,145,4440,14,75,1,chevrolet bel air 160 | 16,8,318,150,4498,14.5,75,1,plymouth grand fury 161 | 14,8,351,148,4657,13.5,75,1,ford ltd 162 | 17,6,231,110,3907,21,75,1,buick century 163 | 16,6,250,105,3897,18.5,75,1,chevroelt chevelle malibu 164 | 15,6,258,110,3730,19,75,1,amc matador 165 | 18,6,225,95,3785,19,75,1,plymouth fury 166 | 21,6,231,110,3039,15,75,1,buick skyhawk 167 | 20,8,262,110,3221,13.5,75,1,chevrolet monza 2+2 168 | 13,8,302,129,3169,12,75,1,ford mustang ii 169 | 29,4,97,75,2171,16,75,3,toyota corolla 170 | 23,4,140,83,2639,17,75,1,ford pinto 171 | 20,6,232,100,2914,16,75,1,amc gremlin 172 | 23,4,140,78,2592,18.5,75,1,pontiac astro 173 | 24,4,134,96,2702,13.5,75,3,toyota corona 174 | 25,4,90,71,2223,16.5,75,2,volkswagen dasher 175 | 24,4,119,97,2545,17,75,3,datsun 710 176 | 18,6,171,97,2984,14.5,75,1,ford pinto 177 | 29,4,90,70,1937,14,75,2,volkswagen rabbit 178 | 19,6,232,90,3211,17,75,1,amc pacer 179 | 23,4,115,95,2694,15,75,2,audi 100ls 180 | 23,4,120,88,2957,17,75,2,peugeot 504 181 | 22,4,121,98,2945,14.5,75,2,volvo 244dl 182 | 25,4,121,115,2671,13.5,75,2,saab 99le 183 | 33,4,91,53,1795,17.5,75,3,honda civic cvcc 184 | 28,4,107,86,2464,15.5,76,2,fiat 131 185 | 25,4,116,81,2220,16.9,76,2,opel 1900 186 | 25,4,140,92,2572,14.9,76,1,capri ii 187 | 26,4,98,79,2255,17.7,76,1,dodge colt 188 | 27,4,101,83,2202,15.3,76,2,renault 12tl 189 | 17.5,8,305,140,4215,13,76,1,chevrolet chevelle malibu classic 190 | 16,8,318,150,4190,13,76,1,dodge coronet brougham 191 | 15.5,8,304,120,3962,13.9,76,1,amc matador 192 | 14.5,8,351,152,4215,12.8,76,1,ford gran torino 193 | 22,6,225,100,3233,15.4,76,1,plymouth valiant 194 | 22,6,250,105,3353,14.5,76,1,chevrolet nova 195 | 24,6,200,81,3012,17.6,76,1,ford maverick 196 | 22.5,6,232,90,3085,17.6,76,1,amc hornet 197 | 29,4,85,52,2035,22.2,76,1,chevrolet chevette 198 | 24.5,4,98,60,2164,22.1,76,1,chevrolet woody 199 | 29,4,90,70,1937,14.2,76,2,vw rabbit 200 | 33,4,91,53,1795,17.4,76,3,honda civic 201 | 20,6,225,100,3651,17.7,76,1,dodge aspen se 202 | 18,6,250,78,3574,21,76,1,ford granada ghia 203 | 18.5,6,250,110,3645,16.2,76,1,pontiac ventura sj 204 | 17.5,6,258,95,3193,17.8,76,1,amc pacer d/l 205 | 29.5,4,97,71,1825,12.2,76,2,volkswagen rabbit 206 | 32,4,85,70,1990,17,76,3,datsun b-210 207 | 28,4,97,75,2155,16.4,76,3,toyota corolla 208 | 26.5,4,140,72,2565,13.6,76,1,ford pinto 209 | 20,4,130,102,3150,15.7,76,2,volvo 245 210 | 13,8,318,150,3940,13.2,76,1,plymouth volare premier v8 211 | 19,4,120,88,3270,21.9,76,2,peugeot 504 212 | 19,6,156,108,2930,15.5,76,3,toyota mark ii 213 | 16.5,6,168,120,3820,16.7,76,2,mercedes-benz 280s 214 | 16.5,8,350,180,4380,12.1,76,1,cadillac seville 215 | 13,8,350,145,4055,12,76,1,chevy c10 216 | 13,8,302,130,3870,15,76,1,ford f108 217 | 13,8,318,150,3755,14,76,1,dodge d100 218 | 31.5,4,98,68,2045,18.5,77,3,honda accord cvcc 219 | 30,4,111,80,2155,14.8,77,1,buick opel isuzu deluxe 220 | 36,4,79,58,1825,18.6,77,2,renault 5 gtl 221 | 25.5,4,122,96,2300,15.5,77,1,plymouth arrow gs 222 | 33.5,4,85,70,1945,16.8,77,3,datsun f-10 hatchback 223 | 17.5,8,305,145,3880,12.5,77,1,chevrolet caprice classic 224 | 17,8,260,110,4060,19,77,1,oldsmobile cutlass supreme 225 | 15.5,8,318,145,4140,13.7,77,1,dodge monaco brougham 226 | 15,8,302,130,4295,14.9,77,1,mercury cougar brougham 227 | 17.5,6,250,110,3520,16.4,77,1,chevrolet concours 228 | 20.5,6,231,105,3425,16.9,77,1,buick skylark 229 | 19,6,225,100,3630,17.7,77,1,plymouth volare custom 230 | 18.5,6,250,98,3525,19,77,1,ford granada 231 | 16,8,400,180,4220,11.1,77,1,pontiac grand prix lj 232 | 15.5,8,350,170,4165,11.4,77,1,chevrolet monte carlo landau 233 | 15.5,8,400,190,4325,12.2,77,1,chrysler cordoba 234 | 16,8,351,149,4335,14.5,77,1,ford thunderbird 235 | 29,4,97,78,1940,14.5,77,2,volkswagen rabbit custom 236 | 24.5,4,151,88,2740,16,77,1,pontiac sunbird coupe 237 | 26,4,97,75,2265,18.2,77,3,toyota corolla liftback 238 | 25.5,4,140,89,2755,15.8,77,1,ford mustang ii 2+2 239 | 30.5,4,98,63,2051,17,77,1,chevrolet chevette 240 | 33.5,4,98,83,2075,15.9,77,1,dodge colt m/m 241 | 30,4,97,67,1985,16.4,77,3,subaru dl 242 | 30.5,4,97,78,2190,14.1,77,2,volkswagen dasher 243 | 22,6,146,97,2815,14.5,77,3,datsun 810 244 | 21.5,4,121,110,2600,12.8,77,2,bmw 320i 245 | 21.5,3,80,110,2720,13.5,77,3,mazda rx-4 246 | 43.1,4,90,48,1985,21.5,78,2,volkswagen rabbit custom diesel 247 | 36.1,4,98,66,1800,14.4,78,1,ford fiesta 248 | 32.8,4,78,52,1985,19.4,78,3,mazda glc deluxe 249 | 39.4,4,85,70,2070,18.6,78,3,datsun b210 gx 250 | 36.1,4,91,60,1800,16.4,78,3,honda civic cvcc 251 | 19.9,8,260,110,3365,15.5,78,1,oldsmobile cutlass salon brougham 252 | 19.4,8,318,140,3735,13.2,78,1,dodge diplomat 253 | 20.2,8,302,139,3570,12.8,78,1,mercury monarch ghia 254 | 19.2,6,231,105,3535,19.2,78,1,pontiac phoenix lj 255 | 20.5,6,200,95,3155,18.2,78,1,chevrolet malibu 256 | 20.2,6,200,85,2965,15.8,78,1,ford fairmont (auto) 257 | 25.1,4,140,88,2720,15.4,78,1,ford fairmont (man) 258 | 20.5,6,225,100,3430,17.2,78,1,plymouth volare 259 | 19.4,6,232,90,3210,17.2,78,1,amc concord 260 | 20.6,6,231,105,3380,15.8,78,1,buick century special 261 | 20.8,6,200,85,3070,16.7,78,1,mercury zephyr 262 | 18.6,6,225,110,3620,18.7,78,1,dodge aspen 263 | 18.1,6,258,120,3410,15.1,78,1,amc concord d/l 264 | 19.2,8,305,145,3425,13.2,78,1,chevrolet monte carlo landau 265 | 17.7,6,231,165,3445,13.4,78,1,buick regal sport coupe (turbo) 266 | 18.1,8,302,139,3205,11.2,78,1,ford futura 267 | 17.5,8,318,140,4080,13.7,78,1,dodge magnum xe 268 | 30,4,98,68,2155,16.5,78,1,chevrolet chevette 269 | 27.5,4,134,95,2560,14.2,78,3,toyota corona 270 | 27.2,4,119,97,2300,14.7,78,3,datsun 510 271 | 30.9,4,105,75,2230,14.5,78,1,dodge omni 272 | 21.1,4,134,95,2515,14.8,78,3,toyota celica gt liftback 273 | 23.2,4,156,105,2745,16.7,78,1,plymouth sapporo 274 | 23.8,4,151,85,2855,17.6,78,1,oldsmobile starfire sx 275 | 23.9,4,119,97,2405,14.9,78,3,datsun 200-sx 276 | 20.3,5,131,103,2830,15.9,78,2,audi 5000 277 | 17,6,163,125,3140,13.6,78,2,volvo 264gl 278 | 21.6,4,121,115,2795,15.7,78,2,saab 99gle 279 | 16.2,6,163,133,3410,15.8,78,2,peugeot 604sl 280 | 31.5,4,89,71,1990,14.9,78,2,volkswagen scirocco 281 | 29.5,4,98,68,2135,16.6,78,3,honda accord lx 282 | 21.5,6,231,115,3245,15.4,79,1,pontiac lemans v6 283 | 19.8,6,200,85,2990,18.2,79,1,mercury zephyr 6 284 | 22.3,4,140,88,2890,17.3,79,1,ford fairmont 4 285 | 20.2,6,232,90,3265,18.2,79,1,amc concord dl 6 286 | 20.6,6,225,110,3360,16.6,79,1,dodge aspen 6 287 | 17,8,305,130,3840,15.4,79,1,chevrolet caprice classic 288 | 17.6,8,302,129,3725,13.4,79,1,ford ltd landau 289 | 16.5,8,351,138,3955,13.2,79,1,mercury grand marquis 290 | 18.2,8,318,135,3830,15.2,79,1,dodge st. regis 291 | 16.9,8,350,155,4360,14.9,79,1,buick estate wagon (sw) 292 | 15.5,8,351,142,4054,14.3,79,1,ford country squire (sw) 293 | 19.2,8,267,125,3605,15,79,1,chevrolet malibu classic (sw) 294 | 18.5,8,360,150,3940,13,79,1,chrysler lebaron town @ country (sw) 295 | 31.9,4,89,71,1925,14,79,2,vw rabbit custom 296 | 34.1,4,86,65,1975,15.2,79,3,maxda glc deluxe 297 | 35.7,4,98,80,1915,14.4,79,1,dodge colt hatchback custom 298 | 27.4,4,121,80,2670,15,79,1,amc spirit dl 299 | 25.4,5,183,77,3530,20.1,79,2,mercedes benz 300d 300 | 23,8,350,125,3900,17.4,79,1,cadillac eldorado 301 | 27.2,4,141,71,3190,24.8,79,2,peugeot 504 302 | 23.9,8,260,90,3420,22.2,79,1,oldsmobile cutlass salon brougham 303 | 34.2,4,105,70,2200,13.2,79,1,plymouth horizon 304 | 34.5,4,105,70,2150,14.9,79,1,plymouth horizon tc3 305 | 31.8,4,85,65,2020,19.2,79,3,datsun 210 306 | 37.3,4,91,69,2130,14.7,79,2,fiat strada custom 307 | 28.4,4,151,90,2670,16,79,1,buick skylark limited 308 | 28.8,6,173,115,2595,11.3,79,1,chevrolet citation 309 | 26.8,6,173,115,2700,12.9,79,1,oldsmobile omega brougham 310 | 33.5,4,151,90,2556,13.2,79,1,pontiac phoenix 311 | 41.5,4,98,76,2144,14.7,80,2,vw rabbit 312 | 38.1,4,89,60,1968,18.8,80,3,toyota corolla tercel 313 | 32.1,4,98,70,2120,15.5,80,1,chevrolet chevette 314 | 37.2,4,86,65,2019,16.4,80,3,datsun 310 315 | 28,4,151,90,2678,16.5,80,1,chevrolet citation 316 | 26.4,4,140,88,2870,18.1,80,1,ford fairmont 317 | 24.3,4,151,90,3003,20.1,80,1,amc concord 318 | 19.1,6,225,90,3381,18.7,80,1,dodge aspen 319 | 34.3,4,97,78,2188,15.8,80,2,audi 4000 320 | 29.8,4,134,90,2711,15.5,80,3,toyota corona liftback 321 | 31.3,4,120,75,2542,17.5,80,3,mazda 626 322 | 37,4,119,92,2434,15,80,3,datsun 510 hatchback 323 | 32.2,4,108,75,2265,15.2,80,3,toyota corolla 324 | 46.6,4,86,65,2110,17.9,80,3,mazda glc 325 | 27.9,4,156,105,2800,14.4,80,1,dodge colt 326 | 40.8,4,85,65,2110,19.2,80,3,datsun 210 327 | 44.3,4,90,48,2085,21.7,80,2,vw rabbit c (diesel) 328 | 43.4,4,90,48,2335,23.7,80,2,vw dasher (diesel) 329 | 36.4,5,121,67,2950,19.9,80,2,audi 5000s (diesel) 330 | 30,4,146,67,3250,21.8,80,2,mercedes-benz 240d 331 | 44.6,4,91,67,1850,13.8,80,3,honda civic 1500 gl 332 | 40.9,4,85,?,1835,17.3,80,2,renault lecar deluxe 333 | 33.8,4,97,67,2145,18,80,3,subaru dl 334 | 29.8,4,89,62,1845,15.3,80,2,vokswagen rabbit 335 | 32.7,6,168,132,2910,11.4,80,3,datsun 280-zx 336 | 23.7,3,70,100,2420,12.5,80,3,mazda rx-7 gs 337 | 35,4,122,88,2500,15.1,80,2,triumph tr7 coupe 338 | 23.6,4,140,?,2905,14.3,80,1,ford mustang cobra 339 | 32.4,4,107,72,2290,17,80,3,honda accord 340 | 27.2,4,135,84,2490,15.7,81,1,plymouth reliant 341 | 26.6,4,151,84,2635,16.4,81,1,buick skylark 342 | 25.8,4,156,92,2620,14.4,81,1,dodge aries wagon (sw) 343 | 23.5,6,173,110,2725,12.6,81,1,chevrolet citation 344 | 30,4,135,84,2385,12.9,81,1,plymouth reliant 345 | 39.1,4,79,58,1755,16.9,81,3,toyota starlet 346 | 39,4,86,64,1875,16.4,81,1,plymouth champ 347 | 35.1,4,81,60,1760,16.1,81,3,honda civic 1300 348 | 32.3,4,97,67,2065,17.8,81,3,subaru 349 | 37,4,85,65,1975,19.4,81,3,datsun 210 mpg 350 | 37.7,4,89,62,2050,17.3,81,3,toyota tercel 351 | 34.1,4,91,68,1985,16,81,3,mazda glc 4 352 | 34.7,4,105,63,2215,14.9,81,1,plymouth horizon 4 353 | 34.4,4,98,65,2045,16.2,81,1,ford escort 4w 354 | 29.9,4,98,65,2380,20.7,81,1,ford escort 2h 355 | 33,4,105,74,2190,14.2,81,2,volkswagen jetta 356 | 34.5,4,100,?,2320,15.8,81,2,renault 18i 357 | 33.7,4,107,75,2210,14.4,81,3,honda prelude 358 | 32.4,4,108,75,2350,16.8,81,3,toyota corolla 359 | 32.9,4,119,100,2615,14.8,81,3,datsun 200sx 360 | 31.6,4,120,74,2635,18.3,81,3,mazda 626 361 | 28.1,4,141,80,3230,20.4,81,2,peugeot 505s turbo diesel 362 | 30.7,6,145,76,3160,19.6,81,2,volvo diesel 363 | 25.4,6,168,116,2900,12.6,81,3,toyota cressida 364 | 24.2,6,146,120,2930,13.8,81,3,datsun 810 maxima 365 | 22.4,6,231,110,3415,15.8,81,1,buick century 366 | 26.6,8,350,105,3725,19,81,1,oldsmobile cutlass ls 367 | 20.2,6,200,88,3060,17.1,81,1,ford granada gl 368 | 17.6,6,225,85,3465,16.6,81,1,chrysler lebaron salon 369 | 28,4,112,88,2605,19.6,82,1,chevrolet cavalier 370 | 27,4,112,88,2640,18.6,82,1,chevrolet cavalier wagon 371 | 34,4,112,88,2395,18,82,1,chevrolet cavalier 2-door 372 | 31,4,112,85,2575,16.2,82,1,pontiac j2000 se hatchback 373 | 29,4,135,84,2525,16,82,1,dodge aries se 374 | 27,4,151,90,2735,18,82,1,pontiac phoenix 375 | 24,4,140,92,2865,16.4,82,1,ford fairmont futura 376 | 23,4,151,?,3035,20.5,82,1,amc concord dl 377 | 36,4,105,74,1980,15.3,82,2,volkswagen rabbit l 378 | 37,4,91,68,2025,18.2,82,3,mazda glc custom l 379 | 31,4,91,68,1970,17.6,82,3,mazda glc custom 380 | 38,4,105,63,2125,14.7,82,1,plymouth horizon miser 381 | 36,4,98,70,2125,17.3,82,1,mercury lynx l 382 | 36,4,120,88,2160,14.5,82,3,nissan stanza xe 383 | 36,4,107,75,2205,14.5,82,3,honda accord 384 | 34,4,108,70,2245,16.9,82,3,toyota corolla 385 | 38,4,91,67,1965,15,82,3,honda civic 386 | 32,4,91,67,1965,15.7,82,3,honda civic (auto) 387 | 38,4,91,67,1995,16.2,82,3,datsun 310 gx 388 | 25,6,181,110,2945,16.4,82,1,buick century limited 389 | 38,6,262,85,3015,17,82,1,oldsmobile cutlass ciera (diesel) 390 | 26,4,156,92,2585,14.5,82,1,chrysler lebaron medallion 391 | 22,6,232,112,2835,14.7,82,1,ford granada l 392 | 32,4,144,96,2665,13.9,82,3,toyota celica gt 393 | 36,4,135,84,2370,13,82,1,dodge charger 2.2 394 | 27,4,151,90,2950,17.3,82,1,chevrolet camaro 395 | 27,4,140,86,2790,15.6,82,1,ford mustang gl 396 | 44,4,97,52,2130,24.6,82,2,vw pickup 397 | 32,4,135,84,2295,11.6,82,1,dodge rampage 398 | 28,4,120,79,2625,18.6,82,1,ford ranger 399 | 31,4,119,82,2720,19.4,82,1,chevy s-10 --------------------------------------------------------------------------------