# Path: sksurv/base.py
# class SurvivalAnalysisMixin:
# 
#     def score(self, X, y):
#         """Returns the concordance index of the prediction.
# 
#         Parameters
#         ----------
#         X : array-like, shape = (n_samples, n_features)
#             Test samples.
# 
#         y : structured array, shape = (n_samples,)
#             A structured array containing the binary event indicator
#             as first field, and time of event or time of censoring as
#             second field.
# 
#         Returns
#         -------
#         cindex : float
#             Estimated concordance index.
#         """
#         from .metrics import concordance_index_censored
#         name_event, name_time = y.dtype.names
# 
#         risk_score = self.predict(X)
#         if not getattr(self, "_predict_risk_score", True):
#             risk_score *= -1  # convert prediction on time scale to risk scale
# 
#         result = concordance_index_censored(y[name_event], y[name_time], risk_score)
#         return result[0]
# 
# Path: sksurv/exceptions.py
# class NoComparablePairException(ValueError):
#     """An error indicating that data of censored event times
#     does not contain one or more comparable pairs.
#     """
# 
# Path: sksurv/util.py
# def check_array_survival(X, y):
#     """Check that all arrays have consistent first dimensions.
# 
#     Parameters
#     ----------
#     X : array-like
#         Data matrix containing feature vectors.
# 
#     y : structured array with two fields
#         A structured array containing the binary event indicator
#         as first field, and time of event or time of censoring as
#         second field.
# 
#     kwargs : dict
#         Additional arguments passed to :func:`sklearn.utils.check_array`.
# 
#     Returns
#     -------
#     event : array, shape=[n_samples,], dtype=bool
#         Binary event indicator.
# 
#     time : array, shape=[n_samples,], dtype=float
#         Time of event or censoring.
#     """
#     event, time = check_y_survival(y)
#     check_consistent_length(X, event, time)
#     return event, time


from abc import ABCMeta, abstractmethod
from scipy import linalg, sparse
from sklearn.base import BaseEstimator
from sklearn.exceptions import ConvergenceWarning
from sklearn.metrics.pairwise import pairwise_kernels
from ..base import SurvivalAnalysisMixin
from ..exceptions import NoComparablePairException
from ..util import check_array_survival
from ._minlip import create_difference_matrix
import warnings
import numpy
        import osqp
        import ecos
            import timeit
                stacklevel=3)
        elif exit_flag == EcosSolver.EXIT_PINF:  # pragma: no cover
            raise RuntimeError("Certificate of primal infeasibility found")
        elif exit_flag == EcosSolver.EXIT_DINF:  # pragma: no cover
            raise RuntimeError("Certificate of dual infeasibility found")
        else:  # pragma: no cover
            raise RuntimeError("Unknown problem in ECOS solver, exit status: {}".format(exit_flag))

    def _decompose(self, P):
        # from scipy.linalg.pinvh
        s, u = linalg.eigh(P)
        largest_eigenvalue = numpy.max(numpy.abs(s))

        cond = self.cond
        if cond is None:
            t = u.dtype
            cond = largest_eigenvalue * max(P.shape) * numpy.finfo(t).eps

        not_below_cutoff = (abs(s) > -cond)
        assert not_below_cutoff.all(), "matrix has negative eigenvalues: {}".format(s.min())

        above_cutoff = (abs(s) > cond)
        u = u[:, above_cutoff]
        s = s[above_cutoff]

        # set maximum eigenvalue to 1
        decomposed = u * numpy.sqrt(s / largest_eigenvalue)
        return decomposed.T, largest_eigenvalue



# Path: sksurv/base.py
# class SurvivalAnalysisMixin:
# 
#     def score(self, X, y):
#         """Returns the concordance index of the prediction.
# 
#         Parameters
#         ----------
#         X : array-like, shape = (n_samples, n_features)
#             Test samples.
# 
#         y : structured array, shape = (n_samples,)
#             A structured array containing the binary event indicator
#             as first field, and time of event or time of censoring as
#             second field.
# 
#         Returns
#         -------
#         cindex : float
#             Estimated concordance index.
#         """
#         from .metrics import concordance_index_censored
#         name_event, name_time = y.dtype.names
# 
#         risk_score = self.predict(X)
#         if not getattr(self, "_predict_risk_score", True):
#             risk_score *= -1  # convert prediction on time scale to risk scale
# 
#         result = concordance_index_censored(y[name_event], y[name_time], risk_score)
#         return result[0]
# 
# Path: sksurv/exceptions.py
# class NoComparablePairException(ValueError):
#     """An error indicating that data of censored event times
#     does not contain one or more comparable pairs.
#     """
# 
# Path: sksurv/util.py
# def check_array_survival(X, y):
#     """Check that all arrays have consistent first dimensions.
# 
#     Parameters
#     ----------
#     X : array-like
#         Data matrix containing feature vectors.
# 
#     y : structured array with two fields
#         A structured array containing the binary event indicator
#         as first field, and time of event or time of censoring as
#         second field.
# 
#     kwargs : dict
#         Additional arguments passed to :func:`sklearn.utils.check_array`.
# 
#     Returns
#     -------
#     event : array, shape=[n_samples,], dtype=bool
#         Binary event indicator.
# 
#     time : array, shape=[n_samples,], dtype=float
#         Time of event or censoring.
#     """
#     event, time = check_y_survival(y)
#     check_consistent_length(X, event, time)
#     return event, time


# Path: sksurv/svm/minlip.py
from abc import ABCMeta, abstractmethod
from scipy import linalg, sparse
from sklearn.base import BaseEstimator
from sklearn.exceptions import ConvergenceWarning
from sklearn.metrics.pairwise import pairwise_kernels
from ..base import SurvivalAnalysisMixin
from ..exceptions import NoComparablePairException
from ..util import check_array_survival
from ._minlip import create_difference_matrix
import warnings
import numpy
        import osqp
        import ecos
            import timeit

                stacklevel=3)
        elif exit_flag == EcosSolver.EXIT_PINF:  # pragma: no cover
            raise RuntimeError("Certificate of primal infeasibility found")
        elif exit_flag == EcosSolver.EXIT_DINF:  # pragma: no cover
            raise RuntimeError("Certificate of dual infeasibility found")
        else:  # pragma: no cover
            raise RuntimeError("Unknown problem in ECOS solver, exit status: {}".format(exit_flag))

    def _decompose(self, P):
        # from scipy.linalg.pinvh
        s, u = linalg.eigh(P)
        largest_eigenvalue = numpy.max(numpy.abs(s))

        cond = self.cond
        if cond is None:
            t = u.dtype
            cond = largest_eigenvalue * max(P.shape) * numpy.finfo(t).eps

        not_below_cutoff = (abs(s) > -cond)
        assert not_below_cutoff.all(), "matrix has negative eigenvalues: {}".format(s.min())

        above_cutoff = (abs(s) > cond)
        u = u[:, above_cutoff]
        s = s[above_cutoff]

        # set maximum eigenvalue to 1
        decomposed = u * numpy.sqrt(s / largest_eigenvalue)
        return decomposed.T, largest_eigenvalue



class MinlipSurvivalAnalysis(BaseEstimator, SurvivalAnalysisMixin):