Principal component regression.
$ npm install ml-pcr
const { PCR } = require('pcr');
const x = [
[0, 0],
[1, 2],
[2, 3],
[3, 4],
];
const y = [
[0, 0, 0],
[2, 4, 3],
[4, 6, 5],
[6, 8, 7],
];
const pcr = new PCR(x, y, { intercept: true, weight: 1 });
console.log(pcr.predict([3, 3])); // Predict Y for an given X
// [6, 6, 6]
console.log(pcr.getLoadingsdata()); // Returns the information of loadings used to perform the linear regression
/*
{
weigth: 99.20021500994476,
evalues: 4.546676521289134,
componentNumber: 1,
component: [ [Array] ]
},
{
weigth: 0.7997849900552465,
evalues: 0.036656812044198794,
componentNumber: 2,
component: [ [Array] ]
}
]
*/
Miller, J. N., & Miller, J. C. (2010). Statistics and Chemometrics for Analytical Chemistry.