Last active
February 4, 2020 12:26
-
-
Save dsottimano/9dc98838d4e584088e8abf50b2384410 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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