Home
Name Modified Size InfoDownloads / Week
Readme.txt 2019-10-29 944 Bytes
223PressureVelocity.txt 2019-10-29 336 Bytes
linearRegressionXY.py 2019-10-29 7.0 kB
Totals: 3 Items   8.3 kB 0
#!/usr/bin/python
#
# Regression Line function, with cubic spline enhancment.
# rY = M*x + b (M = slope b = y intercept)
#
# b  = avg(y) - avg(x)*M
#
# M  = ((avg(x)*avg(y)) - avg(x*y)) / (sqr(avg(x)) - avg(sqr(x)))
#
# R2 = 1 - sum((y-rY)**2) / sum(((y-avgOfY)**2))
#
# Usage: python linearRegression.py -d [n] -i [in file] -o [out file]
#
# -d Number of lines in output file (predicted values).
#
# Notes: -o optional, without -o the results print to stdout.
#        In file is known values (training data).
#        In file format key,value pair ex. 43700,3100
#        Put file is predicted values.
#
# Example: 
# (base) C:python linearRegressionXY.py -d 100 -i 223PressureVelocity.txt -o 223PV.txt
#
# (base) C:python linearRegressionXY.py -d 100 -i 223PressureVelocity.txt
#    Enter input X value: 53700
#  Predicted L/R Y Value: 2962.069
#              R Squared: 0.960
#     Standard Deviation: 97.460
#
Source: Readme.txt, updated 2019-10-29