Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question with Trace Ratio #72

Open
crixus5678 opened this issue Jul 22, 2022 · 0 comments
Open

Question with Trace Ratio #72

crixus5678 opened this issue Jul 22, 2022 · 0 comments

Comments

@crixus5678
Copy link

crixus5678 commented Jul 22, 2022

Based on the code implemented in the calculation of trace ratio, if we set s_within and s_between to have a length of n_selected_features. Then the variables "I" and "idx" will just have a length of n_selected_features. In this case, arent we just restricting the selected features to be the first n_selected_features in fs_idx and the loop is essentially updating/optimizing nothing?

# preprocessing
fs_idx = np.argsort(np.divide(s_between, s_within), 0)[::-1]
k = np.sum(s_between[0:n_selected_features])/np.sum(s_within[0:n_selected_features])
s_within = s_within[fs_idx[0:n_selected_features]]
s_between = s_between[fs_idx[0:n_selected_features]]

# iterate util converge
count = 0
while True:
    score = np.sort(s_between-k*s_within)[::-1]
    I = np.argsort(s_between-k*s_within)[::-1]
    idx = I[0:n_selected_features]
    old_k = k
    k = np.sum(s_between[idx])/np.sum(s_within[idx])
    if verbose:
        print('obj at iter {0}: {1}'.format(count+1, k))
    count += 1
    if abs(k - old_k) < 1e-3:
        break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant