【问题标题】:Lasso Regression: The continuous heavy step functionLasso 回归:连续重步函数
【发布时间】:2019-10-16 15:52:02
【问题描述】:

从许多文档中,我了解到岭回归的秘诀是:

loss_Ridge = loss_function + lambda x L2 norm of slope

Lasso 回归的秘诀是:

loss_Lasso = loss_function + lambda x L1 norm of slope

当我在“TensorFlow Machine Learning Cookbook”中阅读主题“实现套索和岭回归”时,其作者解释说:

"...我们将使用阶跃函数的连续逼近,称为 连续重阶跃函数..."

它的作者还提供了代码行here。 我不明白在这种情况下哪个被称为“连续重阶跃函数”。请帮帮我。

【问题讨论】:

    标签: python tensorflow machine-learning lasso-regression


    【解决方案1】:

    从您提供的链接中,

    if regression_type == 'LASSO':
        # Declare Lasso loss function
        # Lasso Loss = L2_Loss + heavyside_step,
        # Where heavyside_step ~ 0 if A < constant, otherwise ~ 99
        lasso_param = tf.constant(0.9)
        heavyside_step = tf.truediv(1., tf.add(1., tf.exp(tf.multiply(-50., tf.subtract(A, lasso_param)))))
        regularization_param = tf.multiply(heavyside_step, 99.)
    loss = tf.add(tf.reduce_mean(tf.square(y_target - model_output)), regularization_param)
    

    这个heavyside_step 函数非常接近逻辑函数,而逻辑函数又可以是阶跃函数的连续逼近。

    您使用连续逼近,因为损失函数需要相对于模型的参数是可微的。

    要获得有关阅读 https://www.cs.ubc.ca/~schmidtm/Documents/2005_Notes_Lasso.pdf 中的约束公式第 1.6 节的直觉

    您可以在您的代码中看到,如果 A

    【讨论】:

    • 您能否提供一份文件详细描述此功能(重步功能)?我已经阅读了上面的代码,但我想了解如何在与 Lasso 相关的上下文中使用此函数。
    • 感谢@dgumo。我阅读了您的文档,但我仍然不了解heavyside_step 的配方。我正在尝试参考en.wikipedia.org/wiki/Heaviside_step_function,希望我能找到解决方案。
    【解决方案2】:

    如果您想使用 Lasso Regression 对特征进行归一化,这里有一个示例:

    from sklearn.feature_selection import SelectFromModel
    from sklearn.linear_model import Lasso
    estimator = Lasso()
    featureSelection = SelectFromModel(estimator)
    featureSelection.fit(features_vector, target)
    selectedFeatures = featureSelection.transform(features_vector)
    print(selectedFeatures)
    

    【讨论】:

      猜你喜欢
      • 2020-09-23
      • 2020-07-15
      • 2018-11-08
      • 2018-05-11
      • 1970-01-01
      • 1970-01-01
      • 2016-11-16
      • 1970-01-01
      • 2020-05-11
      相关资源
      最近更新 更多