dquant 1.2.2__tar.gz → 1.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dquant
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: DQuant is an open-source Python library for automated volatility forecasting of financial time series. It handles all stages of model construction, from raw prices to the final forecast.
5
5
  Author: Denis Makarov
6
6
  Project-URL: Homepage, https://dquant.space
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dquant"
7
- version = "1.2.2"
7
+ version = "1.2.3"
8
8
  authors = [
9
9
  { name="Denis Makarov" },
10
10
  ]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dquant
3
- Version: 1.2.2
3
+ Version: 1.2.3
4
4
  Summary: DQuant is an open-source Python library for automated volatility forecasting of financial time series. It handles all stages of model construction, from raw prices to the final forecast.
5
5
  Author: Denis Makarov
6
6
  Project-URL: Homepage, https://dquant.space
@@ -2,7 +2,7 @@ import numpy as np
2
2
 
3
3
 
4
4
  def qlike_score(y_true, y_pred):
5
- sigma2_true = y_true ** 2
5
+ sigma2_true = y_true
6
6
  sigma2_pred = np.maximum(y_pred, 1e-10)
7
7
  return np.mean(np.log(sigma2_pred) + sigma2_true / sigma2_pred)
8
8
 
@@ -605,6 +605,7 @@ class FichEn:
605
605
  valid_mask = ~pd.isna(y_h) if hasattr(y_h, 'isna') else ~np.isnan(y_h)
606
606
  X_h = X_scaled[valid_mask]
607
607
  y_h_clean = y_h[valid_mask]
608
+ y_h_clean_orig = self.scaler_y.inverse_transform(y_h_clean.reshape(-1, 1)).ravel()
608
609
 
609
610
  if i != 1:
610
611
  self.models[h_idx].set_params(n_estimators=i)
@@ -620,24 +621,33 @@ class FichEn:
620
621
  valid_mask = ~pd.isna(y_h_v) if hasattr(y_h_v, 'isna') else ~np.isnan(y_h_v)
621
622
  X_h_v = X_test_scaled[valid_mask]
622
623
  y_h_v_clean = y_h_v[valid_mask]
624
+ y_h_v_clean_orig = self.scaler_y.inverse_transform(y_h_v_clean.reshape(-1, 1)).ravel()
623
625
  if i != 1:
624
- t_error += mean_squared_error(y_h_clean, self.models[h_idx].predict(X_h))
625
- v_error += mean_squared_error(y_h_v_clean, self.models[h_idx].predict(X_h_v))
626
- t_mae += mean_absolute_error(y_h_clean, self.models[h_idx].predict(X_h))
627
- v_mae += mean_absolute_error(y_h_v_clean, self.models[h_idx].predict(X_h_v))
628
- t_qlike += qlike_score(y_h_clean, self.models[h_idx].predict(X_h))
629
- v_qlike += qlike_score(y_h_v_clean, self.models[h_idx].predict(X_h_v))
630
- t_r2 += r2_score(y_h_clean, self.models[h_idx].predict(X_h))
631
- v_r2 += r2_score(y_h_v_clean, self.models[h_idx].predict(X_h_v))
626
+ pred_train = self.models[h_idx].predict(X_h)
627
+ pred_val = self.models[h_idx].predict(X_h_v)
628
+ pred_train_orig = self.scaler_y.inverse_transform(pred_train.reshape(-1, 1)).ravel()
629
+ pred_val_orig = self.scaler_y.inverse_transform(pred_val.reshape(-1, 1)).ravel()
630
+ t_error += mean_squared_error(y_h_clean, pred_train)
631
+ v_error += mean_squared_error(y_h_v_clean, pred_val)
632
+ t_mae += mean_absolute_error(y_h_clean, pred_train)
633
+ v_mae += mean_absolute_error(y_h_v_clean, pred_val)
634
+ t_qlike += qlike_score(y_h_clean_orig, pred_train_orig)
635
+ v_qlike += qlike_score(y_h_v_clean_orig, pred_val_orig)
636
+ t_r2 += r2_score(y_h_clean, pred_train)
637
+ v_r2 += r2_score(y_h_v_clean, pred_val)
632
638
  else:
633
- t_error += mean_squared_error(y_h_clean, model.predict(X_h))
634
- v_error += mean_squared_error(y_h_v_clean, model.predict(X_h_v))
635
- t_mae += mean_absolute_error(y_h_clean, model.predict(X_h))
636
- v_mae += mean_absolute_error(y_h_v_clean, model.predict(X_h_v))
637
- t_qlike += qlike_score(y_h_clean, model.predict(X_h))
638
- v_qlike += qlike_score(y_h_v_clean, model.predict(X_h_v))
639
- t_r2 += r2_score(y_h_clean, model.predict(X_h))
640
- v_r2 += r2_score(y_h_v_clean, model.predict(X_h_v))
639
+ pred_train = model.predict(X_h)
640
+ pred_val = model.predict(X_h_v)
641
+ pred_train_orig = self.scaler_y.inverse_transform(pred_train.reshape(-1, 1)).ravel()
642
+ pred_val_orig = self.scaler_y.inverse_transform(pred_val.reshape(-1, 1)).ravel()
643
+ t_error += mean_squared_error(y_h_clean, pred_train)
644
+ v_error += mean_squared_error(y_h_v_clean, pred_val)
645
+ t_mae += mean_absolute_error(y_h_clean, pred_train)
646
+ v_mae += mean_absolute_error(y_h_v_clean, pred_val)
647
+ t_qlike += qlike_score(y_h_clean_orig, pred_train_orig)
648
+ v_qlike += qlike_score(y_h_v_clean_orig, pred_val_orig)
649
+ t_r2 += r2_score(y_h_clean, pred_train)
650
+ v_r2 += r2_score(y_h_v_clean, pred_val)
641
651
 
642
652
 
643
653
  var_test_error = float(t_error)/horizon
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes