Reputation: 9
My python code was running successfully in Ubuntu 14.04; but when I went to run in Windows Platform, it throws me into error. The Code:
import pymc
with open("days1.txt") as f:
dataset = map(float, f)
a = pymc.Uniform('a', lower=0, upper=1500000, value=70, doc='Weibull alpha parameter')
b = pymc.Uniform('b', lower=0, upper=1500000, value=70, doc='Weibull beta parameter')
like = pymc.Weibull('like', alpha=a, beta=b, value=dataset, observed=True)
if __name__=='__main__':
import pylab
M = pymc.MCMC([a,b,like])
M.sample(10000,5000,2)
pymc.Matplot.plot(a)
pymc.Matplot.plot(b)
M.summary()
M.write_csv("parameters1.csv")
The error:
C:\Python35-32>python.exe "E:\TCS\Desktop\EarlyWarning\JLR\Data\EJ327000AB\Scrip
ts\Screen 7\Check Python - 1\weibullEstimationOutData - 1.py"
Traceback (most recent call last):
File "C:\Python35-32\lib\site-packages\pymc\PyMCObjects.py", line 742, in __in
it__
self._value = np.array(value, dtype=dtype)
TypeError: float() argument must be a string or a number, not 'map'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\TCS\Desktop\EarlyWarning\JLR\Data\EJ327000AB\Scripts\Screen 7\Check P
ython - 1\weibullEstimationOutData - 1.py", line 8, in <module>
like = pymc.Weibull('like', alpha=a, beta=b, value=dataset, observed=True)
AttributeError: 'TypeError' object has no attribute 'message'
Kindly Help. Thanks in Advance
Upvotes: 0
Views: 152
Reputation: 42778
You are using Python 2 with Ubuntu, but Python 3 with Windows. Install Python 2 for Windows, or port your code to Python 3
import pylab
import pymc
with open("days1.txt") as f:
dataset = list(map(float, f))
a = pymc.Uniform('a', lower=0, upper=1500000, value=70, doc='Weibull alpha parameter')
b = pymc.Uniform('b', lower=0, upper=1500000, value=70, doc='Weibull beta parameter')
like = pymc.Weibull('like', alpha=a, beta=b, value=dataset, observed=True)
if __name__=='__main__':
M = pymc.MCMC([a,b,like])
M.sample(10000,5000,2)
pymc.Matplot.plot(a)
pymc.Matplot.plot(b)
M.summary()
M.write_csv("parameters1.csv")
Upvotes: 2