#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals


import logging.config

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


def train(tainted_groups, save_dir=None):
    """Interface"""
    logger = logging.getLogger(__name__)
    logger.info("[Number] Total number of training set: {number}".format(
        number=len(tainted_groups)))

    core = operations.train.Core()
    core.train(tainted_groups)
    logger = logging.getLogger(__name__)
    if save_dir:
        logger.debug("[save_dir]" + save_dir)
        core.save(save_dir)
    return tainted_groups


def main(test_percentage=0.1, data_set_path=None, shuffle=False, save_dir=None):
    """Main example"""
    logger = logging.getLogger(__name__)
    logger.info("[Start] Start training")
    data = components.data.complete_set(data_set_path)
    tainted_groups_train, tainted_groups_test = components.data.split_set(
        data, test_percentage, shuffle=shuffle)

    logger.info("tainted_groups_train:"+str(len(tainted_groups_train)))
    logger.info("tainted_groups_test:"+str(len(tainted_groups_test)))


