Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python35
/
lib64
/
python3.5
/
site-packages
/
sklearn
/
__pycache__
/
File Content:
isotonic.cpython-35.opt-1.pyc
��(X7 � @ s d d l Z d d l m Z d d l m Z d d l m Z m Z m Z d d l m Z m Z m Z d d l m Z d d l m Z d d l m Z m Z d d l Z d d l Z d d d g Z d d � Z d d d d d d � Z Gd d � d e e e � Z d S)� N)�interpolate)� spearmanr� )� BaseEstimator�TransformerMixin�RegressorMixin)�as_float_array�check_array�check_consistent_length)� deprecated)�astype)�'_inplace_contiguous_isotonic_regression�_make_unique�check_increasing�isotonic_regression�IsotonicRegressionc C s� t | | � \ } } | d k } | d k r� d t j d | d | � } d t j t | � d � } t j | d | � } t j | d | � } t j | � t j | � k r� t j d � | S) aE Determine whether y is monotonically correlated with x. y is found increasing or decreasing with respect to x based on a Spearman correlation test. Parameters ---------- x : array-like, shape=(n_samples,) Training data. y : array-like, shape=(n_samples,) Training target. Returns ------- `increasing_bool` : boolean Whether the relationship is increasing or decreasing. Notes ----- The Spearman correlation coefficient is estimated from the data, and the sign of the resulting estimate is used as the result. In the event that the 95% confidence interval based on Fisher transform spans zero, a warning is raised. References ---------- Fisher transformation. Wikipedia. https://en.wikipedia.org/wiki/Fisher_transformation r � �?g �?r � g\��(\�?zwConfidence interval of the Spearman correlation coefficient spans zero. Determination of ``increasing`` may be suspect.� �)r r ) r �math�log�sqrt�len�tanh�npZsign�warnings�warn) �x�yZrho�_Zincreasing_bool�FZF_seZrho_0Zrho_1� r! �/isotonic.pyr s " Tc C s | r t j d d � n t j d d d � } t j | | d t j �} | d k rx t j t | � d t j �} n t j | | d t j �} t | | � | d k s� | d k r� | d k r� t j } | d k r� t j } t j | | | | � | | S)a� Solve the isotonic regression model:: min sum w[i] (y[i] - y_[i]) ** 2 subject to y_min = y_[1] <= y_[2] ... <= y_[n] = y_max where: - y[i] are inputs (real numbers) - y_[i] are fitted - w[i] are optional strictly positive weights (default to 1.0) Read more in the :ref:`User Guide <isotonic>`. Parameters ---------- y : iterable of floating-point values The data. sample_weight : iterable of floating-point values, optional, default: None Weights on each point of the regression. If None, weight is set to 1 (equal weights). y_min : optional, default: None If not None, set the lowest value of the fit to y_min. y_max : optional, default: None If not None, set the highest value of the fit to y_max. increasing : boolean, optional, default: True Whether to compute ``y_`` is increasing (if set to True) or decreasing (if set to False) Returns ------- y_ : list of floating-point values Isotonic fit of y. References ---------- "Active set algorithms for isotonic regression; A unifying framework" by Michael J. Best and Nilotpal Chakravarti, section 3. Nr �dtype���) r Zs_�array�float64�onesr r �inf�clip)r � sample_weight�y_min�y_max� increasing�orderr! r! r"