#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import logging.config

from config.constant import Values
import components.data
import operations.predict


def print_predict(predicted):
    logger = logging.getLogger(__name__)
    logger.info("[Result] Predict result")
    for i, group in enumerate(predicted):
        logger.info("[Id] {id}".format(id=i))
        logger.info("[Input] {group}".format(group=str(group)))
        logger.info("[Predicted]  {predicted}".format(
            predicted=predicted[i].prediction))
        logger.info("[Actual] {result}".format(result=group.label.name))


def predict(tainted_groups, load_path=None):
    """Interface"""
    logger = logging.getLogger(__name__)
    logger.debug("[Number] Total number to predict: {number}".format(
        number=len(tainted_groups)))
    load_path = load_path or Values.prediction_model_directory
    core = operations.predict.Core()
    core = core.load(load_path)

    predicted = core.predict(tainted_groups)

    return predicted
