Machine learning & User behavior
npm install framework-ai * public/css/js
* js/value.js
* views/linear.html
* app.js
### In public/js/value.js
``javascript
'use strict';
let known_y = [55000,60000,57000,60000,70000,70000,60000,55000,74000,72000,80000,65000,75000,75000,72000,80000,95000,73000,93500,88500,90000];
let known_x = [41,45,48,50,52,53,56,57,60,60,64,65,65,65,67,68,68,69,70,70,70];
let lr = linearRegression(known_y, known_x);
predict = () => {
c_x = document.getElementById("test_input").value;
c_y = lr.intercept + lr.slope * c_x;
document.getElementById("c_y").innerHTML = c_y;
console.log(c_y);
};
document.getElementById("c_b").innerHTML = lr.intercept;
document.getElementById("c_a").innerHTML = lr.slope;
predict();
`
### In views/linear.html
`html
`
### In public/css/style.css
`css
body {
font-family: Helvetica, Arial, sans-serif;
background: #333;
color: #FFF;
border-top: 5px solid #69c773;
padding: 0 1em;
margin: 0;
}
h1.linear {
text-align: center;
text-decoration: underline;
color: #00ffec;
}
``