Created
February 26, 2016 21:05
-
-
Save sanchezg/a23c7b96ee5cde30ba18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def classify_elements(dataset, interest_key, classifications_number): | |
""" | |
This function tries to classify a set of continuous features from a | |
dataset into a | |
""" | |
keys = dataset.keys() | |
if interest_key not in keys: | |
print 'The feature is not in the dataset' | |
return | |
count_elements = len(dataset) | |
interest_values = [ | |
dataset[idx][interest_key] for idx in xrange(count_elements) | |
] | |
range_class = (max(interest_values) - min())/classifications_number | |
list_class = [] | |
for idx in xrange(classifications_number): | |
list_class = list_class + interest_values[ | |
idx*classifications_number:(idx+1)*classifications_number | |
] | |
return list_class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment