Пример #1
0
    def test_mean(self):
        for X in self.data:
            X_sparse = csr_matrix(X)
            np.testing.assert_array_equal(mean(X_sparse), np.mean(X))

        with self.assertWarns(UserWarning):
            mean([1, np.nan, 0])
Пример #2
0
    def test_mean(self):
        # This warning is not unexpected and it's correct
        warnings.filterwarnings("ignore", r".*mean\(\) resulted in nan.*")
        for X in self.data:
            X_sparse = csr_matrix(X)
            np.testing.assert_array_equal(mean(X_sparse), np.mean(X))

        with self.assertWarns(UserWarning):
            mean([1, np.nan, 0])
Пример #3
0
    def test_mean(self):
        for X in self.data:
            X_sparse = csr_matrix(X)
            np.testing.assert_array_equal(
                mean(X_sparse),
                np.mean(X))

        with self.assertWarns(UserWarning):
            mean([1, np.nan, 0])
Пример #4
0
    def test_mean(self):
        # This warning is not unexpected and it's correct
        warnings.filterwarnings("ignore", r".*mean\(\) resulted in nan.*")
        for X in self.data:
            X_sparse = csr_matrix(X)
            np.testing.assert_array_equal(
                mean(X_sparse),
                np.mean(X))

        with self.assertWarns(UserWarning):
            mean([1, np.nan, 0])
Пример #5
0
 def _init_feature_marker_values(self):
     self.feature_marker_values = []
     cls_index = self.target_class_index
     instances = Table(self.domain, self.instances) \
         if self.instances else None
     for i, attr in enumerate(self.domain.attributes):
         value, feature_val = 0, None
         if len(self.log_reg_coeffs):
             if attr.is_discrete:
                 ind, n = unique(self.data.X[:, i], return_counts=True)
                 feature_val = np.nan_to_num(ind[np.argmax(n)])
             else:
                 feature_val = mean(self.data.X[:, i])
         inst_in_dom = instances and attr in instances.domain
         if inst_in_dom and not np.isnan(instances[0][attr]):
             feature_val = instances[0][attr]
         if feature_val is not None:
             value = self.points[i][cls_index][int(feature_val)] \
                 if attr.is_discrete else \
                 self.log_reg_coeffs_orig[i][cls_index][0] * feature_val
         self.feature_marker_values.append(value)
Пример #6
0
 def test_mean(self):
     for X in self.data:
         X_sparse = csr_matrix(X)
         np.testing.assert_array_equal(
             mean(X_sparse),
             np.mean(X))