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)
| 1483 | |
| 1484 | |
| 1485 | def 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 | |
| 1518 | def check_symmetric(array, *, tol=1e-10, raise_warning=True, raise_exception=False): |
no outgoing calls
searching dependent graphs…