Git Product home page Git Product logo

Comments (5)

blythed avatar blythed commented on May 25, 2024
@dc.dataclass
class InputNode:
    name: str


class Inputs:
    def __init__(self, fn):
        self.params = inspect.signature(fn).parameters

    def __getattr__(self, item):
        assert item in self.params
        return InputNode(item)
    
 
class _Predictor:
    @property
    def inputs(self) -> Inputs:
        ...
     

from superduperdb.

blythed avatar blythed commented on May 25, 2024

What should the signature of .predict look like?

If we had named inputs, we could create Listener which "listens" to specific keys.

Idea: X: t.Optional[t.List[t.Any], t.Dict[str, t.Any], t.Any].

Variants:

def my_func(x, y, z):
    ...

model = Model('test', object=my_func)

# both should work
out1 = model.predict(X={'y': 2, 'x': 3, 'z': 'bla'}, one=True)
out2 = model.predict((3, 2, 'bla'), one=True)

assert out1 == out2

Listener creation could be more precise and similar

# both fine
l = Listener(model=model, key={'y': 'text', 'x': 'image', 'z': 'text2'})
l = Listener(model=model, key=('text', 'image', 'text2'))

# raises `InputException`
l = Listener(model=model, key=('text', 'image'))

What happens to _base? This can only make sense if a model has one input.

def process_document(r):
    ...   # do anything with all keys

In MongoDB there might be different numbers of keys per document in no particular order.
For SQL only, we might say _base means that the model gets all columns apart from the id column.

How about syntactic sugar?

l = Listener(model=model, key='*', select=...)
print(l.key)
# ('txt', 'bla', '...') - gets extracted from select.table_or_collection

from superduperdb.

blythed avatar blythed commented on May 25, 2024

What about outputs object?

class Outputs:
    def __getitem__(self, item: int):
        assert isinstance(item, int)
        return OutputNode(item)

Then in GraphModel we can have different variants:

G.add_edge(model.outputs[0], other.inputs.x)
G.add_edge(model.outputs, other.inputs)
G.add_edge(model.outputs, other.inputs.x)
G.add_edge(model.outputs[0], other.inputs)

from superduperdb.

blythed avatar blythed commented on May 25, 2024

Also we should do some nice pretty-printing of Model information so that developers "know"
what parameters we have for a model.

from superduperdb.

blythed avatar blythed commented on May 25, 2024

Subtasks:

  • Refactor ._predict as _predict(self, X, dataset, ...)
  • Add input and output nodes to _Predictor
  • Connect input and output nodes with Listener and predict(X, db=db)

from superduperdb.

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.