Skip to content

Commit c3afeaa

Browse files
committed
dataset_property_new: minor bugfix and change to how results are reported
1 parent ebaeec0 commit c3afeaa

1 file changed

Lines changed: 2 additions & 14 deletions

File tree

Code-SPA/dataset_property_new.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def nonlinearity_assess(X, y, plot = True, cat = None, alpha = 0.01, difference
3232
Output:
3333
int, whether there is nonlinearity in dataset
3434
"""
35-
poly, _, _ = _feature_trans(X, degree = 2, interaction = True, trans_type = 'simple_interaction')
35+
poly, _, _ = _feature_trans(X, degree = 2, interaction = True, trans_type = 'simple_interaction', all_pos_X = np.all(X >= 0, axis = 0))
3636
Bi = poly[:, X.shape[1]:] # Just the interaction terms and not the intercept or x0, x1, ..., xN terms
3737

3838
# Nonlinearity by linear correlation, quadratic test, and maximal correlation
@@ -304,7 +304,7 @@ def dynamic_assess(x, plot = True, y = None, round_number = 0, alpha = 0.01, fre
304304
plt.savefig(f'FFT_{round_number}.png', dpi = 600, bbox_inches='tight')
305305
return (acf_lag, pacf_lag)
306306

307-
def residual_analysis(X, y, y_hat, plot = True, nlag = None, alpha = 0.01, round_number = 0, log_transform = False):
307+
def residual_analysis(X, y, y_hat, plot = True, nlag = None, alpha = 0.01, round_number = 0):
308308
"""
309309
This funcion assesses the residuals (heteroscedasticity and dyanmics)
310310
Heteroscedasticity is tested on Breusch-Pagan Test and White Test
@@ -313,25 +313,13 @@ def residual_analysis(X, y, y_hat, plot = True, nlag = None, alpha = 0.01, round
313313
Input:
314314
X: independent variables of size N x m
315315
y_hat: fitted dependent variable of size N x 1
316-
residual: residuals of size N x 1
317316
alpha: significance level for statistical tests
318317
319318
Output:
320319
figures, residual analysis
321320
(int_heteroscedasticity, int_dynamics), whether there is heteroscedasticity and dynamics
322321
"""
323-
print('=== Residual Analysis ===')
324-
if log_transform:
325-
y = np.exp(y)
326-
y_hat = np.exp(y_hat)
327-
# ytrain = np.exp(ytrain)
328-
# ytrain_hat = np.exp(ytrain_hat)
329-
330322
residual = y - y_hat
331-
RMSE = np.sqrt(np.mean((residual)**2))
332-
APE = np.mean(np.abs((residual) / y)) * 100
333-
print(f'RMSE = {RMSE}')
334-
print(f'APE = {APE}')
335323

336324
if nlag is None:
337325
if y.shape[0] < 40:

0 commit comments

Comments
 (0)