A simple JavaScript package for machine learning integration, allowing you to train and use machine learning models within your applications.
npm install ml-integration
const MachineLearningIntegration = require('ml-integration');
// Create an instance of the MachineLearningIntegration class
const mlIntegration = new MachineLearningIntegration();
// Example training data
const trainingData = [
{ input: [1], output: 2 },
{ input: [2], output: 4 },
{ input: [3], output: 6 },
];
// Train the model
mlIntegration.trainModel(trainingData);
// Save the trained model to a file
mlIntegration.saveModelToFile('trained-model.json');
// Load the model from a file
mlIntegration.loadModelFromFile('trained-model.json');
// Make a prediction
const prediction = mlIntegration.predict([4]);
console.log('Prediction:', prediction);
Creates a new instance of the MachineLearningIntegration
class.
Trains the machine learning model with the provided training data.
-
trainingData
: An array of{ input, output }
pairs.
Saves the trained model to a JSON file.
-
filename
: The name of the file to save the model.
Loads a trained model from a JSON file.
-
filename
: The name of the file containing the model.
Makes a prediction using the trained model.
-
input
: The input data for making predictions.