mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2024-12-26 01:29:10 +00:00
Merge branch 'master' into master-staged
This commit is contained in:
commit
b721a2a4ce
@ -21,6 +21,7 @@
|
|||||||
},
|
},
|
||||||
"extensions": [
|
"extensions": [
|
||||||
"mhutchie.git-graph",
|
"mhutchie.git-graph",
|
||||||
|
"donjayamanne.jupyter",
|
||||||
],
|
],
|
||||||
"postCreateCommand": "pip install -r analysis-master/analysis-amd64/requirements.txt"
|
"postCreateCommand": "pip install -r analysis-master/analysis-amd64/requirements.txt"
|
||||||
}
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"string = \"3+4+5\"\n",
|
||||||
|
"re.sub(\"\\d+[+]{1}\\d+\", string, sum([int(i) for i in re.split(\"[+]{1}\", re.search(\"\\d+[+]{1}\\d+\", string).group())]))"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.7.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 4
|
||||||
|
}
|
@ -12,7 +12,7 @@ __version__ = "1.2.1.003"
|
|||||||
# changelog should be viewed using print(analysis.__changelog__)
|
# changelog should be viewed using print(analysis.__changelog__)
|
||||||
__changelog__ = """changelog:
|
__changelog__ = """changelog:
|
||||||
1.2.1.003:
|
1.2.1.003:
|
||||||
- fixed __al__
|
- fixed __all__
|
||||||
1.2.1.002:
|
1.2.1.002:
|
||||||
- renamed ArrayTest class to Array
|
- renamed ArrayTest class to Array
|
||||||
1.2.1.001:
|
1.2.1.001:
|
||||||
@ -414,7 +414,8 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
|
|
||||||
popt, pcov = scipy.optimize.curve_fit(lin, X, y)
|
popt, pcov = scipy.optimize.curve_fit(lin, X, y)
|
||||||
|
|
||||||
regressions.append((popt.flatten().tolist(), None))
|
coeffs = popt.flatten().tolist()
|
||||||
|
regressions.append(str(coeffs[0]) + "*x+" + str(coeffs[1]))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
@ -430,7 +431,8 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
|
|
||||||
popt, pcov = scipy.optimize.curve_fit(log, X, y)
|
popt, pcov = scipy.optimize.curve_fit(log, X, y)
|
||||||
|
|
||||||
regressions.append((popt.flatten().tolist(), None))
|
coeffs = popt.flatten().tolist()
|
||||||
|
regressions.append(str(coeffs[0]) + "*log(" + str(coeffs[1]) + "*(x+" + str(coeffs[2]) + "))+" + str(coeffs[3]))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
@ -446,7 +448,8 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
|
|
||||||
popt, pcov = scipy.optimize.curve_fit(exp, X, y)
|
popt, pcov = scipy.optimize.curve_fit(exp, X, y)
|
||||||
|
|
||||||
regressions.append((popt.flatten().tolist(), None))
|
coeffs = popt.flatten().tolist()
|
||||||
|
regressions.append(str(coeffs[0]) + "*e^(" + str(coeffs[1]) + "*(x+" + str(coeffs[2]) + "))+" + str(coeffs[3]))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
@ -468,10 +471,14 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
|
|
||||||
params = model.steps[1][1].intercept_.tolist()
|
params = model.steps[1][1].intercept_.tolist()
|
||||||
params = np.append(params, model.steps[1][1].coef_[0].tolist()[1::])
|
params = np.append(params, model.steps[1][1].coef_[0].tolist()[1::])
|
||||||
params.flatten()
|
params = params.flatten().tolist()
|
||||||
params = params.tolist()
|
|
||||||
|
temp = ""
|
||||||
plys.append(params)
|
counter = 0
|
||||||
|
for param in params:
|
||||||
|
temp += "(" + str(param) + "*x^" + str(counter) + ")"
|
||||||
|
counter += 1
|
||||||
|
plys.append(temp)
|
||||||
|
|
||||||
regressions.append(plys)
|
regressions.append(plys)
|
||||||
|
|
||||||
@ -485,7 +492,8 @@ def regression(inputs, outputs, args): # inputs, outputs expects N-D array
|
|||||||
|
|
||||||
popt, pcov = scipy.optimize.curve_fit(sig, X, y)
|
popt, pcov = scipy.optimize.curve_fit(sig, X, y)
|
||||||
|
|
||||||
regressions.append((popt.flatten().tolist(), None))
|
coeffs = popt.flatten().tolist()
|
||||||
|
regressions.append(str(coeffs[0]) + "*tanh(" + str(coeffs[1]) + "*(x+" + str(coeffs[2]) + "))+" + str(coeffs[3]))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
||||||
|
162
analysis-master/analysis/equation.ipynb
Normal file
162
analysis-master/analysis/equation.ipynb
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import re\n",
|
||||||
|
"from decimal import Decimal\n",
|
||||||
|
"from functools import reduce"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def add(string):\n",
|
||||||
|
" while(len(re.findall(\"[+]{1}[-]?\", string)) != 0):\n",
|
||||||
|
" string = re.sub(\"[-]?\\d+[.]?\\d*[+]{1}[-]?\\d+[.]?\\d*\", str(\"%f\" % reduce((lambda x, y: x + y), [Decimal(i) for i in re.split(\"[+]{1}\", re.search(\"[-]?\\d+[.]?\\d*[+]{1}[-]?\\d+[.]?\\d*\", string).group())])), string, 1)\n",
|
||||||
|
" return string"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 4,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def sub(string):\n",
|
||||||
|
" while(len(re.findall(\"\\d+[.]?\\d*[-]{1,2}\\d+[.]?\\d*\", string)) != 0):\n",
|
||||||
|
" g = re.search(\"\\d+[.]?\\d*[-]{1,2}\\d+[.]?\\d*\", string).group()\n",
|
||||||
|
" if(re.search(\"[-]{1,2}\", g).group() == \"-\"):\n",
|
||||||
|
" r = re.sub(\"[-]{1}\", \"+-\", g, 1)\n",
|
||||||
|
" string = re.sub(g, r, string, 1)\n",
|
||||||
|
" elif(re.search(\"[-]{1,2}\", g).group() == \"--\"):\n",
|
||||||
|
" r = re.sub(\"[-]{2}\", \"+\", g, 1)\n",
|
||||||
|
" string = re.sub(g, r, string, 1)\n",
|
||||||
|
" else:\n",
|
||||||
|
" pass\n",
|
||||||
|
" return string"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def mul(string):\n",
|
||||||
|
" while(len(re.findall(\"[*]{1}[-]?\", string)) != 0):\n",
|
||||||
|
" string = re.sub(\"[-]?\\d+[.]?\\d*[*]{1}[-]?\\d+[.]?\\d*\", str(\"%f\" % reduce((lambda x, y: x * y), [Decimal(i) for i in re.split(\"[*]{1}\", re.search(\"[-]?\\d+[.]?\\d*[*]{1}[-]?\\d+[.]?\\d*\", string).group())])), string, 1)\n",
|
||||||
|
" return string"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 6,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def div(string):\n",
|
||||||
|
" while(len(re.findall(\"[/]{1}[-]?\", string)) != 0):\n",
|
||||||
|
" string = re.sub(\"[-]?\\d+[.]?\\d*[/]{1}[-]?\\d+[.]?\\d*\", str(\"%f\" % reduce((lambda x, y: x / y), [Decimal(i) for i in re.split(\"[/]{1}\", re.search(\"[-]?\\d+[.]?\\d*[/]{1}[-]?\\d+[.]?\\d*\", string).group())])), string, 1)\n",
|
||||||
|
" return string"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 7,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def exp(string):\n",
|
||||||
|
" while(len(re.findall(\"[\\^]{1}[-]?\", string)) != 0):\n",
|
||||||
|
" string = re.sub(\"[-]?\\d+[.]?\\d*[\\^]{1}[-]?\\d+[.]?\\d*\", str(\"%f\" % reduce((lambda x, y: x ** y), [Decimal(i) for i in re.split(\"[\\^]{1}\", re.search(\"[-]?\\d+[.]?\\d*[\\^]{1}[-]?\\d+[.]?\\d*\", string).group())])), string, 1)\n",
|
||||||
|
" return string"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 12,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"def evaluate(string):\n",
|
||||||
|
" string = exp(string)\n",
|
||||||
|
" string = div(string)\n",
|
||||||
|
" string = mul(string)\n",
|
||||||
|
" string = sub(string)\n",
|
||||||
|
" print(string)\n",
|
||||||
|
" string = add(string)\n",
|
||||||
|
" return string"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 13,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "error",
|
||||||
|
"ename": "SyntaxError",
|
||||||
|
"evalue": "unexpected EOF while parsing (<ipython-input-13-f9fb4aededd9>, line 1)",
|
||||||
|
"traceback": [
|
||||||
|
"\u001b[1;36m File \u001b[1;32m\"<ipython-input-13-f9fb4aededd9>\"\u001b[1;36m, line \u001b[1;32m1\u001b[0m\n\u001b[1;33m def parentheses(string):\u001b[0m\n\u001b[1;37m ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m unexpected EOF while parsing\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"def parentheses(string):"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 22,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"name": "stdout",
|
||||||
|
"text": "-158456325028528675187087900672.000000+0.8\n"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"output_type": "execute_result",
|
||||||
|
"data": {
|
||||||
|
"text/plain": "'-158456325028528675187087900672.000000'"
|
||||||
|
},
|
||||||
|
"metadata": {},
|
||||||
|
"execution_count": 22
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"string = \"8^32*4/-2+0.8\"\n",
|
||||||
|
"evaluate(string)"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.7.6-final"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 4
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user