# Path: percept/fields/base.py
# class Complex(ValueField):
#     """
#     Store complex objects, such as classes
#     """
#     def to_json(self, value):
#         return pickle.dumps(value)
# 
#     def from_json(self, value):
#         try:
#             new_value = pickle.loads(value)
#         except Exception:
#             log.exception("Could not unpickle value. : {0}".format(value))
#             new_value = None
#         return new_value
# 
# class List(ValueField):
#     """
#     Store lists
#     """
#     default = []
# 
# class Float(ValueField):
#     """
#     Store float values
#     """
#     def from_json(self, value):
#         try:
#             new_value = float(json.loads(value))
#         except Exception:
#             new_value = None
#         return new_value
# 
# Path: percept/conf/base.py
# class Settings(object):
#     def _initialize(self, settings_module):
#     def _setup(self):
#     def __getattr__(self, name):
#     def _configure_logging(self):
#     def configured(self):
# 
# Path: percept/utils/models.py
# class RegistryCategories(object):
#     """
#     Define valid registry categories
#     """
#     base = "base"
#     preprocessors = "preprocessors"
#     inputs = "inputs"
#     formatters = "formatters"
#     algorithms = "algorithms"
#     workflows = "workflows"
# 
# def get_namespace(mod):
#     return mod.split('.')[0]
# 
# Path: percept/utils/input.py
# class DataFormats(object):
#     """
#     Define acceptable data formats
#     """
#     csv = "csv"
#     dataframe = "dataframe"


from base import Task
from percept.fields.base import Complex, List, Float
from percept.conf.base import settings
from percept.utils.models import RegistryCategories, get_namespace
from percept.utils.input import DataFormats
from itertools import chain
import numpy as np
import os
import math
import random
import pandas as pd
"""
Structures to validate and estimate error
"""


def make_df(datalist, labels, name_prefix=""):
    df = pd.DataFrame(datalist).T
    if name_prefix!="":
        labels = [name_prefix + "_" + l for l in labels]
    labels = [l.replace(" ", "_").lower() for l in labels]
    df.columns = labels
    df.index = range(df.shape[0])
    return df

class Validate(Task):
    data = Complex()
    results = Complex()
    error = Float()

# Path: percept/fields/base.py
# class Complex(ValueField):
#     """
#     Store complex objects, such as classes
#     """
#     def to_json(self, value):
#         return pickle.dumps(value)
# 
#     def from_json(self, value):
#         try:
#             new_value = pickle.loads(value)
#         except Exception:
#             log.exception("Could not unpickle value. : {0}".format(value))
#             new_value = None
#         return new_value
# 
# class List(ValueField):
#     """
#     Store lists
#     """
#     default = []
# 
# class Float(ValueField):
#     """
#     Store float values
#     """
#     def from_json(self, value):
#         try:
#             new_value = float(json.loads(value))
#         except Exception:
#             new_value = None
#         return new_value
# 
# Path: percept/conf/base.py
# class Settings(object):
#     def _initialize(self, settings_module):
#     def _setup(self):
#     def __getattr__(self, name):
#     def _configure_logging(self):
#     def configured(self):
# 
# Path: percept/utils/models.py
# class RegistryCategories(object):
#     """
#     Define valid registry categories
#     """
#     base = "base"
#     preprocessors = "preprocessors"
#     inputs = "inputs"
#     formatters = "formatters"
#     algorithms = "algorithms"
#     workflows = "workflows"
# 
# def get_namespace(mod):
#     return mod.split('.')[0]
# 
# Path: percept/utils/input.py
# class DataFormats(object):
#     """
#     Define acceptable data formats
#     """
#     csv = "csv"
#     dataframe = "dataframe"


# Path: percept/tasks/validate.py
from base import Task
from percept.fields.base import Complex, List, Float
from percept.conf.base import settings
from percept.utils.models import RegistryCategories, get_namespace
from percept.utils.input import DataFormats
from itertools import chain
import numpy as np
import os
import math
import random
import pandas as pd

"""
Structures to validate and estimate error
"""


def make_df(datalist, labels, name_prefix=""):
    df = pd.DataFrame(datalist).T
    if name_prefix!="":
        labels = [name_prefix + "_" + l for l in labels]
    labels = [l.replace(" ", "_").lower() for l in labels]
    df.columns = labels
    df.index = range(df.shape[0])
    return df

class Validate(Task):
    data = Complex()
    results = Complex()
    error = Float()

    importances = Complex()