# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
import jubatus
import jubatus.embedded
from .base import GenericSchema, BaseDataset, BaseService, GenericConfig
from .compat import *
[docs]class Schema(GenericSchema):
"""
Schema for Weight service.
"""
pass
[docs]class Dataset(BaseDataset):
"""
Dataset for Weight service.
"""
@classmethod
def _predict(cls, row):
return Schema.predict(row, False)
[docs]class Weight(BaseService):
"""
Weight service.
"""
[docs] @classmethod
def name(cls):
return 'weight'
@classmethod
def _client_class(cls):
return jubatus.weight.client.Weight
@classmethod
def _embedded_class(cls):
return jubatus.embedded.Weight
[docs] def update(self, dataset):
"""
Updates the weight using the given dataset and returns extracted feature vectors.
"""
cli = self._client()
for (idx, d) in dataset:
result = cli.update(d)
yield (idx, result)
[docs] def calc_weight(self, dataset):
"""
Returns extracted feature vectors, without modifying the weight model.
"""
cli = self._client()
for (idx, d) in dataset:
result = cli.calc_weight(d)
yield (idx, result)
[docs]class Config(GenericConfig):
"""
Configuration to run Weight service.
"""
[docs] @classmethod
def methods(cls):
return [None]
@classmethod
def _default_method(cls):
return None
@classmethod
def _default_parameter(cls, method):
return None