AttributeError: 'list' object has no attribute 'shape'
See original GitHub issueIssue Description
I’m trying to predict a next step position (using latitude and longitude as attributes and target). I’ve tried the following:
pred = gmm.predict(len(X)+i, np.array([X[(num-1)+i]]))
where the first value is 10 and the second “array([[41.4051453, 2.1776344]])” with shape (1, 2)
however, I get this error:
`AttributeError: ‘list’ object has no attribute ‘shape’
What I’m doing wrong? `
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
'list' object has no attribute 'shape' - python - Stack Overflow
list object in python does not have 'shape' attribute because 'shape' implies that all the columns (or rows) have equal length along certain ......
Read more >AttributeError: 'list' object has no attribute 'shape' | bobbyhadz
The Python "AttributeError: 'list' object has no attribute 'shape'" occurs when we try to access the shape attribute on a list. To solve...
Read more >AttributeError: 'list' object has no attribute 'shape'
AttributeError : 'list' object has no attribute 'shape' ... Based on the error messages it seems that feats is a list , while...
Read more >PYTHON : 'list' object has no attribute 'shape' - YouTube
PYTHON : ' list ' object has no attribute ' shape ' [ Gift : Animated Search Engine : https://www.hows.tech/p/recommended.html ] PYTHON :...
Read more >'list' object has no attribute 'reshape' ( Solved )
The solution for this attributeError is very simple. If you want to change the shape or dimensions of the array then firstly convert...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It works!
That’s because the predict function expects an array of shape
(n_samples, n_features)
, but the shape is(n_features,)
. This version works for me:On the current master branch, otherwise you have to cast all lists to numpy arrays.