Code Monkey home page Code Monkey logo

max-toxic-comment-classifier's Issues

Simplify /model/predict results data structure

Is it possible to simplify the result data structure?

For example

{
  "text": [
    "Mary had a little lamb"
  ]
}

returns

{
  "status": "ok",
  "predictions": [
    [
      {
        "toxic": 0.0014839612413197756,
        "severe_toxic": 0.00009525173663860187,
        "obscene": 0.0003549971734173596,
        "threat": 0.00007228714093798772,
        "insult": 0.00022114443709142506,
        "identity_hate": 0.00010927908442681655
      }
    ]
  ]
}

Note that the prediction returns a list of lists of dicts, whereas it should be sufficient to return a list of dicts.

{
  "status": "ok",
  "predictions": [
      {
        "toxic": 0.0014839612413197756,
        "severe_toxic": 0.00009525173663860187,
        "obscene": 0.0003549971734173596,
        "threat": 0.00007228714093798772,
        "insult": 0.00022114443709142506,
        "identity_hate": 0.00010927908442681655
      }
   ]
}

Not sure which input would return a multi-dimensional response. The simplified version can accommodate multiple inputs:

{
  "text": [
    "Mary had a little lamb",
    "Little lamb, little lamb,"
  ]
}

would return

{
  "status": "ok",
  "predictions": [
      {
        "toxic": 0.0014839619398117065,
        "severe_toxic": 0.0000952516493271105,
        "obscene": 0.00035499755176715553,
        "threat": 0.00007228707545436919,
        "insult": 0.00022114443709142506,
        "identity_hate": 0.00010927919356618077
      },
      {
        "toxic": 0.1212717592716217,
        "severe_toxic": 0.00012042735033901408,
        "obscene": 0.0017211131053045392,
        "threat": 0.00017663949984125793,
        "insult": 0.0008766597020439804,
        "identity_hate": 0.00014419591752812266
      }
  ]
}

with predictions[0] returning the eval for the first string, .... second string.

What am I missing?

/model/predict returns unexpected result

No big deal, but

{
 "text": [""]
}

it's odd that nothing can be interpreted as something

     {
        "toxic": 0.0015665121609345078,
        "severe_toxic": 0.00011611604713834822,
        "obscene": 0.0004790136299561709,
        "threat": 0.00007217624806798995,
        "insult": 0.0003883792378474027,
        "identity_hate": 0.0003294776252005249
      }

and similarly a meaningless combination of characters

{
 "text": ["khdcuc4wcc5jlcnw"]
}

and numbers

{
 "text": ["123"]
}

Note sure if there's something that can be done to eliminate noise that's a result of garbage input.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.