I have Dataframe of "IMDB data from 2006 to 2016" which is in Kaggle site: https://www.kaggle.com/PromptCloudHQ/imdb-data . I have made it as numpy array but when I want to assign the inner product of two row of it to numpy.float64 variable, it gives me this error:
sim[i][1] = np.inner(vec[i],vec[1])
TypeError: 'numpy.float64' object does not support item assignment
here is my code:
X = trainset.drop(['Description', 'Runtime','Director','Title', 'ID'], axis=1)
X.Revenue = X.Revenue.fillna(X.Revenue.mean())
X.Metascore= X.Metascore.fillna(X.Revenue.min())
features = ['Genre','Actors']
for f in features:
X_dummy = X[f].str.get_dummies(',').add_prefix(f + '.')
X = X.drop([f], axis = 1)
X = pd.concat((X, X_dummy), axis = 1)
vec = np.ones((1000,2422), dtype=np.uint8)
vec = X.values
sim = np.ones((1000,1), dtype=np.float64)
for i in range (1,1000):
sim[i][1] = np.inner(vec[i],vec[1])
and when I get the type of this inner product it gives me exactly this type:
>>chi = np.inner(vec[0],vec[0])
>>print(type(chi))
<class 'numpy.float64'>
vec = np.array((1000,2422), dtype=np.uint8),sim = np.array((1000,1), dtype=np.float64)are these tuples supposed to be the shapes of the arrays? If so, you are using them wrong. Use theshapeargument in a populated array likenp.onesornp.zeros.