Commit a2cc7e77 authored by Anze Vavpetic's avatar Anze Vavpetic

added weka `apply classifier get instances` and `get attribute values` widgets

parent 0e12851e
This diff is collapsed.
import StringIO
import arff
from services.webservice import WebService
def weka_statistics(input_dict):
summary = input_dict['summary']
class_index = int(input_dict['classIndex'])
......@@ -28,4 +33,22 @@ def weka_statistics(input_dict):
output_dict['tp_rate']=tp_rate
output_dict['fp_rate']=fp_rate
output_dict['f']=f
return output_dict
\ No newline at end of file
return output_dict
def weka_get_attr_list(input_dict):
'''
Returns attribute values for a single attribute from the dataset. Defaults to the last attribute.
E.g., useful for calculating classification statistics.
'''
arff_file = input_dict['arff_file']
attr_name = input_dict.get('attr_name', None)
attr_list = []
for row in arff.loads(arff_file):
if attr_name:
attr = getattr(row, attr_name)
else:
# Default to last row value
attr = row[len(row)-1]
attr_list.append(attr)
return {'attr_list': attr_list}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment