Exemplo n.º 1
0
 def test_class_weights(self):
     y = np.array([0, 1, 0, 0, 2])
     class_weights = {0: 0.5, 1: 1.0, 2: 1.5}
     weights = training_utils_v1.standardize_weights(
         y, class_weight=class_weights
     )
     self.assertAllClose(weights, np.array([0.5, 1.0, 0.5, 0.5, 1.5]))
Exemplo n.º 2
0
 def test_sample_weights_and_class_weights(self):
     y = np.array([0, 1, 0, 0, 2])
     sample_weights = np.array([0.5, 1.0, 1.0, 0.0, 2.0])
     class_weights = {0: 0.5, 1: 1.0, 2: 1.5}
     weights = training_utils_v1.standardize_weights(
         y, sample_weights, class_weights)
     expected = sample_weights * np.array([0.5, 1.0, 0.5, 0.5, 1.5])
     self.assertAllClose(weights, expected)
Exemplo n.º 3
0
 def test_sample_weights(self):
     y = np.array([0, 1, 0, 0, 2])
     sample_weights = np.array([0.5, 1.0, 1.0, 0.0, 2.0])
     weights = training_utils_v1.standardize_weights(y, sample_weights)
     self.assertAllClose(weights, sample_weights)