Submit
Path:
~
/
/
proc
/
thread-self
/
root
/
opt
/
alt
/
python35
/
lib64
/
python3.5
/
site-packages
/
sklearn
/
__pycache__
/
File Content:
dummy.cpython-35.pyc
��(X�C � @ s� d d l m Z d d l Z d d l Z d d l j 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 d d l m Z d d l m Z d d l m Z d d l m Z Gd d � d e e � Z Gd d � d e e � Z d S)� )�divisionN� )� BaseEstimator�ClassifierMixin�RegressorMixin)�check_random_state)�check_array)�check_consistent_length)�check_is_fitted)�random_choice_csc)�_weighted_percentile)�class_distributionc @ s^ e Z d Z d Z d d d d d � Z d d d � Z d d � Z d d � Z d d � Z d S)�DummyClassifieraO DummyClassifier is a classifier that makes predictions using simple rules. This classifier is useful as a simple baseline to compare with other (real) classifiers. Do not use it for real problems. Read more in the :ref:`User Guide <dummy_estimators>`. Parameters ---------- strategy : str, default="stratified" Strategy to use to generate predictions. * "stratified": generates predictions by respecting the training set's class distribution. * "most_frequent": always predicts the most frequent label in the training set. * "prior": always predicts the class that maximizes the class prior (like "most_frequent") and ``predict_proba`` returns the class prior. * "uniform": generates predictions uniformly at random. * "constant": always predicts a constant label that is provided by the user. This is useful for metrics that evaluate a non-majority class .. versionadded:: 0.17 Dummy Classifier now supports prior fitting strategy using parameter *prior*. random_state : int seed, RandomState instance, or None (default) The seed of the pseudo random number generator to use. constant : int or str or array of shape = [n_outputs] The explicit constant as predicted by the "constant" strategy. This parameter is useful only for the "constant" strategy. Attributes ---------- classes_ : array or list of array of shape = [n_classes] Class labels for each output. n_classes_ : array or list of array of shape = [n_classes] Number of label for each output. class_prior_ : array or list of array of shape = [n_classes] Probability of each class for each output. n_outputs_ : int, Number of outputs. outputs_2d_ : bool, True if the output at fit is 2d, else false. sparse_output_ : bool, True if the array returned from predict is to be in sparse CSC format. Is automatically set to True if the input y is passed in sparse format. � stratifiedNc C s | | _ | | _ | | _ d S)N)�strategy�random_state�constant)�selfr r r � r � /dummy.py�__init__P s zDummyClassifier.__init__c s� � j d k r t d � � � j d k rU t j | � rU | j � } t j d t � t j | � � _ � j s t j | � } | j d k � _ | j d k r� t j | d � } | j d � _ � j d k r6� j d k r� t d � � nG t j t j � j � d � � � j d � j k r6t d � j � � t | | � \ � _ � _ � _ � j d k r�t � � f d d � t � j � D� � r�t d � � � j d k r�� j r�� j d � _ � j d � _ � j d � _ � S)a$ Fit the random classifier. Parameters ---------- X : {array-like, sparse matrix}, shape = [n_samples, n_features] Training vectors, where n_samples is the number of samples and n_features is the number of features. y : array-like, shape = [n_samples] or [n_samples, n_outputs] Target values. sample_weight : array-like of shape = [n_samples], optional Sample weights. Returns ------- self : object Returns self. � most_frequentr �uniformr �priorzUnknown strategy type.z�A local copy of the target data has been converted to a numpy array. Predicting on sparse target data with the uniform strategy would not save memory and would be slower.� r NzMConstant target value has to be specified when the constant strategy is used.r z0Constant target value should have shape (%d, 1).c 3 s&