lale.lib.imblearn.all_knn module

class lale.lib.imblearn.all_knn.AllKNN(*, operator, sampling_strategy='auto', n_neighbors=3, kind_sel='all', allow_minority=False, n_jobs=1)

Bases: PlannedIndividualOp

Class to perform under-sampling based on the AllKNN method.

This documentation is auto-generated from JSON schemas.

Parameters
  • operator (operator, optional) –

    Trainable Lale pipeline that is trained using the data obtained from the current imbalance corrector.

    Predict, transform, predict_proba or decision_function would just be forwarded to the trained pipeline. If operator is a Planned pipeline, the current imbalance corrector can’t be trained without using an optimizer to choose a trainable operator first. Please refer to lale/examples for more examples.

  • sampling_strategy (union type, optional, not for optimizer, default 'auto') –

    Sampling information to resample the data set.

    • ’minority’, ‘not minority’, ‘not majority’, ‘all’, or ‘auto’

      The class targeted by the resampling. The number of samples in the different classes will be equalized. Possible choices are:

      • 'minority': resample only the minority class;

      • 'not minority': resample all classes but the minority class;

      • 'not majority': resample all classes but the majority class;

      • 'all': resample all classes;

      • 'auto': equivalent to 'not majority'.

    • or union type, not for optimizer

      Classes targeted by the resampling.

      • array of items : float

      • or array of items : string

    • or callable, not for optimizer

      Function taking y and returns a dict. The keys correspond to the targeted classes and the values correspond to the desired number of samples for each class.

  • n_neighbors (union type, optional, not for optimizer, default 3) –

    Number of neighbors.

    • integer

      Number of nearest neighbours to use to construct synthetic samples.

    • or Any

      An estimator that inherits from sklearn.neighbors.base.KNeighborsMixin that will be used to find the n_neighbors.

  • kind_sel (‘all’ or ‘mode’, optional, not for optimizer, default ‘all’) – Strategy to use in order to exclude samples. If all, all neighbours will have to agree with the samples of interest to not be excluded. If mode, the majority vote of the neighbours will be used in order to exclude a sample.

  • allow_minority (boolean, optional, not for optimizer, default False) – If True, it allows the majority classes to become the minority class without early stopping.

  • n_jobs (integer, optional, not for optimizer, default 1) – The number of threads to open if possible.

decision_function(X)

Confidence scores for all classes.

Note: The decision_function method is not available until this operator is trained.

Once this method is available, it will have the following signature:

Parameters

X (array of items : array of items : float) – Features; the outer array is over samples.

Returns

result – Output data schema for predictions.

Return type

Any

fit(X, y=None, **fit_params)

Train the operator.

Note: The fit method is not available until this operator is trainable.

Once this method is available, it will have the following signature:

Parameters
  • X (array of items : array of items : float) – Features; the outer array is over samples.

  • y (union type) –

    Target class labels; the array is over samples.

    • array of items : float

    • or array of items : string

predict(X, **predict_params)

Make predictions.

Note: The predict method is not available until this operator is trained.

Once this method is available, it will have the following signature:

Parameters

X (array of items : array of items : float) – Features; the outer array is over samples.

Returns

result – Output data schema for predictions.

Return type

Any

predict_proba(X)

Probability estimates for all classes.

Note: The predict_proba method is not available until this operator is trained.

Once this method is available, it will have the following signature:

Parameters

X (array of items : array of items : float) – Features; the outer array is over samples.

Returns

result – Probability of the sample for each class in the model.

Return type

array of items : array of items : float

transform(X, y=None)

Transform the data.

Note: The transform method is not available until this operator is trained.

Once this method is available, it will have the following signature:

Parameters
  • X (array of items : array of items : float) – Features; the outer array is over samples.

  • y (union type) –

    Target class labels; the array is over samples.

    • array of items : float

    • or array of items : string

    • or None

Returns

result – Output data schema for transformed data.

Return type

Any