Skip to content

Instantly share code, notes, and snippets.

@guyroyse
Created May 20, 2020 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guyroyse/5864706e28e30007b11a5b6d8e1eb75c to your computer and use it in GitHub Desktop.
Save guyroyse/5864706e28e30007b11a5b6d8e1eb75c to your computer and use it in GitHub Desktop.
Using RedisAI from ioredis
let redis = new Redis()
async function classinate(values) {
await redis.call(
'AI.TENSORSET', 'model:in',
'DOUBLE', '1', '10',
'VALUES', ...values)
await redis.call(
'AI.MODELRUN', 'models:gmsc:linearsvc', 'INPUTS', 'model:in',
'OUTPUTS', 'model:out:prediction', 'model:out:score')
let classification = await redis.call(
'AI.TENSORGET', 'model:out:prediction', 'VALUES')
return classification[0]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment