Ejemplo n.º 1
0
from ExtractResult import Result
from Fit import Linear_fit
from Transformation import EnelWindSpeedTransformation
import numpy as np

file_coord = np.load("ENEL_2014/Coord.npz")
Coord = file_coord["Coord"]
Coord_turb = file_coord["Coord_turb"]
power_curve = file_coord["power_curve"]

file = "ENEL_2014/Enel_dataset.npz"
results = Result(file, "lasso")

XTrain, YTrain, XTest, YTest = results.extract_train_test()
enel_transf = EnelWindSpeedTransformation()
XTrain, dict_ = enel_transf.transform(XTrain)
XTest, dict_ = EnelWindSpeedTransformation().transform(XTest)

for k in range(5,10):
    print(k, "vicini")
    turbine_dict = find_nearest_turbine(Coord,Coord_turb,k)

    XTrain_, output_dict = enel_transf.nearest_mean_turbine(turbine_dict,dict_,XTrain, power_curve)
    print(XTrain_.shape)

    XTest_, _ = enel_transf.nearest_mean_turbine(turbine_dict,dict_,XTest,power_curve)
    print(XTest_.shape)

    Linear_fit().fitting(XTrain_, YTrain, XTest_,YTest)

    #Power_fit().fitting(XTrain, YTrain, XTest,YTest)
from utility import generate_samples_dynamic_set, get_current_data, compute_mse, get_common_indexes, \
    extract_chosen_indexes_from_start, center_test, find_nearest
import sys

file = "ENEL_2014/Enel_dataset.npz"
results = Result(file, "lasso")

sys.argv[1:] = [int(x) for x in sys.argv[1:]]
k = sys.argv[1]

XTrain, YTrain, XTest, YTest = results.extract_train_test()

##transformation of data
transf = EnelWindSpeedTransformation()

XTrain_transf, dict_ = transf.transform(XTrain)
XTest_transf, dict_ = transf.transform(XTest)

Coord = np.load("ENEL_2014/Coord.npz")["Coord"]

neight_= find_nearest(Coord,k)


XTrain_transf = transf.nearest_products_levels(neight_,dict_,XTrain)
XTest_transf = transf.nearest_products_levels(neight_,dict_,XTest)

##center data
XTrain_noCenter, XVal_noCenter, YTrain_noCenter, YVal_noCenter = train_test_split(XTrain_transf, YTrain, test_size=0.33,random_state=0)
XTrain_, YTrain_, X_mean, y_mean, X_std = center_data(XTrain_noCenter, YTrain_noCenter, fit_intercept=True, normalize = True)
XVal_, YVal_ = center_test(XVal_noCenter,YVal_noCenter,X_mean,y_mean,X_std)