Skip to content

Instantly share code, notes, and snippets.

@sanchezg
Created February 26, 2016 21:05
Show Gist options
  • Save sanchezg/a23c7b96ee5cde30ba18 to your computer and use it in GitHub Desktop.
Save sanchezg/a23c7b96ee5cde30ba18 to your computer and use it in GitHub Desktop.
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