This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_,optvalues,resobj=load('hyperparam_best.joblib') | |
outparams=linkopt(['input_layer','hidden_1','navpu_infl','uni_reg','dropout_rate','hidden_reg'],optvalues) | |
acc_sigma=np.min(resobj.func_vals) #target validation error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ct = 0 | |
for _ in test_data: | |
ct += 1 | |
powcoeffs = np.arange(ct) | |
loss_base = np.full(ct,0.9) | |
loss_array = np.power(loss_base, powcoeffs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for _, test in test_data: | |
predictions = model.predict(tf.boolean_mask( | |
reshape_sample, boolmask, axis=1)) | |
y_pred.append(predictions[0][0]) | |
y_true.append(test[0][0]) | |
reshape_sample = np.roll(reshape_sample, -1, axis=1) | |
reshape_sample[0][-1] = predictions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res = gp_minimize(objective, # the function to minimize | |
space, # the bounds on each dimension of x | |
acq_func="LCB", # the acquisition function | |
n_calls=78, # the number of evaluations of f #78 | |
n_random_starts=5, # the number of random initialization points | |
random_state=0) # the random seed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
space = [Integer(2, 21, name='input_layer'), #number of neurons in input layer | |
Integer(1,3, name='hidden_1'), #number of neurons in the 1st hidden layer | |
Real(0.0, 0.3, name='navpu_infl'), #adjustment of class weighting in the mutual_unit(navpu) and the inflation. | |
Real(0.0, 0.8, name='uni_reg'), # regularization factor in the 1st hidden layer | |
Real(0.0, 0.5, name='dropout_rate'), #dropout fraction on the weights outside the 1st hidden layer | |
Real(0.0, 0.8, name='hidden_reg'), #regularization at the final layer | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
masked_indices=kwargs.pop('masked_indices',[4,6,7,9,10,11,12,14,15]) | |
boolmask=np.full(est_period,True) | |
boolmask[masked_indices]=False | |
model = tf.keras.Sequential() | |
model.add(tf.keras.layers.Dense(kwargs.pop('input_layer',7), | |
input_shape=(tf.boolean_mask(train_data[0][0],boolmask,axis=1).shape[1], | |
train_data[0][0].shape[2]), | |
kernel_initializer='he_normal', | |
kernel_regularizer=tf.keras.regularizers.l1( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def form_dataset(normalized_data, est_period, **kwargs): | |
percent_validation = kwargs.pop('percent_validation', 0.8) | |
rel_norm=normalized_data | |
# end_index=(int(((rel_norm.shape[0]-est_period)*0.9)//batch_size))*batch_size-2 | |
# batch size to be changed to 1 | |
# end_index_test=( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dfcorr = dfrel.corr() | |
heatmap(dfrel.corr()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = auto.arima(ts(data$inflation,frequency = 1),seasonal = FALSE,stepwise=FALSE, | |
approximation = TRUE, max.p = myp, max.q = myq, max.P = myp, | |
max.Q = myq, max.d = 4, max.D=4, | |
max.order=120, num.cores = 3,parallel = TRUE) | |
flength=15 | |
fcast_no_holdout <- forecast(model,flength) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dftemp = pd.read_csv('pb_forecast_f.csv', index_col=None) | |
get_outernan(dfrel.loc[:, 'inflation']) #gets the x and y values | |
dfrel.iloc[-15:, 2] = dftemp.loc[:, 'Point Forecast'].values | |
dftemp = pd.read_csv('pb_forecast_b.csv', index_col=None) | |
dfrel.iloc[:5, 2][::-1] = dftemp.loc[:, 'Point Forecast'].values | |
dfrel.iloc[:5, 2][::-1] = dftemp.loc[:, 'Point Forecast'].values | |
fill_data(dfrel) #fills the missing data through forward, backwards fill, and linear interpolation |
NewerOlder