def check_predictions(clf, X, y):
 n_samples = len(y)
 classes = np.unique(y)
 n_classes = classes.shape[0]
 predicted = clf.fit(X, y).predict(X)
 assert_array_equal(clf.classes_, classes)
 assert_equal(predicted.shape, (n_samples,))
 assert_array_equal(predicted, y)
 probabilities = clf.predict_proba(X)
 assert_equal(probabilities.shape, (n_samples, n_classes))
 assert_array_almost_equal(probabilities.sum(axis=1), np.ones(n_samples))
 assert_array_equal(probabilities.argmax(axis=1), y)

def check_predictions ( clf , X , y ) : n_samples = len ( y ) classes = np . unique ( y ) n_classes = classes . shape [ 0 ] predicted = clf . fit ( X , y ) . predict ( X ) assert_array_equal ( clf . classes_ , classes ) assert_equal ( predicted . shape , ( n_samples , ) ) assert_array_equal ( predicted , y ) probabilities = clf . predict_proba ( X ) assert_equal ( probabilities . shape , ( n_samples , n_classes ) ) assert_array_almost_equal ( probabilities . sum ( axis = 1 ) , np . ones ( n_samples ) ) assert_array_equal ( probabilities . argmax ( axis = 1 ) , y )
check that the model is able to fit the classification data .