Module Import alias Import alias identifier ImportFrom alias ImportFrom alias ImportFrom alias FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str ImportFrom alias If BinOpSub Call NameLoad NameLoad Call NameLoad NameLoad body Raise Call NameLoad Str If BoolOpOr CompareIs NameLoad NameLoad CompareEq Call NameLoad NameLoad Num body Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Num keyword AttributeLoad NameLoad attr keyword Str orelse If CompareIn NameLoad ListLoad Str Str body Assign NameStore Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad If UnaryOpNot Call NameLoad Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr body Raise Call NameLoad Str If CompareEq NameLoad Str body Assign NameStore BinOpDiv Num Call NameLoad NameLoad Assign NameStore BinOpDiv SubscriptLoad NameLoad Index Call AttributeLoad NameLoad attr NameLoad Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Str NameLoad orelse Assign NameStore BinOpDiv Call NameLoad NameLoad BinOpMult Call NameLoad AttributeLoad NameLoad attr Call AttributeLoad Call NameLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore SubscriptLoad NameLoad Index Call AttributeLoad NameLoad attr NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Num keyword AttributeLoad NameLoad attr keyword Str If UnaryOpNot Call NameLoad NameLoad NameLoad body Raise Call NameLoad BinOpMod Str NameLoad For NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad If BoolOpOr CompareGtE NameLoad Call NameLoad NameLoad CompareNotEq SubscriptLoad NameLoad Index NameLoad NameLoad body Raise Call NameLoad BinOpMod Str NameLoad orelse Assign SubscriptStore NameLoad Index NameLoad SubscriptLoad NameLoad Index NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareEq AttributeLoad NameLoad attr Num body Assign NameStore Call AttributeLoad NameLoad attr NameLoad TupleLoad Num Num Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Num If Call NameLoad NameLoad AttributeLoad NameLoad attr body If CompareNotIn NameLoad ListLoad Str Str body Raise Call NameLoad BinOpMod Str NameLoad orelse If BoolOpAnd CompareIsNot NameLoad NameLoad UnaryOpNot Call NameLoad NameLoad AttributeLoad NameLoad attr body Raise Call NameLoad BinOpMod Str NameLoad orelse If CompareGt NameLoad Num body If BoolOpOr UnaryOpNot Call NameLoad NameLoad Str Call NameLoad NameLoad NameLoad body Raise Call NameLoad Str If CompareNotEq Call NameLoad NameLoad NameLoad body Raise Call NameLoad Str Assign NameStore ListLoad For NameStore Call NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad ExtSlice Slice Index NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameLoad If BoolOpOr CompareIn NameLoad ListLoad Str Str CompareEq NameLoad Num body Assign NameStore NameLoad orelse Assign NameStore SubscriptLoad NameLoad Index NameLoad If CompareIsNot NameLoad NameLoad body Assign NameStore SubscriptLoad NameLoad Index TupleLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad keyword Str Assign NameStore BinOpSub Call NameLoad NameLoad Call NameLoad NameLoad orelse Assign NameStore Call NameLoad NameLoad NameLoad NameLoad Assign NameStore SubscriptLoad NameLoad Index Call AttributeLoad NameLoad attr NameLoad NameLoad If NameLoad body Assign SubscriptStore NameLoad Index Call NameLoad NameLoad Call NameLoad NameLoad Num Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword Num keyword AttributeLoad NameLoad attr Return NameLoad decorator_list
N/A N/A warnings N/A numpy np externals six utils.fixes in1d fixes bincount compute_class_weight N/A N/A class_weight classes y N/A N/A N/A Estimate class weights for unbalanced datasets.

    Parameters
    ----------
    class_weight : dict, 'balanced' or None
        If 'balanced', class weights will be given by
        ``n_samples / (n_classes * np.bincount(y))``.
        If a dictionary is given, keys are classes and values
        are corresponding class weights.
        If None is given, the class weights will be uniform.

    classes : ndarray
        Array of the classes occurring in the data, as given by
        ``np.unique(y_org)`` with ``y_org`` the original class labels.

    y : array-like, shape (n_samples,)
        Array of original class labels per sample;

    Returns
    -------
    class_weight_vect : ndarray, shape (n_classes,)
        Array with class_weight_vect[i] the weight for i-th class

    References
    ----------
    The "balanced" heuristic is inspired by
    Logistic Regression in Rare Events Data, King, Zen, 2001.
     preprocessing LabelEncoder N/A N/A N/A set y N/A set classes N/A N/A N/A ValueError classes should include all valid labels that can be in y N/A N/A N/A class_weight None N/A N/A len class_weight 0 N/A N/A weight N/A N/A np ones N/A N/A classes shape N/A 0 dtype N/A np float64 order C N/A N/A N/A class_weight N/A auto balanced N/A N/A le N/A LabelEncoder N/A y_ind N/A N/A le fit_transform y N/A N/A N/A all N/A N/A np in1d classes N/A le classes_ N/A N/A N/A ValueError classes should have valid labels that are in y N/A N/A class_weight auto N/A N/A recip_freq N/A 1.0 N/A bincount y_ind N/A weight N/A N/A recip_freq N/A N/A N/A le transform classes N/A N/A np mean recip_freq N/A N/A N/A warnings warn The class_weight='auto' heuristic is deprecated in 0.17 in favor of a new heuristic class_weight='balanced'. 'auto' will be removed in 0.19 DeprecationWarning N/A N/A recip_freq N/A N/A len y N/A N/A len N/A le classes_ N/A N/A N/A bincount y_ind astype N/A np float64 N/A weight N/A recip_freq N/A N/A N/A le transform classes N/A N/A weight N/A N/A np ones N/A N/A classes shape N/A 0 dtype N/A np float64 order C N/A N/A N/A isinstance class_weight dict N/A N/A N/A ValueError N/A class_weight must be dict, 'auto', or None, got: %r class_weight N/A c class_weight N/A N/A i N/A N/A np searchsorted classes c N/A N/A N/A i N/A len classes N/A N/A classes N/A i c N/A N/A N/A ValueError N/A Class label %d not present. c N/A N/A N/A weight N/A i N/A class_weight N/A c N/A weight N/A compute_sample_weight N/A N/A class_weight y indices N/A None N/A N/A Estimate sample weights by class for unbalanced datasets.

    Parameters
    ----------
    class_weight : dict, list of dicts, "balanced", or None, optional
        Weights associated with classes in the form ``{class_label: weight}``.
        If not given, all classes are supposed to have weight one. For
        multi-output problems, a list of dicts can be provided in the same
        order as the columns of y.

        The "balanced" mode uses the values of y to automatically adjust
        weights inversely proportional to class frequencies in the input data:
        ``n_samples / (n_classes * np.bincount(y))``.

        For multi-output, the weights of each column of y will be multiplied.

    y : array-like, shape = [n_samples] or [n_samples, n_outputs]
        Array of original class labels per sample.

    indices : array-like, shape (n_subsample,), or None
        Array of indices to be used in a subsample. Can be of length less than
        n_samples in the case of a subsample, or equal to n_samples in the
        case of a bootstrap subsample with repeated indices. If None, the
        sample weight will be calculated over the full sample. Only "auto" is
        supported for class_weight if this is provided.

    Returns
    -------
    sample_weight_vect : ndarray, shape (n_samples,)
        Array with sample weights as applied to the original y
     N/A y N/A N/A np atleast_1d y N/A N/A N/A y ndim 1 N/A N/A y N/A N/A np reshape y N/A -1 1 N/A n_outputs N/A N/A y shape N/A 1 N/A N/A isinstance class_weight N/A six string_types N/A N/A N/A class_weight N/A balanced auto N/A N/A N/A ValueError N/A The only valid preset for class_weight is "balanced". Given "%s". class_weight N/A N/A N/A N/A indices None N/A N/A isinstance class_weight N/A six string_types N/A N/A N/A ValueError N/A The only valid class_weight for subsampling is "balanced". Given "%s". class_weight N/A N/A N/A n_outputs 1 N/A N/A N/A N/A N/A hasattr class_weight __iter__ N/A isinstance class_weight dict N/A N/A N/A ValueError For multi-output, class_weight should be a list of dicts, or a valid string. N/A N/A N/A len class_weight n_outputs N/A N/A N/A ValueError For multi-output, number of elements in class_weight should match number of outputs. N/A expanded_class_weight N/A N/A k N/A range n_outputs N/A N/A y_full N/A y N/A N/A N/A k N/A classes_full N/A N/A np unique y_full N/A classes_missing None N/A N/A N/A class_weight N/A balanced auto N/A n_outputs 1 N/A N/A class_weight_k class_weight N/A N/A class_weight_k N/A class_weight N/A k N/A N/A indices None N/A N/A y_subsample N/A y N/A N/A indices k N/A classes_subsample N/A N/A np unique y_subsample N/A weight_k N/A N/A np choose N/A N/A np searchsorted classes_subsample classes_full N/A compute_class_weight class_weight_k classes_subsample y_subsample mode clip N/A classes_missing N/A N/A set classes_full N/A set classes_subsample N/A N/A weight_k N/A compute_class_weight class_weight_k classes_full y_full N/A weight_k N/A weight_k N/A N/A N/A np searchsorted classes_full y_full N/A classes_missing N/A N/A N/A weight_k N/A N/A in1d y_full N/A list classes_missing 0.0 N/A N/A N/A expanded_class_weight append weight_k N/A expanded_class_weight N/A N/A np prod expanded_class_weight axis 0 dtype N/A np float64 N/A expanded_class_weight N/A