#! /usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2022/5/23 01:30:30

@author: LiuKuan
@copyright: Apache License, Version 2.0
'''

#===============================================================================
'''     
'''
#===============================================================================
classifier_list = [
    ##### 线性
    'RidgeClassifier',
    'LogisticRegression', 'LogisticRegressionCV',
    'SGDClassifier',
    'Perceptron',
    'PassiveAggressiveClassifier',
    'SGDOneClassSVM',

    ##### 判别分析
    'LinearDiscriminantAnalysis', 'QuadraticDiscriminantAnalysis',

    ##### SVM
    'SVC', 'NuSVC', 'LinearSVC', 'OneClassSVM',

    ##### KNN
    'KNeighborsClassifier', 'RadiusNeighborsClassifier',
    'NearestCentroid',

    ##### 高斯处理
    'GaussianProcessClassifier',

    ##### 贝叶斯
    "BernoulliNB", "GaussianNB", "MultinomialNB", "ComplementNB", "CategoricalNB",

    ##### 决策树
    'DecisionTreeClassifier', 'ExtraTreeClassifier',

    ##### 集成方法
    "RandomForestClassifier", "ExtraTreesClassifier", "BaggingClassifier",
    "IsolationForest", "GradientBoostingClassifier", "AdaBoostClassifier",
    "VotingClassifier", "StackingClassifier", "HistGradientBoostingClassifier",

    ##### 神经网络
    'MLPClassifier','',
]

def get_classifier(_name = "SVC", **kws):
    name = _name.lower()
    if name == 'RidgeClassifier'.lower():
        from sklearn.linear_model import RidgeClassifier as Alg
    elif name == 'LogisticRegression'.lower():
        from sklearn.linear_model import LogisticRegression as Alg
    elif name == 'LogisticRegressionCV'.lower():
        from sklearn.linear_model import LogisticRegressionCV as Alg
    elif name == 'SGDClassifier'.lower():
        from sklearn.linear_model import SGDClassifier as Alg
    elif name == 'Perceptron'.lower():
        from sklearn.linear_model import Perceptron as Alg
    elif name == 'PassiveAggressiveClassifier'.lower():
        from sklearn.linear_model import PassiveAggressiveClassifier as Alg
    elif name == 'SGDOneClassSVM'.lower():
        from sklearn.linear_model import SGDOneClassSVM as Alg

    elif name == 'LinearDiscriminantAnalysis'.lower():
        from sklearn.discriminant_analysis import LinearDiscriminantAnalysis as Alg
    elif name == 'QuadraticDiscriminantAnalysis'.lower():
        from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis as Alg

    elif name == 'SVC'.lower():
        from sklearn.svm import SVC as Alg
    elif name == 'NuSVC'.lower():
        from sklearn.svm import NuSVC as Alg
    elif name == 'LinearSVC'.lower():
        from sklearn.svm import LinearSVC as Alg
    elif name == 'OneClassSVM'.lower():
        from sklearn.svm import OneClassSVM as Alg

    elif name == 'KNeighborsClassifier'.lower():
        from sklearn.neighbors import KNeighborsClassifier as Alg
    elif name == 'RadiusNeighborsClassifier'.lower():
        from sklearn.neighbors import RadiusNeighborsClassifier as Alg
    elif name == 'NearestCentroid'.lower():
        from sklearn.neighbors import NearestCentroid as Alg

    elif name == 'GaussianProcessClassifier'.lower():
        from sklearn.gaussian_process import GaussianProcessClassifier as Alg

    elif name == 'BernoulliNB'.lower():
        from sklearn.naive_bayes import BernoulliNB as Alg
    elif name == 'GaussianNB'.lower():
        from sklearn.naive_bayes import GaussianNB as Alg
    elif name == 'MultinomialNB'.lower():
        from sklearn.naive_bayes import MultinomialNB as Alg
    elif name == 'ComplementNB'.lower():
        from sklearn.naive_bayes import ComplementNB as Alg
    elif name == 'CategoricalNB'.lower():
        from sklearn.naive_bayes import CategoricalNB as Alg

    elif name == 'DecisionTreeClassifier'.lower():
        from sklearn.tree import DecisionTreeClassifier as Alg    
    elif name == 'ExtraTreeClassifier'.lower():
        from sklearn.tree import ExtraTreeClassifier as Alg    

    elif name == 'RandomForestClassifier'.lower():
        from sklearn.tree import RandomForestClassifier as Alg    
    elif name == 'ExtraTreesClassifier'.lower():
        from sklearn.tree import ExtraTreesClassifier as Alg    
    elif name == 'BaggingClassifier'.lower():
        from sklearn.tree import BaggingClassifier as Alg    
    elif name == 'IsolationForest'.lower():
        from sklearn.tree import IsolationForest as Alg    
    elif name == 'GradientBoostingClassifier'.lower():
        from sklearn.tree import GradientBoostingClassifier as Alg    
    elif name == 'AdaBoostClassifier'.lower():
        from sklearn.tree import AdaBoostClassifier as Alg    
    elif name == 'VotingClassifier'.lower():
        from sklearn.tree import VotingClassifier as Alg    
    elif name == 'StackingClassifier'.lower():
        from sklearn.tree import StackingClassifier as Alg           
    elif name == 'HistGradientBoostingClassifier'.lower():
        from sklearn.tree import HistGradientBoostingClassifier as Alg       

    elif name == 'MLPClassifier'.lower():
        from sklearn.neural_network import MLPClassifier as Alg     
    else:
        raise RuntimeError("Cann't create {}".format(_name))

    return Alg(**kws)


