import sys

sys.argv[1:2] = [str(x) for x in sys.argv[1:2]]
output_folder = sys.argv[1]
threshold_dir = (int)(sys.argv[2])
num_blocks = (int)(sys.argv[3])
compute_mse_current = (int)(sys.argv[4])
cycles = (int)(sys.argv[5])
max_active_set = (int)(sys.argv[6])

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

XTrain, YTrain, XTest, YTest = results.extract_train_test()
enel_dict = results.extract_dict()
Coord, Coord_turb, power_curve = results.extract_coords()

angles_coord_turb, _ = compute_angle(Coord, Coord_turb)

##transformation of data
X = np.concatenate((XTrain, XTest), axis=0)
enel_transf = Enel_powerCurveTransformation()

X_angle, _, _ = enel_transf.compute_angle_matrix(X)
output_dict = dict.fromkeys(np.arange(0, 49), np.array([[]], dtype="int64"))

k_levels = np.arange(0, 12).reshape([12, 1])
for key in np.arange(0, 49):
    current_values = np.arange(key * 12, key * 12 + 12).reshape([12, 1])
    output_dict[key] = np.concatenate((current_values, k_levels), axis=1)
Ejemplo n.º 2
0
import numpy as np
from LASSOModel import Shooting, LASSOEstimator
from Lasso_utils import compute_weightedLASSO, compute_lasso
from utility import get_current_data, assign_weights, assign_weights_ordered, \
    get_beta_div_zeros, print_features_active
import sys

sys.argv[1:] = [str(x) for x in sys.argv[1:]]
file_name = sys.argv[1]

ext = ".npz"
file = "ENEL_2014/"+file_name+ext

results = Result(file, "lasso")

dict_ = results.extract_dict()

XTrain, YTrain, XVal, YVal = results.extract_train_val()

score = "mean_squared_error"
if score=="r2_score":
    score_f = r2_score
    scoring = "r2"
else:
    score_f = mean_squared_error
    scoring = "mean_squared_error"

verbose = True


###compute ranking
Ejemplo n.º 3
0
import sys

sys.argv[1:] = [str(x) for x in sys.argv[1:]]
file_name = sys.argv[1]
file_name_dict = sys.argv[2]
ext = ".npz"
file = "ENEL_2014/"+file_name+ext


file_dict = "ENEL_2014/"+file_name_dict+ext

results_dict = Result(file_dict, "lasso")
results = Result(file, "lasso")

#dict_ = results.extract_dict()
dict_ = results_dict.extract_dict()

XTrain, YTrain, XVal, YVal = results.extract_train_val()

new_loss, beta = compute_lasso(XTrain, YTrain, XVal, YVal,score = "mean_squared_error")
print("loss lineare", new_loss)

score = "mean_squared_error"
if score=="r2_score":
    score_f = r2_score
    scoring = "r2"
else:
    score_f = mean_squared_error
    scoring = "mean_squared_error"

verbose = True
Ejemplo n.º 4
0
file_cross_val =  folder+file_name+ext

results_cross_val = Result(file_cross_val, "lasso")

##get transformed data
XTrain, XTest = results_cross_val.extract_data_transf()
_,YTrain,_, YTest = results_cross_val.extract_train_test()

### centratura dei dati
XTrain, YTrain, X_mean, y_mean, X_std = center_data(XTrain, YTrain, fit_intercept=True, normalize = True)
XTest, YTest = center_test(XTest,YTest,X_mean,y_mean,X_std)


##ranking
verbose = True
dict_ = results_cross_val.extract_dict()

weights_data = results_cross_val.extract_weights()

index_mse = len(weights_data)-1
weights_data = weights_data[index_mse]

final_weights = np.zeros(len(dict_.keys()))

keys_ = np.array((list)(dict_.keys())).astype("int64")
for key in keys_:
    final_weights[key] += np.sum(weights_data[dict_.get(key).astype("int64")])

ordered_final_weights = np.argsort(final_weights)[::-1]
if verbose:
    print("-------------")
sys.argv[1:3] = [str(x) for x in sys.argv[1:]]
folder_name = sys.argv[1]
filename = sys.argv[2]
compute_dict = (int)(sys.argv[3])

tot_filename = folder_name+"/"+filename
results = Result(tot_filename, "lasso")

weights_list = results.extract_weights()
mses = results.extract_mses()
XTrain_transf, _ = results.extract_data_transf()
XTrain_, YTrain_, XVal_, YVal_ = results.extract_train_val()
saved_indexes_list = results.get_saved_indexes()
XTrain_ValNoCenter, YTrainVal_noCenter, XVal_noCenter,YVal_noCenter = results.extract_train_val_no_centered()
output_dict = results.extract_dict()

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

XTrain, YTrain, XTest, YTest = results.extract_train_test()
X_speed,_ = EnelWindSpeedTransformation().transform(XTest)
Coord, Coord_turb, power_curve = results.extract_coords()
angles_coord_turb,verso_turb_point = compute_angle(Coord, Coord_turb)
enel_transf = Enel_powerCurveTransformation()
X_angle,x_verso,_ = enel_transf.compute_angle_matrix(XTest)

if filename=="Enel_cross_val_blocks_direction_single_plus_verso.npz":

    print("trasformazione direzione verso")
    enel_transf = Enel_directionVersoPowerCurveTransformation()