I am rolling classifier based on SVC which computes a custom Gram matrix
and runs this through the SVC classifier with kernel = 'precomputed'. While
this works fine with the fit method, I face a dilemma with the predict
method, shown here:


    def predict(self, X):
        """Run the predict method of the previously-instantiated SVM
        classifier, returning the predicted classes for test set X."""

        # Check is fit had been called
        check_is_fitted(self, ['X_', 'y_'])

        # Input validation
        X = check_array(X)

        cut_off = self.cut_ord_pair[0]
        order = self.cut_ord_pair[1]

        X_gram = seq_kernel_free(X, self.X_, \
        pri_kernel=kernselect(self.kernel, self.coef0, self.gamma,
self.degree, self.scale), \
        cut_off=cut_off, order=order)

        X_gram = np.nan_to_num(X_gram)

        return self.ord_svc_.predict(X_gram)

This will run on any dataset just fine. However, it fails the
check_estimator test. Specifically, when trying to raise an error for
malformed input on predict (in check_classifiers_train), it says that a
ValueError is not raised. Yet if I change the order of X and self.X_ in
seq_kernel_free (which computes the [n_samples_train, n_samples_test] Gram
matrix), it passes the check_estimator test yet fails to run the predict
method.

How do I resolve both issues simultaneously?
_______________________________________________
scikit-learn mailing list
scikit-learn@python.org
https://mail.python.org/mailman/listinfo/scikit-learn

Reply via email to