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

Addition to Mission 155 Solution #112

Open
syed0019 opened this issue Apr 23, 2020 · 0 comments
Open

Addition to Mission 155 Solution #112

syed0019 opened this issue Apr 23, 2020 · 0 comments

Comments

@syed0019
Copy link

The solution file didn't extract the optimal value for k in each model. Below is the code for the extraction of optimal k value:

import operator

two_feat_k_value = {}
three_feat_k_value = {}
four_feat_k_value = {}
five_feat_k_value = {}
six_feat_k_value = {}

dict_ = k_rmse_results.copy()

for k, v in dict_.items():
    for key,val in v.items():
        if k == '2 best features':
            two_feat_k_value[key] = val
        elif k == '3 best features':
            three_feat_k_value[key] = val
        elif k == '4 best features':
            four_feat_k_value[key] = val
        elif k == '5 best features':
            five_feat_k_value[key] = val
        else:
            six_feat_k_value[key] = val
            
print('Optimal k-values:')
print('two best features: {}'.format(min(two_feat_k_value.items(), key=operator.itemgetter(1))[1]))
print('three best features: {}'.format(min(three_feat_k_value.items(), key=operator.itemgetter(1))[1]))
print('four best features: {}'.format(min(four_feat_k_value.items(), key=operator.itemgetter(1))[1]))
print('five best features: {}'.format(min(five_feat_k_value.items(), key=operator.itemgetter(1))[1]))
print('six best features: {}'.format(min(six_feat_k_value.items(), key=operator.itemgetter(1))[1]))
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