Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
51d65e7
New turbine for response curve
treibinator Nov 8, 2013
d554b99
Response Curve without Output
treibinator Nov 8, 2013
3a5ef78
New turbine for response curve
treibinator Nov 8, 2013
20e707d
Response Curve without Output
treibinator Nov 8, 2013
2887a9b
Merge branch 'develop' of github.com:cigroup-ol/windml into develop
jpzk Nov 9, 2013
fa7b776
added smoothing operator; added benchmark class; added benchmark example
jpzk Nov 11, 2013
2fc5564
Merge branch 'develop' of github.com:cigroup-ol/windml into develop
jpzk Nov 11, 2013
4aebbf4
New turbine for response curve
treibinator Nov 8, 2013
b14027b
Response Curve without Output
treibinator Nov 8, 2013
8b2bbe7
added smoothing operator; added benchmark class; added benchmark example
jpzk Nov 11, 2013
ca3c4cb
Merge branch 'develop' of github.com:cigroup-ol/windml into develop
jpzk Nov 11, 2013
83ec93e
added example for benchmark; modified label in benchmark; added opera…
jpzk Nov 12, 2013
2ad731c
added example folder benchmark to example builder
jpzk Nov 12, 2013
8ed62f6
added example description
jpzk Nov 12, 2013
3d0d65a
modified example added predictor
jpzk Nov 12, 2013
4a30dc7
updated example; added naive predictor
jpzk Nov 12, 2013
f75ff0c
removed obsolete imports
jpzk Nov 13, 2013
b9664a6
removed unused import
jpzk Nov 13, 2013
fe3fc0f
respect PEP 8
jpzk Nov 13, 2013
d7eef1b
added new example; plot of joined wind speed probabilities
jpzk Nov 13, 2013
2da00d6
added new example
jpzk Nov 13, 2013
6729ede
added axis label for example
jpzk Nov 14, 2013
bd461de
added uom
jpzk Nov 14, 2013
4509a23
added (better) axis label with uom
jpzk Nov 14, 2013
f105db8
added (better) axis labels with uom
jpzk Nov 14, 2013
5176dc5
updated colors in example
jpzk Nov 14, 2013
7abb28d
create minimal setup.py to enable installation via pip
Bengt Dec 17, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions doc/sphinxext/example_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,14 @@ def figure_contents(self, path, filelist):
def subdir_contents(self, path, subdirs):
subdirs = [os.path.join(path, subdir) for subdir in subdirs]

headlines = {'missingdata' : 'Missing Data',
headlines = {'benchmark' : 'Benchmark',
'missingdata' : 'Missing Data',
'prediction' : 'Prediction',
'visualization' : 'Visualization',
'statistics' : 'Statistics'}

order = ['prediction', 'visualization', 'missingdata', 'statistics']
order = ['prediction', 'visualization', 'missingdata', 'statistics',\
'benchmark']

toctree = ("\n\n"
".. toctree::\n"
Expand All @@ -472,7 +474,7 @@ def subdir_contents(self, path, subdirs):
rel_html = os.path.relpath(self.html_filename(f), path)

toctree += " ./%s\n\n" % os.path.splitext(rel_html)[0]

contents += (" .. figure:: ./%s\n"
" :target: ./%s\n"
"\n"
Expand Down
27 changes: 27 additions & 0 deletions examples/benchmark/comparison.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""
MSE Comparison of Predictors
-------------------------------------------------------------------------

This example shows a comparison of different predictors: Standard
spatio-temporal predictor with linear regression, univariate predictor
with linear regression (only based on target turbine measurements) and
the naive / persistance model. The testbed is QuickNDirty,
which is only used for the example page presentation.
"""

# Author: Jendrik Poloczek <jendrik.poloczek@madewithtea.com>
# Author: Nils A. Treiber <nils.andre.treiber@uni-oldenburg.de>
# License: BSD 3 clause

from windml.benchmark.benchmark import Benchmark
from windml.prediction.std_linreg import StdLinreg
from windml.prediction.univariate_linreg import UnivariateLinreg
from windml.prediction.naive import Naive

bench = Benchmark()
bench.run(StdLinreg(), 'QuickNDirty')
bench.run(UnivariateLinreg(), 'QuickNDirty')
bench.run(Naive(), 'QuickNDirty')

bench.visualize_mse_on_parks()

2 changes: 1 addition & 1 deletion examples/missingdata/mar_damaged.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

ax.grid(True)
plt.ylim(-2, 32)
plt.ylabel("Corrected Power (MW), Wind Speed (m/s)")
plt.ylabel("Corrected Power [MW], Wind Speed [m/s]")

plt.plot(d_time, y1, label = 'Power Production', color="b", alpha=0.5)
plt.plot(d_time, y2, label = 'Wind Speed', color="g", alpha=0.5)
Expand Down
2 changes: 1 addition & 1 deletion examples/missingdata/mreg_knn_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@

ax.grid(True)
plt.ylim(-2, 32)
plt.ylabel("Corrected Power (MW), Wind Speed (m/s)")
plt.ylabel("Corrected Power [MW], Wind Speed [m/s]")

plt.plot(d_time, y1, label = 'Power Production (interpolated)', color="b")
plt.plot(d_time, y2, label = 'Wind Speed (interpolated)', color="g")
Expand Down
2 changes: 1 addition & 1 deletion examples/missingdata/mreg_lin_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

ax.grid(True)
plt.ylim(-2, 32)
plt.ylabel("Corrected Power (MW), Wind Speed (m/s)")
plt.ylabel("Corrected Power [MW], Wind Speed [m/s]")

plt.plot(d_time, y1, label = 'Power Production (interpolated)', color="b")
plt.plot(d_time, y2, label = 'Wind Speed (interpolated)', color="g")
Expand Down
2 changes: 1 addition & 1 deletion examples/missingdata/mreg_svr_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@

ax.grid(True)
plt.ylim(-2, 32)
plt.ylabel("Corrected Power (MW), Wind Speed (m/s)")
plt.ylabel("Corrected Power [MW], Wind Speed [m/s]")

plt.plot(d_time, y1, label = 'Power Production (interpolated)', color="b")
plt.plot(d_time, y2, label = 'Wind Speed (interpolated)', color="g")
Expand Down
4 changes: 2 additions & 2 deletions examples/missingdata/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ def to_percent(y, position):
formatter = FuncFormatter(to_percent)

plt.gca().xaxis.set_major_formatter(formatter)
plt.xlabel("Rate of Missing Data")
plt.ylabel("Reconstruction MSE")
plt.xlabel("Rate of Missing Data in Percent")
plt.ylabel("Reconstruction MSE of Power [MW]")
plt.xlim([0.1, 0.9])
plt.ylim([0, 10])
plt.legend(loc="upper left")
Expand Down
4 changes: 2 additions & 2 deletions examples/missingdata/reconstruction_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ def to_percent(y, position):
formatter = FuncFormatter(to_percent)

plt.gca().xaxis.set_major_formatter(formatter)
plt.xlabel("Rate of Missing Data")
plt.ylabel("Prediction MSE")
plt.xlabel("Rate of Missing Data in Percent")
plt.ylabel("Prediction MSE of Power [MW]")
plt.xlim([0.1, 0.9])
plt.ylim([12.5, 16])
plt.legend(loc="upper left")
Expand Down
12 changes: 8 additions & 4 deletions examples/prediction/compare_regressors_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from numpy import zeros, float32
from windml.datasets.nrel import NREL
from windml.mapping.power_mapping import PowerMapping
from windml.visualization.colorset import colorset

from sklearn.grid_search import GridSearchCV
from sklearn import linear_model
Expand Down Expand Up @@ -90,12 +91,13 @@ def compute_mse(regressor, param):
regressors = ['rf', 'knn']
params = [1,2,4,8,16,32,64,128]

marker = {'rf': 'go--', 'knn': 'ro--', 'naive': 'bo--'}
color = {'rf': colorset[0], 'knn': colorset[3], 'naive': colorset[2]}
marker = {'rf': 'o--', 'knn': 'o--', 'naive': 'o--'}
labels = {'rf': 'Random Forest', 'knn': 'KNN', 'naive' : 'Naive'}

plt.title("MSE depending on Algorithm Parameter")
plt.xlabel("Algorithm Parameter (k for KNN, Number of Estimators for RF )")
plt.ylabel("MSE")
plt.ylabel("MSE of Power [MW]")
plt.xlim([1, 128])

mse_naive_hats = []
Expand All @@ -106,9 +108,11 @@ def compute_mse(regressor, param):
mse_y_hat, mse_naive_hat = compute_mse(regressor, param)
mse.append(mse_y_hat)
mse_naive_hats.append(mse_naive_hat)
plt.plot(params, mse, marker[regressor], label=labels[regressor])
plt.plot(params, mse, marker[regressor], label=labels[regressor],\
color=color[regressor])

plt.plot(params, mse_naive_hats, marker['naive'], label=labels['naive'])
plt.plot(params, mse_naive_hats, marker['naive'], label=labels['naive'],\
color=color['naive'])

plt.legend(loc='upper right')
plt.show()
14 changes: 9 additions & 5 deletions examples/prediction/horizon_mse.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from numpy import zeros, float32
from windml.datasets.nrel import NREL
from windml.mapping.power_mapping import PowerMapping
from windml.visualization.colorset import colorset

from sklearn.grid_search import GridSearchCV
from sklearn import linear_model
Expand Down Expand Up @@ -87,12 +88,13 @@ def compute_mse(regressor, horizon):
regressors = ['linear', 'knn']
horizons = range(2, 18, 2)

marker = {'linear': 'go--', 'knn': 'ro--', 'naive': 'bo--'}
color = {'linear': colorset[0], 'knn': colorset[3], 'naive': colorset[2]}
marker = {'linear': 'o--', 'knn': 'o--', 'naive': 'o--'}
labels = {'linear': 'Linear', 'knn': 'KNN', 'naive' : 'Naive'}

plt.title("MSE depending on Forecast Horizon")
plt.xlabel("Forecast Horizon")
plt.ylabel("MSE")
plt.xlabel("Forecast Horizon Time [600s]")
plt.ylabel("MSE of Power [MW]")

mse_naive_hats = []
for regressor in regressors:
Expand All @@ -102,9 +104,11 @@ def compute_mse(regressor, horizon):
mse_y_hat, mse_naive_hat = compute_mse(regressor, horizon)
mse.append(mse_y_hat)
mse_naive_hats.append(mse_naive_hat)
plt.plot(horizons, mse, marker[regressor], label=labels[regressor])
plt.plot(horizons, mse, marker[regressor], color=color[regressor],\
label=labels[regressor])

plt.plot(horizons, mse_naive_hats, marker['naive'], label=labels['naive'])
plt.plot(horizons, mse_naive_hats, marker['naive'], label=labels['naive'],\
color=color['naive'])

plt.legend(loc='lower right')
plt.show()
Expand Down
37 changes: 23 additions & 14 deletions examples/prediction/knn_regression_turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from numpy import zeros, float32
from windml.datasets.nrel import NREL
from windml.mapping.power_mapping import PowerMapping
from windml.visualization.colorset import cmap, colorset
from sklearn.neighbors import KNeighborsRegressor

# get windpark and corresponding target. forecast is for the target turbine
Expand Down Expand Up @@ -86,44 +87,52 @@
figure = plt.figure(figsize=(15, 10))

plot_abs = plt.subplot(2, 2, 1)
plt.title("Absolute Labels and True Measurements")
plt.title("Predicted and True Measurements")

# Array of true labels for plotting.
y = zeros(len(y_hat))
for i in range(0, len(y_hat)):
y[i] = (Y[train_to + (i * test_step)])

colors = {'predictor' : colorset[0],
'naive' : colorset[1],
'true' : colorset[3]}

time = range(0, len(y_hat))
plt.plot(time, y, "g-", label="Measurement")
plt.plot(time, y_hat, "r-", label="KNN Label")
plt.plot(time, naive_hat, "b-", label="Naive Label")
plt.plot(time, y, color=colors['true'], label="Measurement")
plt.plot(time, y_hat, color=colors['predictor'], label="KNN-predicted")
plt.plot(time, naive_hat, color=colors['naive'], label="Naive-predicted")
plt.xlabel("Time [600s]")
plt.ylabel("Power [MW]")
plt.xlim([9600, 9750])
plt.ylim([-30, 50])
plt.legend()

plot_scatter = plt.subplot(2, 2, 2)
plt.title("Naive Label and True Measurement")
plt.title("Naive-predicted and True Measurement")
col = abs(y - naive_hat)
plt.scatter(y, naive_hat, c=col, linewidth=0.0, cmap=plt.cm.jet)
plt.xlabel("Y")
plt.ylabel("Naive Label")
plt.scatter(y, naive_hat, c=col, linewidth=0.0, cmap=cmap)
plt.xlabel("True Measurement [MW]")
plt.ylabel("Naive-predicted Measurement [MW]")
plt.xlim([0, 30])
plt.ylim([0, 30])

plot_abs = plt.subplot(2, 2, 3)
plt.title("Absolute Difference")
plt.plot(time, (y_hat - y), "r-", label="KNN Label")
plt.plot(time, (naive_hat - y), "b-", label="Naive Label")
plt.plot(time, (y_hat - y), color=colors['predictor'], label="KNN-predicted")
plt.plot(time, (naive_hat - y), color=colors['true'], label="Naive-predicted")
plt.xlim([9600, 9750])
plt.ylim([-20, 30])
plt.xlabel("Time [600s]")
plt.ylabel("Deviation of True Power [MW]")
plt.legend()

plot_scatter = plt.subplot(2, 2, 4)
plt.title("KNN Label and True Measurement")
plt.title("KNN-predicted and True Measurement")
col = abs(y - y_hat)
plt.scatter(y, y_hat, c=col, linewidth=0.0, cmap=plt.cm.jet)
plt.xlabel("Y")
plt.ylabel("KNN Label")
plt.scatter(y, y_hat, c=col, linewidth=0.0, cmap=cmap)
plt.xlabel("True Measurement [MW]")
plt.ylabel("KNN-predicted Measurement [MW]")
plt.xlim([0, 30])
plt.ylim([0, 30])

Expand Down
41 changes: 23 additions & 18 deletions examples/prediction/lin_regression_turbine.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@

import math
import matplotlib.pyplot as plt

from numpy import zeros, float32
from windml.datasets.nrel import NREL
from windml.visualization.colorset import cmap, colorset
from windml.mapping.power_mapping import PowerMapping

from sklearn.grid_search import GridSearchCV
from sklearn import linear_model

# get windpark and corresponding target. forecast is for the target turbine
Expand Down Expand Up @@ -82,47 +80,54 @@
figure = plt.figure(figsize=(15, 10))

plot_abs = plt.subplot(2, 2, 1)
plt.title("Absolute Labels and True Measurements")
plt.title("Predicted and True Measurements")

# Array of true labels for plotting.
y = zeros(len(y_hat))
for i in range(0, len(y_hat)):
y[i] = (Y[train_to + (i * test_step)])

colors = {'predictor' : colorset[0],
'naive' : colorset[1],
'true' : colorset[3]}

time = range(0, len(y_hat))
plt.plot(time, y, "g-", label="Measurement")
plt.plot(time, y_hat, "r-", label="Linear Label")
plt.plot(time, naive_hat, "b-", label="Naive Label")
plt.plot(time, y, color=colors['true'], label="Measurement")
plt.plot(time, y_hat, color=colors['predictor'], label="Linear-predicted")
plt.plot(time, naive_hat, color=colors['naive'], label="Naive-predicted")
plt.xlabel("Time [600s]")
plt.ylabel("Power [MW]")
plt.xlim([9600, 9750])
plt.ylim([-30, 50])
plt.legend()

plot_scatter = plt.subplot(2, 2, 2)
plt.title("Naive Label and True Measurement")
plt.title("Naive-predicted and True Measurement")
col = abs(y - naive_hat)
plt.scatter(y, naive_hat, c=col, linewidth=0.0, cmap=plt.cm.jet)
plt.xlabel("Y")
plt.ylabel("Naive Label")
plt.scatter(y, naive_hat, c=col, linewidth=0.0, cmap=cmap)
plt.xlabel("True Measurement [MW]")
plt.ylabel("Naive-predicted Measurement [MW]")
plt.xlim([0, 30])
plt.ylim([0, 30])

plot_abs = plt.subplot(2, 2, 3)
plt.title("Absolute Difference")
plt.plot(time, (y_hat - y), "r-", label="Linear Label")
plt.plot(time, (naive_hat - y), "b-", label="Naive Label")
plt.plot(time, (y_hat - y), color=colors['predictor'], label="Linear-predicted")
plt.plot(time, (naive_hat - y), color=colors['true'], label="Naive-predicted")
plt.xlim([9600, 9750])
plt.ylim([-20, 30])
plt.xlabel("Time [600s]")
plt.ylabel("Deviation of True Power [MW]")
plt.legend()

plot_scatter = plt.subplot(2, 2, 4)
plt.title("Linear Label and True Measurement")
plt.title("Linear-predicted and True Measurement")
col = abs(y - y_hat)
plt.scatter(y, y_hat, c=col, linewidth=0.0, cmap=plt.cm.jet)
plt.xlabel("Y")
plt.ylabel("Linear Label")
plt.scatter(y, y_hat, c=col, linewidth=0.0, cmap=cmap)
plt.xlabel("True Measurement [MW]")
plt.ylabel("Linear-predicted Measurement [MW]")
plt.xlim([0, 30])
plt.ylim([0, 30])

plt.show()


Loading