<commit_before>from rest_framework.serializers import ModelSerializer, JSONField
from features.models import Sample, Feature, Bin, Slice, Target


class FeatureSerializer(ModelSerializer):
    class Meta:
        model = Feature
        fields = ('name', 'relevancy', 'redundancy', 'rank', 'mean', 'variance',
                  'min', 'max')


class TargetSerializer(ModelSerializer):
    feature = FeatureSerializer(many=False)

    class Meta:
        model = Target
        fields = ('feature', )


class BinSerializer(ModelSerializer):
    class Meta:
        model = Bin
        fields = ('from_value', 'to_value', 'count')


class SampleSerializer(ModelSerializer):
    class Meta:
        model = Sample
        fields = ('value',)


class SliceSerializer(ModelSerializer):
    marginal_distribution = JSONField()
    conditional_distribution = JSONField()

    class Meta:
        model = Slice
        fields = ('from_value', 'score', 'to_value', 'marginal_distribution', 'conditional_distribution')<commit_msg>Updated feature slices request to return frequency and significance<commit_after>from rest_framework.serializers import ModelSerializer, JSONField
from features.models import Sample, Feature, Bin, Slice, Target


class FeatureSerializer(ModelSerializer):
    class Meta:
        model = Feature
        fields = ('name', 'relevancy', 'redundancy', 'rank', 'mean', 'variance',
                  'min', 'max')


class TargetSerializer(ModelSerializer):
    feature = FeatureSerializer(many=False)

    class Meta:
        model = Target
        fields = ('feature', )


class BinSerializer(ModelSerializer):
    class Meta:
        model = Bin
        fields = ('from_value', 'to_value', 'count')


class SampleSerializer(ModelSerializer):
    class Meta:
        model = Sample
        fields = ('value',)


class SliceSerializer(ModelSerializer):
    marginal_distribution = JSONField()
    conditional_distribution = JSONField()

    class Meta:
        model = Slice
        fields = ('from_value', 'deviation', 'frequency', 'significance', 'to_value', 'marginal_distribution', 'conditional_distribution')
{'fraction_non_alphanumeric': 0.1071932299012694, 'fraction_numerical': 0.0, 'mean_word_length': 3.537313432835821, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2814080', 'n_tokens_mistral': 567, 'n_tokens_neox': 540, 'n_words': 153}