"""
Sequence Visualization Based on ISOMAP
-------------------------------------------------------------------------
This example allows to visualize high-dimensional wind time-series, employing dimensionality reduction. A wind speed sequence is mapped into a
3-dimensional latent space to monitor its intrinsic structure onto one time axis.
The values of the 3-dimensional latent space are normalized and mapped to RGB-values.
Thereby, the mapping maintains important properties of the original
high-dimensional data so that varying wind conditions and seasonal changes can
be monitored.
"""
# Author: Oliver Kramer
# License: BSD 3 clause
import sklearn
import numpy as np
import pylab as plt
from sklearn import manifold, decomposition
from windml.datasets.nrel import NREL
# load data and define parameters / training and test sequences
K = 30
ds = NREL()
windpark = ds.get_windpark(NREL.park_id['tehachapi'], 10, 2004)
X = np.array(windpark.get_powermatrix())
X_train = X[:2000]
X_test = X[2000:2000+200*4]
# computation of ISOMAP projection
print "computation of ISOMAP projection"
if(sklearn.__version__ == "0.9"):
X_latent = manifold.Isomap(K, out_dim=2).fit_transform(X_train)
else:
X_latent = manifold.Isomap(K, n_components=2).fit_transform(X_train)
# computation of sequence of closest embedded patterns
sequence = []
for x in X_test:
win = 0
smallest = 10E100
for b in xrange(len(X_train)):
if np.dot(x-X_train[b],x-X_train[b])