You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ python gradient_descent.py
Traceback (most recent call last):
File "gradient_descent.py", line 73, in<module>
x, y = np.loadtxt("data.txt", delimiter= "\t", unpack = True)
File "/Users/fujisho/.pyenv/versions/3.7.4/lib/python3.7/site-packages/numpy/lib/npyio.py", line 1146, in loadtxt
forxin read_data(_loadtxt_chunksize):
File "/Users/fujisho/.pyenv/versions/3.7.4/lib/python3.7/site-packages/numpy/lib/npyio.py", line 1074, in read_data
items = [conv(val) for(conv, val)in zip(converters, vals)]
File "/Users/fujisho/.pyenv/versions/3.7.4/lib/python3.7/site-packages/numpy/lib/npyio.py", line 1074, in<listcomp>
items = [conv(val) for(conv, val)in zip(converters, vals)]
File "/Users/fujisho/.pyenv/versions/3.7.4/lib/python3.7/site-packages/numpy/lib/npyio.py", line 781, in floatconv
return float(x)
ValueError: could not convert string to float: 'The dataset for gradient descent example can be downloaded from: http://themlbook.com/wiki/doku.php?id=gradient_descent'
I downloaded the CSV pointed in data.txt and loaded it instead of it, but it didn't work as well:
$ python gradient_descent.py
Traceback (most recent call last):
File "gradient_descent.py", line 73, in<module>
x, y = np.loadtxt("Advertising.csv", delimiter= "\t", unpack = True)
File "/Users/fujisho/.pyenv/versions/3.7.4/lib/python3.7/site-packages/numpy/lib/npyio.py", line 1146, in loadtxt
forxin read_data(_loadtxt_chunksize):
File "/Users/fujisho/.pyenv/versions/3.7.4/lib/python3.7/site-packages/numpy/lib/npyio.py", line 1074, in read_data
items = [conv(val) for(conv, val)in zip(converters, vals)]
File "/Users/fujisho/.pyenv/versions/3.7.4/lib/python3.7/site-packages/numpy/lib/npyio.py", line 1074, in<listcomp>
items = [conv(val) for(conv, val)in zip(converters, vals)]
File "/Users/fujisho/.pyenv/versions/3.7.4/lib/python3.7/site-packages/numpy/lib/npyio.py", line 781, in floatconv
return float(x)
ValueError: could not convert string to float: ',TV,radio,newspaper,sales'
It would be helpful if you can provide any tips to solve the problem.
The text was updated successfully, but these errors were encountered:
Looks like the gradient_descent.py script expects a tabular CSV.
You have to remove the header (the first line of Advertising.csv), remove the ids (the first column of Advertising.csv), and then replace the comas by tabs (real tabs, not 2/4/8 spaces).
save advertising.csv to the same folder with the original file
create a new folder "Illustrations" within the same folder
replace lines 12 and 72 with:
x, y = np.loadtxt("advertising.csv", delimiter= ",", skiprows=1, usecols=(2,4), unpack = True)
to ignore the header, use "," instead of tabular and use specific columns instead of all 5
Hi,
I tried running gradient_descent.py.
But it failed.
I downloaded the CSV pointed in
data.txt
and loaded it instead of it, but it didn't work as well:It would be helpful if you can provide any tips to solve the problem.
The text was updated successfully, but these errors were encountered: