#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2022/5/11 21:54:21

@author: LiuKuan
@copyright: Apache License, Version 2.0
'''
#===============================================================================
'''  包装了 sklearn所支持的聚类算法
'''
#===============================================================================

cluster_list = [
    'AffinityPropagation',
    'Agglomerative',
    'Birch',
    'DBScan',
    'DBScan_daal'
    'GaussianMixture',
    'BayesianGaussianMixture',
    'KMeans',
    'KMeans_daal',
    'KMeansBisecting',
    'KMeansMiniBatch',
    'MeanShift',
    'OPTICS',
    'Spectral',
    'SpectralBiing',
    'SpectralCoing'
]

def get_cluster(_name = "KMeans", **kws):
    name = _name.lower()
    if name == 'AffinityPropagation'.lower():
        from sklearn.cluster import AffinityPropagation as Alg
    elif name == 'Agglomerative'.lower():
        from sklearn.cluster import AgglomerativeClustering as Alg
    elif name == 'Birch'.lower():
        from sklearn.cluster import Birch as Alg
    elif name == 'DBScan'.lower():
        from sklearn.cluster import DBSCAN as Alg
    elif name == 'DBScan_daal'.lower(): 
        from daal4py.sklearn.cluster import DBSCAN as Alg
    elif name == 'GaussianMixture'.lower(): 
        from sklearn.mixture import GaussianMixture as Alg
    elif name == 'BayesianGaussianMixture'.lower(): 
        from sklearn.mixture import BayesianGaussianMixture as Alg
    elif name == 'KMeans'.lower(): 
        from sklearn.cluster import KMeans as Alg
    elif name == 'KMeans_daal'.lower(): 
        from daal4py.sklearn.cluster import KMeans as Alg
    elif name == 'KMeansBisecting'.lower(): 
        from sklearn.cluster import BisectingKMeans as Alg
    elif name == 'KMeansMiniBatch'.lower(): 
        from sklearn.cluster import MiniBatchKMeans as Alg
    elif name == 'MeanShift'.lower(): 
        from sklearn.cluster import MeanShift as Alg
    elif name == 'OPTICS'.lower(): 
        from sklearn.cluster import OPTICS as Alg
    elif name == 'Spectral'.lower(): 
        from sklearn.cluster import SpectralClustering as Alg
    elif name == 'SpectralBiing'.lower(): 
        from sklearn.cluster import SpectralBiclustering as Alg
    elif name == 'SpectralCoing'.lower(): 
        from sklearn.cluster import SpectralCoclustering as Alg
    else:
        raise RuntimeError("Cann't create {}".format(_name))

    return Alg(**kws)


