Giter Site home page Giter Site logo

Comments (3)

edoaltamura avatar edoaltamura commented on July 29, 2024

@adekusar-drl, could you please share an example or template of how you'd match the SKlearn type hinting for QML?

from qiskit-machine-learning.

adekusar-drl avatar adekusar-drl commented on July 29, 2024

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 ArrayLike type hint and it may work. This issue is more exploratory one rather something that can be easily implemented. Even if numpy's hinting is good enough, I'd first double check if such hinting brings in any value, not problems.

from qiskit-machine-learning.

edoaltamura avatar edoaltamura commented on July 29, 2024

For instance

def fit(
self, X: np.ndarray, y: np.ndarray, sample_weight: np.ndarray | None = None
) -> "PegasosQSVC":

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.

from qiskit-machine-learning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.