# Path: moloi/descriptors/rdkit_descriptor.py
# def rdkit_fetures_names():
#     DESCRIPTORS = {_camel_to_snail(s): f for (s, f) in Descriptors.descList}
#     return DESCRIPTORS.keys()
# 
# Path: moloi/descriptors/mordred_descriptor.py
# def mordred_fetures_names():
#     calc = Calculator(descriptors)
#     cols = []
#     for i in calc.descriptors:
#         i = str(i)
#         i = i.split(".")[-1]
#         cols.append(str(i))
#     return cols
# 
# Path: moloi/data_processing.py
# def m_mean(a, column):
#     """
#     for feature importance
#     """
#     mean = np.mean(a.T[column])
#     for i in range(len(a)):
#         a[i][column] = mean
#     return a


import os
import pylab
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib as mlp
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from mpl_toolkits.mplot3d import Axes3D # keep it
from sklearn.metrics import roc_auc_score, roc_curve, r2_score, mean_absolute_error
from sklearn.decomposition import PCA
from sklearn.manifold import TSNE
from joblib import Parallel, delayed
from joblib.parallel import BACKENDS
from moloi.descriptors.rdkit_descriptor import rdkit_fetures_names
from moloi.descriptors.mordred_descriptor import mordred_fetures_names
from moloi.data_processing import m_mean
                values = np.array(values)
                set_red = False
                if len(np.unique(names)) > 2:
                    if values[0] == max(values):
                        set_red = str(names[0])
                    if values[-1] == max(values):
                        set_red = str(names[-1])

                names = [str(i) for i in table[c]]
                barlist = plt.bar(names, score["mean_test_score"], label=c, color='g', alpha=0.3)
                if set_red:
                    barlist[names.index(set_red)].set_color('r')
                plt.xticks(rotation=45)
                plt.ylabel("mean_test_score")
                plt.title(c)
                fig.tight_layout()
            except ValueError:
                pass

            plt.savefig(path+'img/grid_'+c+'.png', dpi=150)
            plt.clf()
            plt.cla()
            plt.close()
    except:
        logger.info("Can't plot gridsearch for this experiment")


def col(i):
    if 'morgan' in i:
        return 'r'

# Path: moloi/descriptors/rdkit_descriptor.py
# def rdkit_fetures_names():
#     DESCRIPTORS = {_camel_to_snail(s): f for (s, f) in Descriptors.descList}
#     return DESCRIPTORS.keys()
# 
# Path: moloi/descriptors/mordred_descriptor.py
# def mordred_fetures_names():
#     calc = Calculator(descriptors)
#     cols = []
#     for i in calc.descriptors:
#         i = str(i)
#         i = i.split(".")[-1]
#         cols.append(str(i))
#     return cols
# 
# Path: moloi/data_processing.py
# def m_mean(a, column):
#     """
#     for feature importance
#     """
#     mean = np.mean(a.T[column])
#     for i in range(len(a)):
#         a[i][column] = mean
#     return a


# Path: moloi/plots.py
import os
import pylab
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib as mlp
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from mpl_toolkits.mplot3d import Axes3D # keep it
from sklearn.metrics import roc_auc_score, roc_curve, r2_score, mean_absolute_error
from sklearn.decomposition import PCA
from sklearn.manifold import TSNE
from joblib import Parallel, delayed
from joblib.parallel import BACKENDS
from moloi.descriptors.rdkit_descriptor import rdkit_fetures_names
from moloi.descriptors.mordred_descriptor import mordred_fetures_names
from moloi.data_processing import m_mean

                values = np.array(values)
                set_red = False
                if len(np.unique(names)) > 2:
                    if values[0] == max(values):
                        set_red = str(names[0])
                    if values[-1] == max(values):
                        set_red = str(names[-1])

                names = [str(i) for i in table[c]]
                barlist = plt.bar(names, score["mean_test_score"], label=c, color='g', alpha=0.3)
                if set_red:
                    barlist[names.index(set_red)].set_color('r')
                plt.xticks(rotation=45)
                plt.ylabel("mean_test_score")
                plt.title(c)
                fig.tight_layout()
            except ValueError:
                pass

            plt.savefig(path+'img/grid_'+c+'.png', dpi=150)
            plt.clf()
            plt.cla()
            plt.close()
    except:
        logger.info("Can't plot gridsearch for this experiment")


def col(i):
    if 'morgan' in i:
        return 'r'

    if i in mordred_fetures_names():