The solution:
The given dataset was already an array, so I didn’t need to call .values.
The solution:
The given dataset was already an array, so I didn’t need to call .values.
The problem lies in the following line:
df = StandardScaler().fit_transform(df)
It returns a NumPy array (see the documentation), which does not have a drop function. You would have to convert it into a pd.DataFrame first!
new_df = pd.DataFrame(StandardScaler().fit_transform(df), columns=df.columns, index=df.index)
On the line
mlp.fit(X_train, y_train.values.ravel())
y_train is of type numpy.ndarray and, as staded on the error message
has no attribute 'values'
If you have properly encoded this array, you should be able to use it simply as
mlp.fit(X_train, y_train)
I had the same error but this worked
random_forest.fit(X_train,y_train.ravel())
Error creating numpy v-stack, 'AttributeError: 'numpy.ndarray' object has no attribute 'np'
python - 'numpy.ndarray' object has no attribute 'values' - Stack Overflow
AttributeError: 'numpy.ndarray' object has no attribute 'numpy'
python - 'numpy.ndarray' object has no attribute 'value' - Stack Overflow
Hi,
I'm trying to create a numpy v-stack and creating 3 np.array's for it, by filling them with a loop:
I get the error: 'AttributeError: 'numpy.ndarray' object has no attribute 'np' . I think I'm using the wrong notation to append to the empty arrays:
neighbor_id = [id_ for id_ in range(1, n_obs) if id_ != user_id]
neighbor_id_arr = np.array(neighbor_id)
similarity = np.array([])
num_interactions = np.array([])
# get similarity and num_interactions
for id_ in neighbor_id:
similarity.np.append(np.dot(user_item.loc[user_id],user_item.loc[id_])) #The issue is here, I think
num_interactions.np.append(user_interactions.loc[id_])
c = numpy.vstack((neighbor_id_arr, similarity,num_interactions))
Thanks!
James
The solution: the given dataset was already an array, so I didnt need to call .value.
The problem lies in the following line:
df = StandardScaler().fit_transform(df)
It returns a numpy array (see docs), which does not have a drop function. You would have to convert it into a pd.DataFrame first!
new_df = pd.DataFrame(StandardScaler().fit_transform(df), columns=df.columns, index=df.index)
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!!