Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const SimpleLinearRegression = ML.SimpleLinearRegression;
- // training data
- const x = [1,2,3]; // inputs
- const y = [2,4,6]; // outputs
- // training
- const model = new ML.SimpleLinearRegression(x, y);
- // model details
- console.log(`
- Slope: ${model.slope}
- Intercept: ${model.intercept}
- Function: ${model.toString()}
- `);
- // predicting
- for(let i=1; i < 13; i++){
- const prediction = model.predict(i);
- console.log(`2x${i} = ${prediction}`)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement