sample code with main js here
-
default model used is
movieReview, trained on IMDB reviews truncated to 200 words and only 20K most common words used (not good results for negative at least for my test input) -
prediction score would range from 0 to 1, ranging from extreme hint of negative to positive
-
initializing using
const sentiment = ml5.sentiment(modelName, ?callback)
- modelName: required, defaults to
movieReview; can also use path tomanifest.jsonfilecallback: optional, called when model has loaded; returns a promise resolved when model loaded
-
attributes on sentiment object are
.readyand.model -
methods on sentiment object is
.predict(text_to_predict)returns score with 0 as negative and 1 as positive