inconsistent shapes
Raise code
return A
def _divide_sparse(self, other):
"""
Divide this matrix by a second sparse matrix.
"""
if other.shape != self.shape:
raise ValueError('inconsistent shapes')
r = self._binopt(other, '_eldiv_')
if np.issubdtype(r.dtype, np.inexact):
# Eldiv leaves entries outside the combined sparsity
# pattern empty, so they must be filled manually.
# Everything outside of other's sparsity is NaN, and everything
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.
Links to the raise (1)
https://github.com/scipy/scipy/blob/e4b3e6eb372b8c1d875f2adf607630a31e2a609c/scipy/sparse/compressed.py#L1265Ways to fix
X_train, X_test, d_train, d_test = train_test_split(x, d, test_size=0.33, random_state=20, stratify=dt.iloc[:,-1:])
y_predict_train = np.zeros(d_train.shape, dtype=float)
y_predict_test = np.zeros(d_test.shape, dtype=float)
for i in range(d_test.shape[1]):
regresion = LinearRegression().fit(X_train, d_train[:,i])
y_predict_train[:,i] = regresion.predict(X_train)
y_predict_test[:,i] = regresion.predict(X_test)
def OneCold(y):
encoder = LabelBinarizer()
return encoder.fit_transform(np.argmax(y, axis=1))
accuracy_score(OneCold(y_predict_train), d_train)
X_train, X_test, d_train, d_test = train_test_split(x, d, test_size=0.33, random_state=20, stratify=dt.iloc[:,-1:])
y_predict_train = np.zeros(d_train.shape, dtype=float)
y_predict_test = np.zeros(d_test.shape, dtype=float)
for i in range(d_test.shape[1]):
regresion = LinearRegression().fit(X_train, d_train[:,i])
y_predict_train[:,i] = regresion.predict(X_train)
y_predict_test[:,i] = regresion.predict(X_test)
def OneCold(y):
encoder = LabelBinarizer()
return encoder.fit_transform(np.argmax(y, axis=1))
accuracy_score(OneCold(y_predict_train), d_train)