Skip to content

Commit

Permalink
Update reduce.py
Browse files Browse the repository at this point in the history
  • Loading branch information
abhi-glitchhg authored Oct 30, 2023
1 parent c506c26 commit dc2a501
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions corrfeatred/reduce.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
from networkx.algorithms import clique
import random

def reduce_features(correlation_matrix, threshhold=0.75,policy='min', random_state=None):
def reduce_features(correlation_matrix, threshhold=0.75,policy='min', random_seed=None):


# """
# correlation_matrix : df.corr
# threshhold: float
# method: whether we want minimum number of features or maximum number of features. NOTE: this is bit unstable and sometimes `min` policy has more features than `max`, this depends on how graph develops.
# random_state: random state, use this to get different set of features for same correlation matrix.
# random_seed: random state, use this to get different set of features for same correlation matrix.
# """

if random_state!=None:
random_gen = random.Random(random_state)
if random_seed!=None:
random_gen = random.Random(random_seed)
corrmatrix = correlation_matrix.abs().copy()
inf_ = 4*(corrmatrix.shape[0]) + 10 # adding 10 for no reason, this could be any positive number;
corr_matrix = corrmatrix > threshhold
Expand Down Expand Up @@ -50,7 +50,7 @@ def reduce_features(correlation_matrix, threshhold=0.75,policy='min', random_sta
node_to_clique_list[key].append(idx) # node to group mapping
while not np.all(mask):

if random_state==None:
if random_seed==None:
top = method(node_to_clique_count.items(), key = lambda kv: kv[1])
else:
dict_items = list(node_to_clique_count.items())
Expand Down

0 comments on commit dc2a501

Please sign in to comment.