framework-ai v1.0.38
POC Framework Artificial Intelligence
Create application (Linear Regression) machine learning with framework-AI
Folder Structure
- public/css/js
- js/value.js
- views/linear.html
app.js
In public/js/value.js
'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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/png" href="../css/favicon.ico">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<meta name="viewport" content="width=device-width" />
<title>Linear Regression</title>
<link href="../css/style.css" rel="stylesheet" />
</head>
<body>
<h1 class="linear">Linear Regression Example</h1>
<div class="predict">
<div>Equation: Y = b + a*x</div>
<div>Model: Y = <span id="c_b"></span> + <span id="c_a"></span>*x</div>
<div>Input <input type="text" id="test_input" value="34"><input type="button" onclick="predict(); return false;" value="Predict"></div>
<div>Prediction for 34 mp = <span id="c_y"></span></div>
</div>
</body>
<script src="../js/value.js" type="text/javascript"></script>
</html>
In public/css/style.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;
}
Comming soon resolving puzzle
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago