Skip to content

Instantly share code, notes, and snippets.

@dsottimano
Last active February 4, 2020 12:26
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 dsottimano/9dc98838d4e584088e8abf50b2384410 to your computer and use it in GitHub Desktop.
Save dsottimano/9dc98838d4e584088e8abf50b2384410 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="index.js"></script>
</head>
<body>
<script>
let model = new CPT();
let data = [
['hello', 'how', 'are', 'you'],
['hello', 'how', 'are', 'your', 'studies', 'going', '?'],
['This', 'is', 'a', 'test'],
['How', 'does', 'this', 'work']
]
model.train(
data // Training Data
);
let target = [
['how', 'are']
];
let predictions = model.predict(
target, // Test input
2, // The number of last elements that will be used
// to find similar sequences, (default: target.length)
2 // The number of predictions required.
);
document.write(predictions)
console.log(predictions) // [['you'], ['your']]
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment