Created
October 28, 2022 15:31
-
-
Save WoolDoughnut310/d33f859d6b962465ae8d42d1eb6bd4ca 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
import * as tf from "@tensorflow/tfjs-node" | |
import { KMeans, setBackend } from "scikitjs" | |
setBackend(tf) | |
const train = [ | |
[1, 2], | |
[1, 4], | |
[4, 4], | |
[4, 0] | |
] | |
const kmean = new KMeans({ nClusters: 2 }) | |
kmean.fit(train) | |
const test = [ | |
[3, 2], | |
[2, 1] | |
] | |
const result = kmean.predict(test) | |
console.log(result.array()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment