mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-11-10 06:54:44 +00:00
analysis.py v 1.1.13.001
analysis pkg v 1.0.0.006
This commit is contained in:
parent
b669e55283
commit
a0e1293361
@ -1,6 +1,6 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: analysis
|
||||
Version: 1.0.0.5
|
||||
Version: 1.0.0.6
|
||||
Summary: analysis package developed by Titan Scouting for The Red Alliance
|
||||
Home-page: https://github.com/titanscout2022/tr2022-strategy
|
||||
Author: The Titan Scouting Team
|
||||
|
Binary file not shown.
@ -7,10 +7,14 @@
|
||||
# current benchmark of optimization: 1.33 times faster
|
||||
# setup:
|
||||
|
||||
__version__ = "1.1.13.000"
|
||||
__version__ = "1.1.13.001"
|
||||
|
||||
# changelog should be viewed using print(analysis.__changelog__)
|
||||
__changelog__ = """changelog:
|
||||
1.1.13.001:
|
||||
- bug fix with linear regression not returning a proper value
|
||||
- cleaned up regression
|
||||
- fixed bug with polynomial regressions
|
||||
1.1.13.000:
|
||||
- fixed all regressions to now properly work
|
||||
1.1.12.006:
|
||||
@ -343,28 +347,27 @@ def histo_analysis(hist_data):
|
||||
|
||||
return None
|
||||
|
||||
def regression(ndevice, inputs, outputs, args, loss = torch.nn.MSELoss(), _iterations = 10000, lr = 0.01, _iterations_ply = 10000, lr_ply = 0.01): # inputs, outputs expects N-D array
|
||||
def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
||||
|
||||
regressions = []
|
||||
Regression().set_device(ndevice)
|
||||
|
||||
if 'lin' in args: # formula: ax + b
|
||||
|
||||
try:
|
||||
|
||||
X = np.array(inputs).reshape(-1,1)
|
||||
X = np.array(inputs)
|
||||
y = np.array(outputs)
|
||||
|
||||
model = sklearn.linear_model.LinearRegression().fit(X, y)
|
||||
def func(x, a, b):
|
||||
|
||||
ret = model.coef_.flatten().tolist()
|
||||
ret.append(model.intercept_)
|
||||
return a * x + b
|
||||
|
||||
regressions.append((ret, model.score(X,y)))
|
||||
popt, pcov = scipy.optimize.curve_fit(func, X, y)
|
||||
|
||||
regressions.append((popt.flatten().tolist(), None))
|
||||
|
||||
except Exception as e:
|
||||
|
||||
print(e)
|
||||
pass
|
||||
|
||||
if 'log' in args: # formula: a log (b(x + c)) + d
|
||||
@ -384,7 +387,6 @@ def regression(ndevice, inputs, outputs, args, loss = torch.nn.MSELoss(), _itera
|
||||
|
||||
except Exception as e:
|
||||
|
||||
print(e)
|
||||
pass
|
||||
|
||||
if 'exp' in args: # formula: a e ^ (b(x + c)) + d
|
||||
@ -404,11 +406,13 @@ def regression(ndevice, inputs, outputs, args, loss = torch.nn.MSELoss(), _itera
|
||||
|
||||
except Exception as e:
|
||||
|
||||
print(e)
|
||||
pass
|
||||
|
||||
if 'ply' in args: # formula: a + bx^1 + cx^2 + dx^3 + ...
|
||||
|
||||
inputs = [inputs]
|
||||
outputs = [outputs]
|
||||
|
||||
plys = []
|
||||
limit = len(outputs[0])
|
||||
|
||||
@ -444,7 +448,6 @@ def regression(ndevice, inputs, outputs, args, loss = torch.nn.MSELoss(), _itera
|
||||
|
||||
except Exception as e:
|
||||
|
||||
print(e)
|
||||
pass
|
||||
|
||||
return regressions
|
||||
|
@ -7,10 +7,14 @@
|
||||
# current benchmark of optimization: 1.33 times faster
|
||||
# setup:
|
||||
|
||||
__version__ = "1.1.13.000"
|
||||
__version__ = "1.1.13.001"
|
||||
|
||||
# changelog should be viewed using print(analysis.__changelog__)
|
||||
__changelog__ = """changelog:
|
||||
1.1.13.001:
|
||||
- bug fix with linear regression not returning a proper value
|
||||
- cleaned up regression
|
||||
- fixed bug with polynomial regressions
|
||||
1.1.13.000:
|
||||
- fixed all regressions to now properly work
|
||||
1.1.12.006:
|
||||
@ -343,28 +347,27 @@ def histo_analysis(hist_data):
|
||||
|
||||
return None
|
||||
|
||||
def regression(ndevice, inputs, outputs, args, loss = torch.nn.MSELoss(), _iterations = 10000, lr = 0.01, _iterations_ply = 10000, lr_ply = 0.01): # inputs, outputs expects N-D array
|
||||
def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
||||
|
||||
regressions = []
|
||||
Regression().set_device(ndevice)
|
||||
|
||||
if 'lin' in args: # formula: ax + b
|
||||
|
||||
try:
|
||||
|
||||
X = np.array(inputs).reshape(-1,1)
|
||||
X = np.array(inputs)
|
||||
y = np.array(outputs)
|
||||
|
||||
model = sklearn.linear_model.LinearRegression().fit(X, y)
|
||||
def func(x, a, b):
|
||||
|
||||
ret = model.coef_.flatten().tolist()
|
||||
ret.append(model.intercept_)
|
||||
return a * x + b
|
||||
|
||||
regressions.append((ret, model.score(X,y)))
|
||||
popt, pcov = scipy.optimize.curve_fit(func, X, y)
|
||||
|
||||
regressions.append((popt.flatten().tolist(), None))
|
||||
|
||||
except Exception as e:
|
||||
|
||||
print(e)
|
||||
pass
|
||||
|
||||
if 'log' in args: # formula: a log (b(x + c)) + d
|
||||
@ -384,7 +387,6 @@ def regression(ndevice, inputs, outputs, args, loss = torch.nn.MSELoss(), _itera
|
||||
|
||||
except Exception as e:
|
||||
|
||||
print(e)
|
||||
pass
|
||||
|
||||
if 'exp' in args: # formula: a e ^ (b(x + c)) + d
|
||||
@ -404,11 +406,13 @@ def regression(ndevice, inputs, outputs, args, loss = torch.nn.MSELoss(), _itera
|
||||
|
||||
except Exception as e:
|
||||
|
||||
print(e)
|
||||
pass
|
||||
|
||||
if 'ply' in args: # formula: a + bx^1 + cx^2 + dx^3 + ...
|
||||
|
||||
inputs = [inputs]
|
||||
outputs = [outputs]
|
||||
|
||||
plys = []
|
||||
limit = len(outputs[0])
|
||||
|
||||
@ -444,7 +448,6 @@ def regression(ndevice, inputs, outputs, args, loss = torch.nn.MSELoss(), _itera
|
||||
|
||||
except Exception as e:
|
||||
|
||||
print(e)
|
||||
pass
|
||||
|
||||
return regressions
|
||||
|
BIN
analysis-master/dist/analysis-1.0.0.5.tar.gz
vendored
BIN
analysis-master/dist/analysis-1.0.0.5.tar.gz
vendored
Binary file not shown.
Binary file not shown.
BIN
analysis-master/dist/analysis-1.0.0.6.tar.gz
vendored
Normal file
BIN
analysis-master/dist/analysis-1.0.0.6.tar.gz
vendored
Normal file
Binary file not shown.
@ -2,7 +2,7 @@ import setuptools
|
||||
|
||||
setuptools.setup(
|
||||
name="analysis", # Replace with your own username
|
||||
version="1.0.0.005",
|
||||
version="1.0.0.006",
|
||||
author="The Titan Scouting Team",
|
||||
author_email="titanscout2022@gmail.com",
|
||||
description="analysis package developed by Titan Scouting for The Red Alliance",
|
||||
|
@ -70,8 +70,10 @@ __all__ = [
|
||||
from analysis import analysis as an
|
||||
import data as d
|
||||
import time
|
||||
import warnings
|
||||
|
||||
def main():
|
||||
warnings.filterwarnings("ignore")
|
||||
while(True):
|
||||
|
||||
current_time = time.time()
|
||||
@ -152,19 +154,19 @@ def simplestats(data, test):
|
||||
return an.histo_analysis([list(range(len(data))), data])
|
||||
|
||||
if(test == "regression_linear"):
|
||||
return an.regression('cpu', [list(range(len(data)))], [data], ['lin'], _iterations = 5000)
|
||||
return an.regression(list(range(len(data))), data, ['lin'])
|
||||
|
||||
if(test == "regression_logarithmic"):
|
||||
return an.regression('cpu', [list(range(len(data)))], [data], ['log'], _iterations = 5000)
|
||||
return an.regression(list(range(len(data))), data, ['log'])
|
||||
|
||||
if(test == "regression_exponential"):
|
||||
return an.regression('cpu', [list(range(len(data)))], [data], ['exp'], _iterations = 5000)
|
||||
return an.regression(list(range(len(data))), data, ['exp'])
|
||||
|
||||
if(test == "regression_polynomial"):
|
||||
return an.regression('cpu', [list(range(len(data)))], [data], ['ply'], _iterations = 5000)
|
||||
return an.regression(list(range(len(data))), data, ['ply'])
|
||||
|
||||
if(test == "regression_sigmoidal"):
|
||||
return an.regression('cpu', [list(range(len(data)))], [data], ['sig'], _iterations = 5000)
|
||||
return an.regression(list(range(len(data))), data, ['sig'])
|
||||
|
||||
def push_to_database(apikey, competition, results, metrics):
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user