<s> """<STR_LIT>""" <EOL> import math <EOL> import matplotlib . pyplot as plt <EOL> from numpy import zeros , float32 <EOL> from windml . datasets . nrel import NREL <EOL> from windml . mapping . power_mapping import PowerMapping <EOL> from sklearn . grid_search import GridSearchCV <EOL> from sklearn . cross_validation import KFold <EOL> from sklearn . svm import SVR <EOL> from sklearn . metrics import mean_squared_error <EOL> park_id = NREL . park_id [ '<STR_LIT>' ] <EOL> windpark = NREL ( ) . get_windpark ( park_id , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> ) <EOL> target = windpark . get_target ( ) <EOL> feature_window , horizon = <NUM_LIT:3> , <NUM_LIT:3> <EOL> mapping = PowerMapping ( ) <EOL> X = mapping . get_features_park ( windpark , feature_window , horizon ) <EOL> y = mapping . get_labels_turbine ( target , feature_window , horizon ) <EOL> train_to , test_to = int ( math . floor ( len ( X ) * <NUM_LIT:0.5> ) ) , len ( X ) <EOL> train_step , test_step = <NUM_LIT:5> , <NUM_LIT:5> <EOL> X_train = X [ : train_to : train_step ] <EOL> y_train = y [ : train_to : train_step ] <EOL> X_test = X [ train_to : test_to : test_step ] <EOL> y_test = y [ train_to : test_to : test_step ] <EOL> """<STR_LIT>""" <EOL> svr = SVR ( kernel = '<STR_LIT>' , epsilon = <NUM_LIT:0.1> , C = <NUM_LIT> , gamma = <NUM_LIT> ) <EOL> svr . fit ( X_train , y_train ) <EOL> y_hat = svr . predict ( X_test ) <EOL> naive_hat = zeros ( len ( y_hat ) , dtype = float32 ) <EOL> for i in range ( <NUM_LIT:0> , len ( y_hat ) ) : <EOL> naive_hat [ i ] = y [ train_to + ( i * test_step ) - horizon ] <EOL> mse_y_hat = mean_squared_error ( y_test , y_hat ) <EOL> mse_naive_hat = mean_squared_error ( y_test , naive_hat ) <EOL> print "<STR_LIT>" , mse_y_hat <EOL> print "<STR_LIT>" , mse_naive_hat <EOL> with plt . style . context ( "<STR_LIT>" ) : <EOL> figure = plt . figure ( figsize = ( <NUM_LIT:8> , <NUM_LIT:5> ) ) <EOL> time = range ( <NUM_LIT:0> , len ( y_hat ) ) <EOL> plt . plot ( time , y_test , label = "<STR_LIT>" ) <EOL> plt . plot ( time , naive_hat , label = "<STR_LIT>" ) <EOL> plt . plot ( time , y_hat , label = "<STR_LIT>" ) <EOL> plt . xlim ( [ <NUM_LIT> , <NUM_LIT> ] ) <EOL> plt . ylim ( [ - <NUM_LIT:5> , <NUM_LIT:50> ] ) <EOL> plt . xlabel ( "<STR_LIT>" ) <EOL> plt . ylabel ( "<STR_LIT>" ) <EOL> plt . legend ( ) <EOL> plt . tight_layout ( ) <EOL> plt . show ( ) </s>
