MCPcopy Create free account
hub / github.com/scikit-learn/scikit-learn / has_fit_parameter

Function has_fit_parameter

sklearn/utils/validation.py:1485–1515  ·  view source on GitHub ↗

Check whether the estimator's fit method supports the given parameter. Parameters ---------- estimator : object An estimator to inspect. parameter : str The searched parameter. Returns ------- is_parameter : bool Whether the parameter was found

(estimator, parameter)

Source from the content-addressed store, hash-verified

1483
1484
1485def has_fit_parameter(estimator, parameter):
1486 """Check whether the estimator's fit method supports the given parameter.
1487
1488 Parameters
1489 ----------
1490 estimator : object
1491 An estimator to inspect.
1492
1493 parameter : str
1494 The searched parameter.
1495
1496 Returns
1497 -------
1498 is_parameter : bool
1499 Whether the parameter was found to be a named parameter of the
1500 estimator's fit method.
1501
1502 Examples
1503 --------
1504 >>> from sklearn.svm import SVC
1505 >>> from sklearn.utils.validation import has_fit_parameter
1506 >>> has_fit_parameter(SVC(), "sample_weight")
1507 True
1508 """
1509 return (
1510 # This is used during test collection in common tests. The
1511 # hasattr(estimator, "fit") makes it so that we don't fail for an estimator
1512 # that does not have a `fit` method during collection of checks. The right
1513 # checks will fail later.
1514 hasattr(estimator, "fit") and parameter in signature(estimator.fit).parameters
1515 )
1516
1517
1518def check_symmetric(array, *, tol=1e-10, raise_warning=True, raise_exception=False):

Callers 11

partial_fitMethod · 0.90
fitMethod · 0.90
_yield_checksFunction · 0.90
_check_array_api_coreFunction · 0.90
test_has_fit_parameterFunction · 0.90
fitMethod · 0.90
_consumes_sample_weightFunction · 0.90
_validate_estimatorMethod · 0.90
test_common.pyFile · 0.90

Calls

no outgoing calls

Tested by 1

test_has_fit_parameterFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…