Esempio n. 1
0
 def parse(self):
     array_bool_inliers = iforest(self.X,
                                  num_estimators=100,
                                  random_state=1102,
                                  contamination=0.05)
     self.X = self.X[array_bool_inliers, :]
     self.y = self.y[array_bool_inliers]
Esempio n. 2
0
    def test_iforest(self):

        X = np.array([[1, 1], [1.1, 1], [1, 1.1], [1.1, 1.1], [100, 100]])
        array_out = iforest(X, num_estimators=10, random_state=1102)

        self.assertTrue(not array_out[4])
        self.assertTrue(array_out[0])
        self.assertTrue(array_out[1])
        self.assertTrue(array_out[2])
        self.assertTrue(array_out[3])

        X = np.array([[1, 1], [1.1, 1], [1, 1.1], [1.1, 1.1], [100, 100],
                      [100.1, 100], [100, 100.1], [100.1, 100.1], [50, 50]])
        array_out = iforest(X=X,
                            num_estimators=100,
                            random_state=1102,
                            contamination=0.05)

        self.assertEqual(sum(array_out), 8)
        self.assertTrue(not array_out[8])
Esempio n. 3
0
    def parse(self):
        
        # SEX
        self.X[:, 1] = self.X[:, 1] - 1
        # EDUCATION
        self.X = np.hstack((self.X, get_dummies(self.X[:, 2])))
        self.X = np.delete(self.X,[2], 1)
        #MARRIAGE
        self.X = np.hstack((self.X, get_dummies(self.X[:, 2])))
        self.X = np.delete(self.X,[2], 1)

        array_bool_inliers = iforest(
            self.X, 
            num_estimators=100, 
            random_state=1102, 
            contamination=0.05
        )
        self.X = self.X[array_bool_inliers, :]
        self.y = self.y[array_bool_inliers]