Check out example codes for "how to use ml5.js". It will help you in understanding the concepts better.

Code Example 1

// Step 1: Create an image classifier with MobileNet
const classifier = ml5.imageClassifier("MobileNet", onModelReady);

// Step 2: select an image
const img = document.querySelector("#myImage");

// Step 3: Make a prediction
let prediction = classifier.predict(img, gotResults);

// Step 4: Do something with the results!
function gotResults(err, results) {
  // all the amazing things you'll add

Learn ReactJs, React Native from