コード例 #1
0
 def test_row_is_nan(self):
     M = np.array(
             [(0, 1,), (1, np.nan), (2, 0), (3, np.nan), (4, 1)],
             dtype=[('id', int), ('label', float)])
     arguments = [{'func': row_is_nan, 'col_name': 'label', 'vals': None}]
     res = remove_rows_where(M, arguments)
     ctrl = np.array(
         [(0, 1), (2, 0), (4, 1)],
         dtype=[('id', int), ('label', float)])
     self.assertTrue(np.array_equal(res, ctrl))
コード例 #2
0
    def test_remove_rows_where(self):
        M = [[1,2,3], [2,3,4], [3,4,5]]
        col_names = ['heigh','weight', 'age']
        lables= [0,0,1]
        M = diogenes.utils.cast_list_of_list_to_sa(
            M,
            col_names=col_names)

        arguments = [{'func': row_val_eq, 'col_name': 'heigh', 'vals': 1},
                     {'func': row_val_lt, 'col_name': 'weight', 'vals': 3},
                     {'func': row_val_between, 'col_name': 'age', 'vals': 
                      (3, 4)}]

        res = remove_rows_where(
            M, 
            arguments)

        ctrl = cast_list_of_list_to_sa([[2,3,4],[3,4,5]],col_names=['heigh','weight', 'age'])
                   
        self.assertTrue(np.array_equal(res, ctrl))
コード例 #3
0
    #new eval function
    def rounds_to_val(M, col_name, boundary):
        return (np.round(M[col_name]) == boundary)

    M = choose_rows_where(M, [{
        'func': rounds_to_val,
        'col_name': 'f0',
        'vals': 5
    }], 'new_col')

    from diogenes.modify import (fewer_then_n_nonzero_in_col,
                                 remove_rows_where, remove_cols, val_eq)
    #remove Useless row
    M = fewer_then_n_nonzero_in_col(M, 1)
    M = append_cols(M, labels, 'labels')
    M = remove_rows_where(M, val_eq, 'labels', 2)
    labels = M['labels']
    M = remove_cols(M, 'labels')

from diogenes.operate import run_std_classifiers, run_alt_classifiers  #run_alt_classifiers not working yet

exp = run_std_classifiers(M, labels)
exp.make_csv()
import pdb

pdb.set_trace()

####################Communicate#######################

#Pretend .1 is wrong so set all values of .1 in M[3] as .2
# make a new column where its a test if col,val, (3,.2), (2,1.4) is true.
コード例 #4
0
        return (np.round(M[col_name]) == boundary)
    
    M = choose_rows_where(M,
                          [{'func': rounds_to_val, 
                            'col_name': 'f0', 
                            'vals': 5}],
                            'new_col')
    
    from  diogenes.modify import (fewer_then_n_nonzero_in_col, 
                                 remove_rows_where,
                                 remove_cols,
                                 val_eq)
    #remove Useless row
    M = fewer_then_n_nonzero_in_col(M,1)
    M = append_cols(M, labels, 'labels')
    M = remove_rows_where(M, val_eq, 'labels', 2)
    labels=M['labels']
    M = remove_cols(M, 'labels')


from diogenes.operate import run_std_classifiers, run_alt_classifiers #run_alt_classifiers not working yet
exp = run_std_classifiers(M,labels)
exp.make_csv()
import pdb; pdb.set_trace()


####################Communicate#######################



#Pretend .1 is wrong so set all values of .1 in M[3] as .2