1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-12 07:16:54 +08:00
Charles Young
2021-03-08 17:49:59 +08:00
parent 81b86f8022
commit 351d598c9f
3 changed files with 34 additions and 83 deletions

View File

@@ -28,7 +28,7 @@ class TestStructuredCovEstimator(unittest.TestCase):
self.assertTrue(if_identical)
def test_nan_option_covariance(self):
# Try to estimate the covariance from a randomly generated matrix.
# Test if nan_option is correctly passed.
NUM_VARIABLE = 10
NUM_OBSERVATION = 200
EPS = 1e-6
@@ -45,6 +45,19 @@ class TestStructuredCovEstimator(unittest.TestCase):
self.assertTrue(if_identical)
def test_decompose_covariance(self):
# Test if return_decomposed_components is correctly passed.
NUM_VARIABLE = 10
NUM_OBSERVATION = 200
estimator = StructuredCovEstimator(scale_return=False, assume_centered=True, nan_option='fill')
X = np.random.rand(NUM_OBSERVATION, NUM_VARIABLE)
F, cov_b, var_u = estimator.predict(X, is_price=False, return_decomposed_components=True)
self.assertTrue(F is not None and cov_b is not None and var_u is not None)
def test_constructed_covariance(self):
# Try to estimate the covariance from a specially crafted matrix.
# There should be some significant correlation since X is specially crafted.