Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Prediction jmp model to python stand alone script
"""
=====================================================
Data Prediction Fucntion
=====================================================
Author : Esmaeil Hadavandi <es.hadavandi@gmail.com>
Python : Benyamin Salimi <benyamin.salimi@gmail.com>
input : input.xlsx
output: output.xlsx
"""
from __future__ import division
from pandas import read_excel,ExcelWriter
from numpy import arcsinh,log,tanh
# Load data From excel file
data = read_excel('input.xlsx', sheet_name='Sheet1')
#Prediction Function
def score(indata):
# H1_1
# H1_2
# H1_3
# H1_4
# H1_5
_temp_0 = -0.101422177570886
_temp_1 = -16.0606452034202
_temp_2 = 3.94149280703208
_temp_3 = 43.8809952420328
_temp_4 = 10.7978097553746
_temp_5 = 0.673047312902676
_temp_0 += -19.8821221285066 * indata[u"De"].as_matrix()
_temp_0 += -3.68863601327633 * indata[u"Dt"].as_matrix()
_temp_0 += -1.14088570769108 * indata[u"Fs"].as_matrix()
_temp_0 += -0.225065698850502 * indata[u"I"].as_matrix()
_temp_0 += -1.24807493627343 * arcsinh((-8.82724940025682 + 1.11034437371763 * indata[u"Ls"].as_matrix()))
_temp_0 += 0.132787214556369 * arcsinh((-2.47261924507061 + 0.00123054887081347 * indata[u"G"].as_matrix()))
_temp_0 += 0.102066093610326 * arcsinh((-2.47261924507061 + 0.00123054887081347 * indata[u"تناژ ذوب"].as_matrix()))
_temp_0 += 1.30836293669312 * arcsinh((-2.22874994809614 + 0.000999222971144473 * indata[u"DRI [Ton]"].as_matrix()))
_temp_0 += -0.440337405451095 * arcsinh((-2.17071397432173 + 0.182551658052196 * indata[u"ts"].as_matrix()))
_temp_0 += -0.650854515459092 * arcsinh(
(-1.99771674986444 + 0.0000017889970646863 * indata[u"Energy [KWh]"].as_matrix()))
_temp_0 += 0.265462968642365 * arcsinh(
(-1.70343865820836 + 0.00199176948504182 * indata[u"T.T.T[min]"].as_matrix()))
_temp_0 += 1.80804216573321 * arcsinh(
(-0.685243045984855 + 0.0000256301967602438 * indata[u"Dolo [kg]"].as_matrix()))
_temp_0 += -0.883025354949591 * arcsinh(
(-0.387759249366533 + 0.0000117450296274744 * indata[u"O2 inject [Nm3]"].as_matrix()))
_temp_0 += 1.18256434356171 * arcsinh((-0.231830329654435 + 0.624713233432101 * indata[u"Tn"].as_matrix()))
_temp_0 += 2.85481055364048 * arcsinh((41489.585694087 + 485.11873547859 * indata[u"Scrap (Ton)"].as_matrix()))
_temp_0 += 1.98926703385514 * log(
((-11812.5020191945 + indata[u"Lime [Kg]"].as_matrix()) / (234738.266306768 + -1 * indata[u"Lime [Kg]"].as_matrix())))
H1_1 = tanh(_temp_0)
_temp_1 += 8.32288721609759 * indata[u"De"].as_matrix()
_temp_1 += 7.10306648147959 * indata[u"Dt"].as_matrix()
_temp_1 += 0.489256382804671 * indata[u"Fs"].as_matrix()
_temp_1 += 0.443660875974952 * indata[u"I"].as_matrix()
_temp_1 += -0.553900894019696 * arcsinh((-8.82724940025682 + 1.11034437371763 * indata[u"Ls"].as_matrix()))
_temp_1 += -0.693155537923237 * arcsinh((-2.47261924507061 + 0.00123054887081347 * indata[u"G"].as_matrix()))
_temp_1 += 0.135192504823986 * arcsinh((-2.47261924507061 + 0.00123054887081347 * indata[u"تناژ ذوب"].as_matrix()))
_temp_1 += 1.22374944702403 * arcsinh((-2.22874994809614 + 0.000999222971144473 * indata[u"DRI [Ton]"].as_matrix()))
_temp_1 += 0.987480198805115 * arcsinh((-2.17071397432173 + 0.182551658052196 * indata[u"ts"].as_matrix()))
_temp_1 += 0.749228629761454 * arcsinh(
(-1.99771674986444 + 0.0000017889970646863 * indata[u"Energy [KWh]"].as_matrix()))
_temp_1 += -0.312400792263449 * arcsinh(
(-1.70343865820836 + 0.00199176948504182 * indata[u"T.T.T[min]"].as_matrix()))
_temp_1 += 1.88430818100618 * arcsinh(
(-0.685243045984855 + 0.0000256301967602438 * indata[u"Dolo [kg]"].as_matrix()))
_temp_1 += 2.43995541076705 * arcsinh(
(-0.387759249366533 + 0.0000117450296274744 * indata[u"O2 inject [Nm3]"].as_matrix()))
_temp_1 += 1.33187069051929 * arcsinh((-0.231830329654435 + 0.624713233432101 * indata[u"Tn"].as_matrix()))
_temp_1 += -2.78085422011678 * arcsinh((41489.585694087 + 485.11873547859 * indata[u"Scrap (Ton)"].as_matrix()))
_temp_1 += 0.974448713241648 * log(
((-11812.5020191945 + indata[u"Lime [Kg]"].as_matrix()) / (234738.266306768 + -1 * indata[u"Lime [Kg]"].as_matrix())))
H1_2 = tanh(_temp_1)
_temp_2 += -4.3796307889583 * indata[u"De"].as_matrix()
_temp_2 += -18.1336908053974 * indata[u"Dt"].as_matrix()
_temp_2 += 0.231985207010941 * indata[u"Fs"].as_matrix()
_temp_2 += -0.0632953451792861 * indata[u"I"].as_matrix()
_temp_2 += -0.625126940833151 * arcsinh((-8.82724940025682 + 1.11034437371763 * indata[u"Ls"].as_matrix()))
_temp_2 += 0.591197597610626 * arcsinh((-2.47261924507061 + 0.00123054887081347 * indata[u"G"].as_matrix()))
_temp_2 += -0.7994852117817 * arcsinh((-2.47261924507061 + 0.00123054887081347 * indata[u"تناژ ذوب"].as_matrix()))
_temp_2 += 1.55038438390311 * arcsinh((-2.22874994809614 + 0.000999222971144473 * indata[u"DRI [Ton]"].as_matrix()))
_temp_2 += 0.929313752235579 * arcsinh((-2.17071397432173 + 0.182551658052196 * indata[u"ts"].as_matrix()))
_temp_2 += -0.351695691065738 * arcsinh(
(-1.99771674986444 + 0.0000017889970646863 * indata[u"Energy [KWh]"].as_matrix()))
_temp_2 += -1.58293179269078 * arcsinh(
(-1.70343865820836 + 0.00199176948504182 * indata[u"T.T.T[min]"].as_matrix()))
_temp_2 += 0.329266799549475 * arcsinh(
(-0.685243045984855 + 0.0000256301967602438 * indata[u"Dolo [kg]"].as_matrix()))
_temp_2 += 1.19218057619107 * arcsinh(
(-0.387759249366533 + 0.0000117450296274744 * indata[u"O2 inject [Nm3]"].as_matrix()))
_temp_2 += -0.263912677607981 * arcsinh((-0.231830329654435 + 0.624713233432101 * indata[u"Tn"].as_matrix()))
_temp_2 += 0.779255730450434 * arcsinh((41489.585694087 + 485.11873547859 * indata[u"Scrap (Ton)"].as_matrix()))
_temp_2 += -0.822857285031598 * log(
((-11812.5020191945 + indata[u"Lime [Kg]"].as_matrix()) / (234738.266306768 + -1 * indata[u"Lime [Kg]"].as_matrix())))
H1_3 = tanh(_temp_2)
_temp_3 += 4.88112584922222 * indata[u"De"].as_matrix()
_temp_3 += -17.7362809326343 * indata[u"Dt"].as_matrix()
_temp_3 += 0.228706755591884 * indata[u"Fs"].as_matrix()
_temp_3 += -0.34625638219889 * indata[u"I"].as_matrix()
_temp_3 += -0.133652566861778 * arcsinh((-8.82724940025682 + 1.11034437371763 * indata[u"Ls"].as_matrix()))
_temp_3 += 0.671302261376617 * arcsinh((-2.47261924507061 + 0.00123054887081347 * indata[u"G"].as_matrix()))
_temp_3 += 1.26504240595627 * arcsinh((-2.47261924507061 + 0.00123054887081347 * indata[u"تناژ ذوب"].as_matrix()))
_temp_3 += -0.419408113590424 * arcsinh(
(-2.22874994809614 + 0.000999222971144473 * indata[u"DRI [Ton]"].as_matrix()))
_temp_3 += 0.347732485713245 * arcsinh((-2.17071397432173 + 0.182551658052196 * indata[u"ts"].as_matrix()))
_temp_3 += -0.959063378380209 * arcsinh(
(-1.99771674986444 + 0.0000017889970646863 * indata[u"Energy [KWh]"].as_matrix()))
_temp_3 += 0.452201275851379 * arcsinh(
(-1.70343865820836 + 0.00199176948504182 * indata[u"T.T.T[min]"].as_matrix()))
_temp_3 += 0.808928494546987 * arcsinh(
(-0.685243045984855 + 0.0000256301967602438 * indata[u"Dolo [kg]"].as_matrix()))
_temp_3 += 0.444546963225285 * arcsinh(
(-0.387759249366533 + 0.0000117450296274744 * indata[u"O2 inject [Nm3]"].as_matrix()))
_temp_3 += -0.346179154618768 * arcsinh((-0.231830329654435 + 0.624713233432101 * indata[u"Tn"].as_matrix()))
_temp_3 += -1.31102755379037 * arcsinh((41489.585694087 + 485.11873547859 * indata[u"Scrap (Ton)"].as_matrix()))
_temp_3 += -0.188778417066098 * log(
((-11812.5020191945 + indata[u"Lime [Kg]"].as_matrix()) / (234738.266306768 + -1 * indata[u"Lime [Kg]"].as_matrix())))
H1_4 = tanh(_temp_3)
_temp_4 += -9.53481853497659 * indata[u"De"].as_matrix()
_temp_4 += 4.22151400194082 * indata[u"Dt"].as_matrix()
_temp_4 += -0.277274950580976 * indata[u"Fs"].as_matrix()
_temp_4 += -0.0885141805978403 * indata[u"I"].as_matrix()
_temp_4 += -0.186962642216943 * arcsinh((-8.82724940025682 + 1.11034437371763 * indata[u"Ls"].as_matrix()))
_temp_4 += -1.21895594405926 * arcsinh((-2.47261924507061 + 0.00123054887081347 * indata[u"G"].as_matrix()))
_temp_4 += 0.380941869713994 * arcsinh((-2.47261924507061 + 0.00123054887081347 * indata[u"تناژ ذوب"].as_matrix()))
_temp_4 += 0.386126314367183 * arcsinh(
(-2.22874994809614 + 0.000999222971144473 * indata[u"DRI [Ton]"].as_matrix()))
_temp_4 += -1.02997526288145 * arcsinh((-2.17071397432173 + 0.182551658052196 * indata[u"ts"].as_matrix()))
_temp_4 += -2.24351583121462 * arcsinh(
(-1.99771674986444 + 0.0000017889970646863 * indata[u"Energy [KWh]"].as_matrix()))
_temp_4 += -1.76616546575829 * arcsinh(
(-1.70343865820836 + 0.00199176948504182 * indata[u"T.T.T[min]"].as_matrix()))
_temp_4 += 2.00674705103229 * arcsinh(
(-0.685243045984855 + 0.0000256301967602438 * indata[u"Dolo [kg]"].as_matrix()))
_temp_4 += -4.27602558322612 * arcsinh(
(-0.387759249366533 + 0.0000117450296274744 * indata[u"O2 inject [Nm3]"].as_matrix()))
_temp_4 += 0.0510201182143028 * arcsinh((-0.231830329654435 + 0.624713233432101 * indata[u"Tn"]))
_temp_4 += 0.21569855683994 * arcsinh((41489.585694087 + 485.11873547859 * indata[u"Scrap (Ton)"].as_matrix()))
_temp_4 += -0.140324848765973 * log(
((-11812.5020191945 + indata[u"Lime [Kg]"].as_matrix()) / (234738.266306768 + -1 * indata[u"Lime [Kg]"].as_matrix())))
H1_5 = tanh(_temp_4)
_temp_5 += -0.0293642884727444 * H1_1
_temp_5 += 0.0451192163546081 * H1_2
_temp_5 += -0.0059618748546572 * H1_3
_temp_5 += -0.112789336899903 * H1_4
_temp_5 += 0.043041902823119 * H1_5
#outdata[u"Predicted الکترود Kg/Ton"] = _temp_5
return _temp_5
#save File funtion
def SaveFile(indata,_temp_5):
indata = indata.assign(Predicted_kg_per_Ton=_temp_5)
writer = ExcelWriter('output.xlsx')
indata.to_excel(writer, 'Sheet1')
writer.save()
print('output.xlsx is saved')
#run Program
SaveFile(data,score(data))
print(__doc__)
print("DONE")
numpy==1.14.3
pandas==0.23.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.