b3-bnn
TypeScript icon, indicating that this package has built-in type declarations

1.0.20 • Public • Published

🍌 Naive Bayes classifier

npm i b3-bnn

Initialization and configuration

import BNN from "b3-bnn";

// Classifier instance
const bayes = BNN();

// Add layer (classifier)
const sLayer = bayes.addLayer("thread-length");

// Set normalizer for input string
sLayer.setNormalizer((phrase) => {
  // Remove standard spaces
  return phrase.replace(/((DIN)|(GOST))\s*(\d+)/gm, "$1:$2");
});

Learning

await sLayer.learn(
  "The bolt GOST 7798 with dimensions of 6x20 has a thread length",
  "fully"
);
await sLayer.learn(
  "The bolt GOST 7798 with dimensions of 6x80 has a thread length",
  "partly"
);

await sLayer.learn(
  "The bolt DIN 933 with dimensions of 6x20 has a thread length",
  "fully"
);
await sLayer.learn(
  "The bolt DIN 933 with dimensions of 6x80 has a thread length",
  "fully"
);

await sLayer.learn(
  "The bolt DIN 931 with dimensions of 6x20 has a thread length",
  "partly"
);
await sLayer.learn(
  "The bolt DIN 931 with dimensions of 6x80 has a thread length",
  "partly"
);

Promt

const answers = await sLayer.classify(
  "What is the thread length of the DIN 933 bolt with dimensions 6x80?"
);

Dependencies (0)

    Dev Dependencies (17)

    Package Sidebar

    Install

    npm i b3-bnn

    Weekly Downloads

    4

    Version

    1.0.20

    License

    ISC

    Unpacked Size

    33.9 kB

    Total Files

    16

    Last publish

    Collaborators

    • orxtime