numerai-tools 0.4.2.dev1__tar.gz → 0.4.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.1
2
2
  Name: numerai_tools
3
- Version: 0.4.2.dev1
3
+ Version: 0.4.3
4
4
  Summary: A collection of open-source tools to help interact with Numerai, model data, and automate submissions.
5
5
  Home-page: https://github.com/numerai/numerai-tools
6
6
  Maintainer: Numerai
@@ -461,7 +461,7 @@ def numerai_corr(
461
461
  Returns:
462
462
  pd.Series - the resulting correlation scores for each column in predictions
463
463
  """
464
- targets = targets - targets.mean()
464
+ targets = center(targets)
465
465
  targets, predictions = filter_sort_index(
466
466
  targets, predictions, max_filtered_index_ratio
467
467
  )
@@ -557,14 +557,15 @@ def alpha(
557
557
  sample_weights: pd.Series - the universe sampling weights
558
558
  targets: pd.Series - the live targets to evaluate against
559
559
  """
560
+ targets = center(targets)
560
561
  assert not predictions.isna().any().any(), "Predictions contain NaNs"
561
562
  assert not neutralizers.isna().any().any(), "Normalization factors contain NaNs"
562
563
  assert not sample_weights.isna().any(), "Weights contain NaNs"
563
564
  predictions, neutralizers, sample_weights, targets = filter_sort_index_many(
564
565
  [predictions, neutralizers, sample_weights, targets]
565
566
  )
566
-
567
- weights = tie_kept_rank__gaussianize__pow_1_5(predictions).apply(
567
+ ranked_preds = tie_kept_rank__gaussianize__pow_1_5(predictions)
568
+ weights = ranked_preds.apply(
568
569
  lambda s_prime: generate_neutralized_weights(
569
570
  s_prime, neutralizers, sample_weights
570
571
  )
@@ -593,6 +594,7 @@ def meta_portfolio_contribution(
593
594
  sample_weights: pd.Series - the universe sampling weights
594
595
  targets: pd.Series - the live targets to evaluate against
595
596
  """
597
+ targets = center(targets)
596
598
  assert not predictions.isna().any().any(), "Predictions contain NaNs"
597
599
  assert not neutralizers.isna().any().any(), "Normalization factors contain NaNs"
598
600
  assert not sample_weights.isna().any(), "Weights contain NaNs"
@@ -611,15 +613,12 @@ def meta_portfolio_contribution(
611
613
  t = targets.values
612
614
  swp = w @ s
613
615
  swp = swp - swp.mean()
614
- swp_abs_sum = np.sum(np.abs(swp))
616
+ l1_norm = np.sum(np.abs(swp))
617
+ l1_norm_squared = np.power(l1_norm, 2)
615
618
  swp_sign = np.sign(swp)
616
- alpha_unnormalized_swp_grad = (
617
- 1
618
- / np.power(swp_abs_sum, 2)
619
- * (swp_abs_sum * t - swp_sign * np.dot(swp, t)).reshape(-1, 1)
620
- )
621
- zero_mean_jac_vec_prod = (
622
- alpha_unnormalized_swp_grad - alpha_unnormalized_swp_grad.mean()
623
- )
624
- mpc = (w.T @ zero_mean_jac_vec_prod).squeeze()
619
+ swp_alpha = np.dot(swp, t)
620
+ directional_gradient = l1_norm * t - swp_sign * swp_alpha
621
+ jacobian_vector_product = directional_gradient.reshape(-1, 1) / l1_norm_squared
622
+ centered_jacobian = jacobian_vector_product - jacobian_vector_product.mean()
623
+ mpc = (w.T @ centered_jacobian).squeeze()
625
624
  return pd.Series(mpc, index=stakes.index)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: numerai-tools
3
- Version: 0.4.2.dev1
3
+ Version: 0.4.3
4
4
  Summary: A collection of open-source tools to help interact with Numerai, model data, and automate submissions.
5
5
  Home-page: https://github.com/numerai/numerai-tools
6
6
  Maintainer: Numerai
@@ -1,7 +1,7 @@
1
1
  from setuptools import setup
2
2
  from setuptools import find_packages
3
3
 
4
- VERSION = "0.4.2.dev1"
4
+ VERSION = "0.4.3"
5
5
 
6
6
 
7
7
  def load(path):