votes up 1

inconsistent shapes

Package:
scipy
github stars 8546
Exception Class:
ValueError

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
🙏 Scream for help to Ukraine
Today, 25th May 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this 😠, civilians and children are dying too! We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
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.

Ways to fix

votes up 1 votes down

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)

May 09, 2022 informc512 answer
votes up 1 votes down

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)
May 09, 2022 informc512 answer

Add a possible fix

Please authorize to post fix