Пример #1
0
    def __findBestModel(self, model: str) -> str:
        pred = Predictor()

        pdHandler = PrometheusDataHandler(model)

        data = pdHandler.get_data()
        results = {}

        count = 0.0
        logging.debug("Running findBestModel in SimpleLoadBalance")
        #data = { ip, vals }
        for ip in data:
            # data_values = [ (name,value) ]
            values = data[ip]
            data_values = pred.accuracy(values)
            for r in data_values:
                # print(r)
                try:
                    results[r[1]] += r[0]
                    #some times it is better to ask for forgiveness than permission :)
                except KeyError as e:
                    results[r[1]] = r[0]
            count += 1.0

        ##
        #Here we take the average between all of the nodes
        ##
        for k in results.keys():
            val = results[k]
            results[k] = val / count

        order_acc = sorted(results.items(), key=operator.itemgetter(1))
        return order_acc[0][0]
Пример #2
0
	def process(self, request):
		model = request['model']
		pdHandler = PrometheusDataHandler(model)
		data = pdHandler.get_data()

		pred = Predictor()
		for ip in data:
			values = data[ip]
			self.data_[ip] = pred.accuracy(values)