python 2.7 - Tensorflow error using tf.image.random : 'numpy.ndarray' object has no attribute 'get_shape' - Stack Overflow
python - AttributeError: 'numpy.ndarray' object has no attribute 'get_shape'? - Stack Overflow
tensorflow - Python - AttributeError: 'numpy.ndarray' object has no attribute 'input_shapes' - Stack Overflow
AttributeError: 'Array' object has no attribute 'shape'
Using .values on a pandas dataframe gives you a numpy array. This will not contain column names and such. You do this when setting X like this:
X = dataset[['Read?', 'x1', .. ,'x47']].values
But then you try to get the column names from X (which it does not have) by writing X.columns here:
coeff_df = pd.DataFrame(regressor.coef_, X.columns, columns=['Coefficient'])
So store your column names in a variable or input them again, like this:
coeff_df = pd.DataFrame(regressor.coef_, ['Read?', 'x1', .. ,'x47'], columns=['Coefficient'])
hi remove values method
X = dataset[['Read?', 'x1', 'x2', 'x3', 'x4', 'x5', 'x6' , 'x7','x8','x9','x10','x11','x12','x13','x14','x15','x16','x17','x18','x19','x20','x21','x22','x23','x24','x25','x26','x27','x28','x29','x30','x31','x32','x33','x34','x35','x36','x37','x38','x39','x40','x41','x42','x43','x44','x45','x46','x47']]
coeff_df = pd.DataFrame(regressor.coef_, X.columns, columns=['Coefficient'])
Check the shape of mealarray. If the argument to fit_transform is an array of strings, it must be a one-dimensional array. (That is, mealarray.shape must be of the form (n,).) For example, you'll get the "no attribute" error if mealarray has a shape such as (n, 1).
You could try something like
data = vectorizer.fit_transform(mealarray.ravel())
Got the answer to my question. Basically, CountVectorizer is taking lists (with string contents) as an argument rather than array. That solved my problem.
Use numpy.array to use shape attribute.
>>> import numpy as np
>>> X = np.array([
... [[-9.035250067710876], [7.453250169754028], [33.34074878692627]],
... [[-6.63700008392334], [5.132999956607819], [31.66075038909912]],
... [[-5.1272499561309814], [8.251499891281128], [30.925999641418457]]
... ])
>>> X.shape
(3L, 3L, 1L)
NOTE X.shape returns 3-items tuple for the given array; [n, T] = X.shape raises ValueError.
Alternatively, you can use np.shape(...)
For instance:
import numpy as np
a=[1,2,3]
and np.shape(a) will give an output of (3,)
https://imgur.com/gallery/yAdAjdx
Hello,
Linked is the screenshot of the two error messages I keep recieving as well as the code leading up to it. I'm trying to run an uplift on a classification tree. Any help is appreciated, I am still fairly new to python. Thank you!!
Recoding Variables
"
#I need to recode variables given there are "5" responses present on a 4-point scale
scldict = {1:1,2:2,3:3,4:4,5:'NaN'}
w1array = np.array(week1)
w1vec = w1array.vectorize(scldict)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-92-e3f6056d2727> in <module>()
2 scaldict = {1:1,2:2,3:3,4:4,5:'NaN'}
3 w1array = np.array(week1)
----> 4 w1vec = w1array.vectorize(scaldict)
AttributeError: 'numpy.ndarray' object has no attribute 'vectorize'Hello world, I am trying to recode variables given there are invalid responses in my survey data. I am using a dictionary and the vectorize function (seen on StackOverflow) to do this. Why is the vectorize function not available? I am lost.
Any help or suggestions for recoding variables in an efficient manner would be appreciated.