Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Linear Regression Lua
--[[ Author: Ice Script Date: 10/4/20 Description: Going to use this for machine learning purposes. I will mainly be writing these in Python but just to get the feel for it I wrote it in a language I am fairly familiar with. ]] local data = { -- Age and BG Levels {25, 75}, {27, 70}, {30, 78}, {33, 90}, {40, 100}, {50, 120}, {52, 110}, {54, 106}, {60, 120} } local XSum = 0 local YSum = 0 local XYSum = 0 local XXSum = 0 local YYSum = 0 for _, v in pairs (data) do XSum = XSum + v[1] XXSum = XXSum + v[1]^2 YSum = YSum + v[2] YYSum = YYSum + v[2]^2 XYSum = XYSum + v[1]*v[2] end local div = (#data*XXSum)-(XSum^2) local a = ((YSum*XXSum)-( XSum*XYSum )) / div local b = (( #data*XYSum ) - ( XSum*YSum )) / div print(a, b, div .."\n") for x = 20, 100 do print("Age: ".. x, "BG: ".. math.floor((a + (b*x))*100 ) /100) end
run
|
edit
|
history
|
help
0
Lua properties
VERSION
RSA KEY GENERATOR (LUA)
Security keygen
VWPASSATPOLIZEI
Relative Angles
PAID HACK PuBG
Exponential from Two Points
help with lua number input
PAID HACK PuBG