@@ -547,9 +547,9 @@ def get_predictor_ws(mdata, num_test_var, effective_sz):
547547 np .random .shuffle (arr )
548548
549549 ## 3. effective sample size
550- indx_W_shuffle = arr [:effective_sz ]
550+ index_W_shuffle = arr [:effective_sz ]
551551
552- W_del_shuffle_eff = Ws_del [indx_W_shuffle , :] # the sample size of W should be equal to effective sample size
552+ W_del_shuffle_eff = Ws_del [index_W_shuffle , :] # the sample size of W should be equal to effective sample size
553553 return W_del_shuffle_eff .reshape (- 1 , Ws_ncol )
554554
555555
@@ -597,11 +597,11 @@ def contain_common_neighbors_prt_mvar(X, Y, condition_set, skel, prt_m):
597597
598598 common_neighbor = (X_child == 1 ) & (Y_child == 1 )
599599 if sum (common_neighbor ) > 0 : # have at least one common neighbor
600- indx = np .array ([i for i in range (len (Y_child ))])
601- common_neighbor_indx = indx [common_neighbor ]
600+ index = np .array ([i for i in range (len (Y_child ))])
601+ common_neighbor_index = index [common_neighbor ]
602602 var = [X ] + [Y ] + list (condition_set )
603603 prt_ls = get_prt_mvars (var , prt_m )
604- if len (list (set (common_neighbor_indx ) & set (prt_ls ))):
604+ if len (list (set (common_neighbor_index ) & set (prt_ls ))):
605605 # at least one common neighbor is the parent of M
606606 return True
607607 else : # the common neighbors are not the parent of M
@@ -615,14 +615,14 @@ def get_prt_mvars(var, prt_m):
615615 :params:
616616 - var: a list or a tuple
617617 :return:
618- - W_indx_ : a list with unique elements
618+ - W_index_ : a list with unique elements
619619 """
620- W_indx_ = []
620+ W_index_ = []
621621 for vi in var :
622622 if vi in prt_m ['m' ]: # vi has a missingness indicator requiring correction
623- W_indx_ += get_prt_of_mi (vi , prt_m )
624- W_indx_ = list (np .unique (W_indx_ ))
625- return W_indx_
623+ W_index_ += get_prt_of_mi (vi , prt_m )
624+ W_index_ = list (np .unique (W_index_ ))
625+ return W_index_
626626
627627
628628def get_prt_of_mi (vi , prt_m ):
@@ -633,30 +633,30 @@ def get_prt_of_mi(vi, prt_m):
633633 return list (prti )
634634
635635
636- def get_prt_mw (W_indx_ , prt_m ):
636+ def get_prt_mw (W_index_ , prt_m ):
637637 """Iteratively get the parents of missingness indicators of W
638638 :params:
639- W_indx_ : a list with unique elements
639+ W_index_ : a list with unique elements
640640 :return:
641- W_indx : a list with unique elements
641+ W_index : a list with unique elements
642642 """
643- W_indx = W_indx_
644- prt_W = get_prt_mvars (W_indx , prt_m )
645- stop_cond = list (set (prt_W ) - set (W_indx ))
646- while len (stop_cond ) > 0 : # There are parents of W_indx
647- W_indx += prt_W
648- W_indx = list (np .unique (W_indx ))
649- prt_W = get_prt_mvars (W_indx , prt_m )
650- stop_cond = list (set (prt_W ) - set (W_indx ))
643+ W_index = W_index_
644+ prt_W = get_prt_mvars (W_index , prt_m )
645+ stop_cond = list (set (prt_W ) - set (W_index ))
646+ while len (stop_cond ) > 0 : # There are parents of W_index
647+ W_index += prt_W
648+ W_index = list (np .unique (W_index ))
649+ prt_W = get_prt_mvars (W_index , prt_m )
650+ stop_cond = list (set (prt_W ) - set (W_index ))
651651
652- # No more parents of W_indx outside of the list W_indx
653- return list (np .unique (W_indx ))
652+ # No more parents of W_index outside of the list W_index
653+ return list (np .unique (W_index ))
654654
655655
656656def test_wise_deletion (data ):
657657 """dataset after test-wise deletion"""
658- indxCompleteRows = get_indx_complete_rows (data )
659- return data [indxCompleteRows , :]
658+ indexCompleteRows = get_index_complete_rows (data )
659+ return data [indexCompleteRows , :]
660660
661661
662662def learn_regression_model (tdel_data , num_model ):
@@ -699,13 +699,13 @@ def get_sub_correlation_matrix(mvdata):
699699 matrix: the correlation matrix of all the variables
700700 sample_size: the sample size of the dataset after test-wise deletion
701701 """
702- indxRows = get_indx_complete_rows (mvdata )
703- matrix = np .corrcoef (mvdata [indxRows , :], rowvar = False )
704- sample_size = len (indxRows )
702+ indexRows = get_index_complete_rows (mvdata )
703+ matrix = np .corrcoef (mvdata [indexRows , :], rowvar = False )
704+ sample_size = len (indexRows )
705705 return matrix , sample_size
706706
707707
708- def get_indx_complete_rows (mvdata ):
708+ def get_index_complete_rows (mvdata ):
709709 """
710710 Get the index of the rows with complete records
711711 -------
@@ -718,9 +718,9 @@ def get_indx_complete_rows(mvdata):
718718 the index of the rows with complete records
719719 """
720720 nrow , ncol = np .shape (mvdata )
721- bindxRows = np .ones ((nrow ,), dtype = bool )
722- indxRows = np .array (list (range (nrow )))
721+ bindexRows = np .ones ((nrow ,), dtype = bool )
722+ indexRows = np .array (list (range (nrow )))
723723 for i in range (ncol ):
724- bindxRows = np .logical_and (bindxRows , ~ np .isnan (mvdata [:, i ]))
725- indxRows = indxRows [ bindxRows ]
726- return indxRows
724+ bindexRows = np .logical_and (bindexRows , ~ np .isnan (mvdata [:, i ]))
725+ indexRows = indexRows [ bindexRows ]
726+ return indexRows
0 commit comments