Skip to content

Commit

Permalink
Merge pull request #250 from Ilhasoft/fix/bben-206
Browse files Browse the repository at this point in the history
Fix/bben 206
  • Loading branch information
johncordeiro committed May 28, 2019
2 parents 0553d14 + af64315 commit ae6484f
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions bothub/api/v2/evaluate/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,27 @@ class Meta:
'support'
]

precision = serializers.SerializerMethodField()
f1_score = serializers.SerializerMethodField()
accuracy = serializers.SerializerMethodField()
recall = serializers.SerializerMethodField()
support = serializers.SerializerMethodField()

def get_precision(self, obj):
return obj.precision if obj.precision else 0

def get_f1_score(self, obj):
return obj.f1_score if obj.f1_score else 0

def get_accuracy(self, obj):
return obj.accuracy if obj.accuracy else 0

def get_recall(self, obj):
return obj.recall if obj.recall else 0

def get_support(self, obj):
return obj.support if obj.support else 0


class RepositoryEvaluateResultIntentSerializer(serializers.ModelSerializer):

Expand Down Expand Up @@ -166,15 +187,15 @@ class Meta:
model = RepositoryEvaluateResult
fields = [
'id',
'version',
'created_at',
'matrix_chart',
'confidence_chart',
'log',
'intents_list',
'entities_list',
'intent_results',
'entity_results'

'entity_results',
]

log = serializers.SerializerMethodField()
Expand All @@ -185,7 +206,8 @@ class Meta:

def get_intents_list(self, obj):
return RepositoryEvaluateResultIntentSerializer(
obj.evaluate_result_intent.all(), many=True).data
obj.evaluate_result_intent.all().exclude(intent__exact=''),
many=True).data

def get_entities_list(self, obj):
return RepositoryEvaluateResultEntitySerializer(
Expand Down

0 comments on commit ae6484f

Please sign in to comment.