"""
Cause-effect models.

"""

# Author: Jose A. R. Fonollosa <jarfo@yahoo.com>
#
# License: Apache, Version 2.0

from multiprocessing import Pool

import numpy as np
from sklearn import pipeline
from sklearn.base import BaseEstimator
from sklearn.ensemble import GradientBoostingClassifier

import features as f

gbc_params = {
    'loss':'deviance',
    'learning_rate': 0.1,
    'n_estimators': 500,
    'subsample': 1.0,
    'min_samples_split': 8,
    'min_samples_leaf': 1,
    'max_depth': 9,
    'init': None,
    'random_state': 1,
    'max_features': None,
    'verbose': 0
    }

selected_features = [
    'Adjusted Mutual Information[A,A type,B,B type]',
    'Conditional Distribution Entropy Variance[A,A type,B,B type]',
    'Conditional Distribution Entropy Variance[B,B type,A,A type]',
    'Conditional Distribution Kurtosis Variance[A,A type,B,B type]',
    'Conditional Distribution Kurtosis Variance[B,B type,A,A type]',
    'Conditional Distribution Similarity[A,A type,B,B type]',
    'Conditional Distribution Similarity[B,B type,A,A type]',
    'Conditional Distribution Skewness Variance[A,A type,B,B type]',
    'Conditional Distribution Skewness Variance[B,B type,A,A type]',
    'Discrete Conditional Entropy[A,A type,B,B type]',
    'Discrete Conditional Entropy[B,B type,A,A type]',
    'Discrete Entropy[A,A type]',
    'Discrete Entropy[B,B type]',
    'Discrete Mutual Information[A,A type,B,B type]',
    'HSIC[A,A type,B,B type]',
    'IGCI[A,A type,B,B type]',
    'IGCI[B,B type,A,A type]',
    'Kurtosis[A,A type]',
    'Kurtosis[B,B type]',
    'Log[Number of Samples[A]]',
    'Log[Number of Unique Samples[A]]',
    'Log[Number of Unique Samples[B]]',
    'Moment21[A,A type,B,B type]',
    'Moment21[B,B type,A,A type]',
    'Moment31[A,A type,B,B type]',
    'Moment31[B,B type,A,A type]',
    'Normalized Discrete Entropy[A,A type]',
    'Normalized Discrete Entropy[B,B type]',
    'Normalized Discrete Mutual Information[Discrete Mutual Information[A,A type,B,B type],Discrete Joint Entropy[A,A type,B,B type]]',
    'Normalized Discrete Mutual Information[Discrete Mutual Information[A,A type,B,B type],Min[Discrete Entropy[A,A type],Discrete Entropy[B,B type]]]',
    'Normalized Entropy[A,A type]',
    'Normalized Entropy[B,B type]',
    'Normalized Error Probability[A,A type,B,B type]',
    'Normalized Error Probability[B,B type,A,A type]',
#    'Number of Unique Samples[A]',
#    'Number of Unique Samples[B]',
    'Pearson R[A,A type,B,B type]',
    'Polyfit Error[A,A type,B,B type]',
    'Polyfit Error[B,B type,A,A type]',
    'Polyfit[A,A type,B,B type]',
    'Polyfit[B,B type,A,A type]',
    'Skewness[A,A type]',