def __init__(self, requirements, model_type): self.id = str(uuid.uuid1()) self.model_type = model_type self.requirements = requirements self.model = ModelFactory.get_model(model_type)() self.request_data = None self.status = OrderedModelStatus.INITIATED
def process(value): model_data = json.loads(value) x = np.asarray(model_data['x']) y = np.asarray(model_data['y']) model_type = model_data['type'] weights = np.asarray(model_data['weights']) model = ModelFactory.get_model(model_type)(X=x, y=y, weights=weights) return model
def process(self, model_type, public_key): """ Process to run model :param requirements: :param public_key: :return: """ self.encryption_service.set_public_key(public_key) X, y = self.data_loader.get_sub_set() self.model = self.model if self.model else ModelFactory.get_model(model_type)(X, y) return self.model.compute_gradient().tolist()
def __init__(self, model_type, name="default", requirements=None, payments=None): self.id = str(uuid.uuid1()) self.model_type = model_type self.model = ModelFactory.get_model(model_type)(requirements=requirements) self.model.type = model_type self.status = BuyerModelStatus.INITIATED.name self.name = name self.iterations = 0 self.improvement = 0.0 self.mse = 0.0 self.cost = 0.0 self.mse_history = [] self.diffs = [] self.partial_diffs = {} self.payments = payments
def __init__(self, model_id, model_type, reqs, name="default"): self.id = model_id self.model_type = model_type _model = ModelFactory.get_model(self.model_type)(X=None, y=None, requirements=reqs) self.model = _model self.model.set_weights(_model.weights.tolist()) self.model.type = self.model_type self.requirements = reqs self.status = TrainingStatus.WAITING.name self.iterations = 0 self.improvement = 0.0 self.name = name self.earned = 0.0 self.role = "None" self.mse = 0.0 self.initial_mse = 0.0 self.mse_history = []
def link_to_dataset(self, data): _model = ModelFactory.get_model(self.model_type)(X=data[0], y=data[1]) self.model = _model self.status = TrainingStatus.INITIATED.name self.update()