Example #1
0
index_not_inf = index_beta[index_beta>n_informative]
print("loss", new_loss, "beta inf", len(index_inf), ", beta non inf",len(index_beta))

real_indexes = []
iter = np.argmin(mses)
print("iter", iter)
indexes = ordered_final_weights[:iter+1].astype("int64")

if weights_all:
    weights = assign_weights(weights_data.copy())
    weights = weights[indexes]
else:
    weights = assign_weights(weights_data.copy()[indexes])

###compute weighted LASSO on val
XTrainVal, YTrainVal, XVal, YVal = results_cross_val.extract_train_val()
XTrain_Valcurrent, XVal_current = get_current_data(XTrainVal, XVal, indexes)

print("----------------------------")

model = Shooting(weights)
lasso = LASSOEstimator(model)

loss, beta = compute_weightedLASSO(lasso,XTrain_Valcurrent,YTrainVal, XVal_current, YVal,scoring, score_f, verbose, values_TM)

beta = np.abs(beta)
beta_indexes,beta_ordered = get_beta_div_zeros(beta)

##new indexes
final_indexes = indexes[beta_indexes]
print("final indexes", final_indexes)
Example #2
0
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

weights_data = results.extract_weights()
from ExtractResult import Result
from Transformation import Enel_powerCurveTransformation, EnelWindSpeedTransformation, \
    Enel_directionVersoPowerCurveTransformation, Enel_directionPowerCurveTransformation

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":