Beispiel #1
0

for msg in new_pc.consumer:
    """
    "name": "Data",
    "fields": [
        {"name": "phase", "type": ["string"]},
        {"name": "id_x", "type": ["int"]},
        {"name": "x", "type": ["float"]},
        {"name": "y", "type": ["float"]}
        ]
    """
    new_data = new_pc.decode_avro_msg(msg)

    """
    "name": "Data",
    "fields": [
        {"name": "phase", "type": ["string"]},
        {"name": "id_x", "type": ["int"]},
        {"name": "x", "type": ["float"]},
        {"name": "y", "type": ["float"]}
        ]
    """

    new_data_point = {'phase': new_data['phase'],
                      'id': new_data['id'],
                      'x': new_data['x'],
                      'y': new_data['y']}

    new_pc.send_msg(new_data_point)
            {"name": "phase", "type": ["enum"], "symbols": ["init", "observation"]},
            {"name": "model_name", "type": ["string"]},
            {"name": "n_data_points", "type": ["int"]},
            {"name": "id_start_x", "type": ["int"]},
            {"name": "model", "type": ["bytes"]},
            {"name": "model_size", "type": ["int"]},
            {"name": "rmse", "type": ["null, float"]},
            {"name": "mae", "type": ["null, float"]},
            {"name": "rsquared", "type": ["null, float"]},
            {"name": "CPU_ms", "type": ["float"]},
            {"name": "RAM", "type": ["float"]}
            ]
        """

        model_data = {
            'phase': new_data['phase'],
            'model_name': MODEL_ALGORITHM,
            'id': new_data['id'],
            'n_data_points': len(X),
            'id_start_x': id_start_x,
            'model': model_pickle,
            'model_size': getsizeof(model_pickle),
            'rmse': rmse_score,
            'mae': mae_score,
            'rsquared': r2_score,
            'CPU_ms': real_time,
            'RAM': peak_mb
        }

        new_pc.send_msg(model_data)