1.0.20 • Published 6 months ago

b3-bnn v1.0.20

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

🍌 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?"
);
1.0.19

6 months ago

1.0.18

6 months ago

1.0.17

6 months ago

1.0.16

6 months ago

1.0.20

6 months ago

1.0.14

6 months ago

1.0.13

6 months ago

1.0.12

6 months ago

1.0.11

6 months ago

1.0.10

6 months ago

1.0.8

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago