These common parameter names, specifically used in estimator construction
(see concept parameter), sometimes also appear as parameters of
functions or non-estimator constructors.
class_weightUsed to specify sample weights when fitting classifiers as a function
of the target class. Where sample_weight is also
supported and given, it is multiplied by the class_weight
contribution. Similarly, where class_weight is used in a
multioutput (including multilabel) tasks, the weights
are multiplied across outputs (i.e. columns of y).
By default, all samples have equal weight such that classes are
effectively weighted by their prevalence in the training data.
This could be achieved explicitly with class_weight={label1: 1,
label2: 1, ...} for all class labels.
More generally, class_weight is specified as a dict mapping class
labels to weights ({class_label: weight}), such that each sample
of the named class is given that weight.
class_weight='balanced' can be used to give all classes
equal weight by giving each sample a weight inversely related
to its class’s prevalence in the training data:
n_samples / (n_classes * np.bincount(y)). Class weights will be
used differently depending on the algorithm: for linear models (such
as linear SVM or logistic regression), the class weights will alter the
loss function by weighting the loss of each sample by its class weight.
For tree-based algorithms, the class weights will be used for
reweighting the splitting criterion.
Note however that this rebalancing does not take the weight of
samples in each class into account.
For multioutput classification, a list of dicts is used to specify
weights for each output. For example, for four-class multilabel
classification weights should be [{0: 1, 1: 1}, {0: 1, 1: 5}, {0: 1,
1: 1}, {0: 1, 1: 1}] instead of [{1:1}, {2:5}, {3:1}, {4:1}].
The class_weight parameter is validated and interpreted with
utils.class_weight.compute_class_weight.
cvDetermines a cross validation splitting strategy, as used in
cross-validation based routines. cv is also available in estimators
such as multioutput.ClassifierChain or
calibration.CalibratedClassifierCV which use the predictions
of one estimator as training data for another, to not overfit the
training supervision.
Possible inputs for cv are usually:
kernelSpecifies the kernel function to be used by Kernel Method algorithms.
For example, the estimators svm.SVC and
gaussian_process.GaussianProcessClassifier both have a
kernel parameter that takes the name of the kernel to use as string
or a callable kernel function used to compute the kernel matrix. For
more reference, see the Kernel Approximation and the
Gaussian Processes user guides.
max_iterFor estimators involving iterative optimization, this determines the
maximum number of iterations to be performed in fit. If
max_iter iterations are run without convergence, a
exceptions.ConvergenceWarning should be raised. Note that the
interpretation of “a single iteration” is inconsistent across
estimators: some, but not all, use it to mean a single epoch (i.e. a
pass over every sample in the data).
memorySome estimators make use of joblib.Memory to
store partial solutions during fitting. Thus when fit is called
again, those partial solutions have been memoized and can be reused.
A memory parameter can be specified as a string with a path to a
directory, or a joblib.Memory instance (or an object with a
similar interface, i.e. a cache method) can be used.
memory values are validated and interpreted with
utils.validation.check_memory.
metricAs a parameter, this is the scheme for determining the distance between
two data points. See metrics.pairwise_distances. In practice,
for some algorithms, an improper distance metric (one that does not
obey the triangle inequality, such as Cosine Distance) may be used.
Note: Hierarchical clustering uses affinity with this meaning.
We also use metric to refer to evaluation metrics, but avoid
using this sense as a parameter name.
n_componentsThe number of features which a transformer should transform the
input into. See components_ for the special case of affine
projection.
n_iter_no_changeNumber of iterations with no improvement to wait before stopping the
iterative procedure. This is also known as a patience parameter. It
is typically used with early stopping to avoid stopping too
early.
n_jobsThis parameter is used to specify how many concurrent processes or
threads should be used for routines that are parallelized with
joblib.
n_jobs is an integer, specifying the maximum number of concurrently
running workers. If 1 is given, no joblib parallelism is used at all,
which is useful for debugging. If set to -1, all CPUs are used. For
n_jobs below -1, (n_cpus + 1 + n_jobs) are used. For example with
n_jobs=-2, all CPUs but one are used.
n_jobs is None by default, which means unset; it will
generally be interpreted as n_jobs=1, unless the current
joblib.Parallel backend context specifies otherwise.
Note that even if n_jobs=1, low-level parallelism (via Numpy and OpenMP)
might be used in some configuration.
pos_labelValue with which positive labels must be encoded in binary
classification problems in which the positive class is not assumed.
This value is typically required to compute asymmetric evaluation
metrics such as precision and recall.
random_stateWhenever randomization is part of a Scikit-learn algorithm, a
random_state parameter may be provided to control the random number
generator used. Note that the mere presence of random_state doesn’t
mean that randomization is always used, as it may be dependent on
another parameter, e.g. shuffle, being set.
The passed value will have an effect on the reproducibility of the
results returned by the function (fit, split, or any
other function like k_means). random_state’s
value may be:
- None (default)
Use the global random state instance from numpy.random.
Calling the function multiple times will reuse
the same instance, and will produce different results.
scoringDepending on the object, can specify:
the score function to be maximized (usually by
cross validation),
the multiple score functions to be reported,
the score function to be used to check early stopping, or
for visualization related objects, the score function to output or plot
The score function can be a string accepted
by metrics.get_scorer or a callable scorer, not to be
confused with an evaluation metric, as the latter have a more
diverse API. scoring may also be set to None, in which case the
estimator’s score method is used. See The scoring parameter: defining model evaluation rules
in the User Guide.
Where multiple metrics can be evaluated, may be given
either as a list of unique strings, a dictionary with names as keys and
callables as values or a callable that returns a dictionary. Note that
this does specify which score function is to be maximized, and
another parameter such as may be used for this purpose.
verboseLogging is not handled very consistently in Scikit-learn at present,
but when it is provided as an option, the verbose parameter is
usually available to choose no logging (set to False). Any True value
should enable some logging, but larger integers (e.g. above 10) may be
needed for full verbosity. Verbose logs are usually printed to
Standard Output.
Estimators should not produce any output on Standard Output with the
default verbose setting.
warm_startWhen fitting an estimator repeatedly on the same dataset, but for
multiple parameter values (such as to find the value maximizing
performance as in grid search), it may be possible
to reuse aspects of the model learned from the previous parameter value,
saving time. When warm_start is true, the existing fitted
model attributes are used to initialize the new model
in a subsequent call to fit.
Note that this is only applicable for some models and some
parameters, and even some orders of parameter values. In general, there
is an interaction between warm_start and the parameter controlling
the number of iterations of the estimator.
For estimators imported from ensemble,
warm_start will interact with n_estimators or .
For these models, the number of iterations, reported via
or , corresponds the total number of
estimators/iterations learnt since the initialization of the model.
Thus, if a model was already initialized with estimators, and
is called with or set to , the model
will train new estimators.