-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend type hints in the classifiers and regressors #159
Comments
@adekusar-drl, could you please share an example or template of how you'd match the SKlearn type hinting for QML? |
It has been a low priority for a long time, things might have changed. While scikit learn does not expose type hints by default, one of the possible options to take a look at https://numpy.org/doc/stable/reference/typing.html#module-numpy.typing. Numpy has |
For instance qiskit-machine-learning/qiskit_machine_learning/algorithms/classifiers/pegasos_qsvc.py Lines 128 to 130 in c59063a
would become import numpy.typing as npt
def fit(
self, X: npt.ArrayLike, y: npt.ArrayLike, sample_weight: npt.ArrayLike | None = None
) -> "PegasosQSVC": or, more strictly, import numpy.typing as npt
def fit(
self, X: npt.NDArray[np.float64], y: npt.NDArray[np.float64], sample_weight: npt.NDArray[np.float64] | None = None
) -> "PegasosQSVC": While young, the new typing in Numpy is covered by tests and CI, and made it into a major release. So I'd consider the basic features relatively stable. |
Mypy can also be configured to account for strongly typed Numpy objects as
|
What is the expected behavior?
Since we are going to introduce categorical labels (and perhaps categorical features), I think, we can re-consider type hints for the classifiers and regressors and make them more like in Scikit-Learn:
array_like
. This may allow to pass plain lists or other types. As an example take a look at the interface here: https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.htmlThis issue is just for discussion.
The text was updated successfully, but these errors were encountered: