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

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

#===============================================================================
'''     
'''
#===============================================================================
regress_list = [

    ##### 线性回归
    'LinearRegression',
    'Ridge', 'RidgeCV',
    'Lasso', 'LassoCV',
    'LassoLars', 'LassoLarsCV', 'LassoLarsIC', # 最小角度回归
    'ElasticNet', 'ElasticNetCV',
    'SGDRegressor',
    'OrthogonalMatchingPursuit', 'OrthogonalMatchingPursuitCV', #正交匹配追踪算法（OMP）
    'BayesianRidge', 'ARDRegression',
    'TweedieRegressor', 'PoissonRegressor', 'GammaRegressor',
    'RANSACRegressor','HuberRegressor','TheilSenRegressor',
    'QuantileRegressor',

    ##### 核岭回归
    'KernelRidge',

    ##### SVM
    'SVR', 'NuSVR', 'LinearSVR',

    ##### 随机梯度下降
    'SGDRegressor',

    ##### KNN
    'KNeighborsRegressor', 'RadiusNeighborsRegressor',

    ##### 高斯处理
    'GaussianProcessRegressor', 

    ##### 交叉分解
    'PLSRegression', 'PLSCanonical',

    ##### 决策树
    'DecisionTreeRegressor','ExtraTreeRegressor',

    ##### 集成方法
    'RandomForestRegressor', 'ExtraTreesRegressor', 'BaggingRegressor', 
    'GradientBoostingRegressor', 'AdaBoostRegressor', 'VotingRegressor',
    'StackingRegressor', 'HistGradientBoostingRegressor', 

    ##### Isotonic
    'IsotonicRegression', 
    
    ##### 神经网络
    'MLPRegressor', 
]

def get_regress(_name = "Ridge", **kws):
    name = _name.lower()
    if name == 'LinearRegression'.lower():
        from sklearn.linear_model import LinearRegression as Alg
    elif name == 'Ridge'.lower():
        from sklearn.linear_model import Ridge as Alg
    elif name == 'RidgeCV'.lower():
        from sklearn.linear_model import RidgeCV as Alg
    elif name == 'Lasso'.lower():
        from sklearn.linear_model import Lasso as Alg
    elif name == 'LassoCV'.lower():
        from sklearn.linear_model import LassoCV as Alg
    elif name == 'LassoLars'.lower():
        from sklearn.linear_model import LassoLars as Alg
    elif name == 'LassoLarsCV'.lower():
        from sklearn.linear_model import LassoLarsCV as Alg
    elif name == 'LassoLarsIC'.lower():
        from sklearn.linear_model import LassoLarsIC as Alg
    elif name == 'ElasticNet'.lower():
        from sklearn.linear_model import ElasticNet as Alg
    elif name == 'ElasticNetCV'.lower():
        from sklearn.linear_model import ElasticNetCV as Alg

    elif name == 'SGDRegressor'.lower():
        from sklearn.linear_model import SGDRegressor  as Alg

    elif name == 'OrthogonalMatchingPursuit'.lower():
        from sklearn.linear_model import OrthogonalMatchingPursuit as Alg
    elif name == 'OrthogonalMatchingPursuitCV'.lower():
        from sklearn.linear_model import OrthogonalMatchingPursuitCV as Alg

    elif name == 'BayesianRidge'.lower():
        from sklearn.linear_model import BayesianRidge as Alg
    elif name == 'ARDRegression'.lower():
        from sklearn.linear_model import ARDRegression as Alg

    elif name == 'TweedieRegressor'.lower():
        from sklearn.linear_model import TweedieRegressor as Alg
    elif name == 'PoissonRegressor'.lower():
        from sklearn.linear_model import PoissonRegressor as Alg
    elif name == 'GammaRegressor'.lower():
        from sklearn.linear_model import GammaRegressor as Alg

    elif name == 'RANSACRegressor'.lower():
        from sklearn.linear_model import RANSACRegressor  as Alg
    elif name == 'HuberRegressor'.lower():
        from sklearn.linear_model import HuberRegressor  as Alg
    elif name == 'TheilSenRegressor'.lower():
        from sklearn.linear_model import TheilSenRegressor  as Alg
    elif name == 'QuantileRegressor'.lower():
        from sklearn.linear_model import QuantileRegressor  as Alg


    elif name == 'KernelRidge'.lower():
        from sklearn.kernel_ridge import KernelRidge  as Alg

    elif name == 'SVR'.lower():
        from sklearn.svm import SVR  as Alg
    elif name == 'NuSVR'.lower():
        from sklearn.svm import NuSVR  as Alg
    elif name == 'LinearSVR'.lower():
        from sklearn.svm import LinearSVR  as Alg

    elif name == 'KNeighborsRegressor'.lower():
        from sklearn.neighbors import KNeighborsRegressor as Alg
    elif name == 'RadiusNeighborsRegressor'.lower():
        from sklearn.neighbors import RadiusNeighborsRegressor as Alg

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

    elif name == 'PLSRegression'.lower():
        from sklearn.cross_decomposition import PLSRegression as Alg    
    elif name == 'PLSCanonical'.lower():
        from sklearn.cross_decomposition import PLSCanonical as Alg    

    elif name == 'DecisionTreeRegressor'.lower():
        from sklearn.tree import DecisionTreeRegressor as Alg    
    elif name == 'ExtraTreeRegressor'.lower():
        from sklearn.tree import ExtraTreeRegressor as Alg    
    
    elif name == 'RandomForestRegressor'.lower():
        from sklearn.ensemble import RandomForestRegressor as Alg
    elif name == 'ExtraTreesRegressor'.lower():
        from sklearn.ensemble import ExtraTreesRegressor as Alg
    elif name == 'BaggingRegressor'.lower():
        from sklearn.ensemble import BaggingRegressor as Alg
    elif name == 'GradientBoostingRegressor'.lower():
        from sklearn.ensemble import GradientBoostingRegressor as Alg
    elif name == 'AdaBoostRegressor'.lower():
        from sklearn.ensemble import AdaBoostRegressor as Alg
    elif name == 'VotingRegressor'.lower():
        from sklearn.ensemble import VotingRegressor as Alg
    elif name == 'StackingRegressor'.lower():
        from sklearn.ensemble import StackingRegressor as Alg
    elif name == 'HistGradientBoostingRegressor'.lower():
        from sklearn.ensemble import HistGradientBoostingRegressor as Alg             

    elif name == 'IsotonicRegression'.lower():
        from sklearn.isotonic import IsotonicRegression as Alg     
        
    elif name == 'MLPRegressor'.lower():
        from sklearn.neural_network import MLPRegressor as Alg

    else:
        raise RuntimeError("Cann't create {}".format(_name))

    return Alg(**kws)
