1
$\begingroup$

Using scikit-learn:

http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LassoCV.html

Specifically, I am interested in:

1) If eps grows, does the accuracy(precision) increase or decrease?

2) If tol grows, does the accuracy(precision) increase or decrease?

$\endgroup$
3
  • $\begingroup$ I don't think accuracy and precision are the same things. A very precise answer could be totally inaccurate. $\endgroup$ – Vishal Mar 24 '16 at 19:28
  • $\begingroup$ Agreed. But can you help me with this specific question? $\endgroup$ – The Baron Mar 24 '16 at 19:32
  • $\begingroup$ You're trying to use a linear model to calculate accuracy and precision. These are concepts associated with classification models, not linear models. Do you mean perhaps improved mean square error? $\endgroup$ – ilanman Dec 30 '16 at 23:52
3
$\begingroup$

Here is an example of LassoCV's affect on MSE with varying eps and tol (using the diabetes dataset), for various $\alpha$'s. Note that this is the average MSE (each CV run will have a different MSE):

enter image description here

enter image description here

It appears that eps has a significant impact for some penalty parameters, but with a large enough penalty it doesn't matter. tol doesn't seem to play a large role (at least as far as scikit has implement LassoCV).

See below for code.

import matplotlib.pyplot as plt
from matplotlib.pyplot import cm
%matplotlib inline
import numpy as np
from sklearn import datasets
from sklearn.linear_model import LassoCV

# load data
diabetes = datasets.load_diabetes()
X = diabetes.data
y = diabetes.target

# Plot of epsilons
epss = [0.0001, 0.001, 0.01, 0.1]

plt.figure(figsize=(10,6))
color = cm.rainbow(np.linspace(0,1,len(epss)))

for i,c in zip(epss,color):
    model = LassoCV(eps=i).fit(X, y)

    ymin, ymax = 2300, 3800
    plt.plot(m_log_alphas, model.mse_path_.mean(axis=-1), color=c,
             label='eps = {}'.format(i), linewidth=2)
    plt.legend()

    plt.xlabel('-log(alpha)')
    plt.ylabel('Mean square error')
    plt.axis('tight')
    plt.ylim(ymin, ymax)


# Plot of tols
plt.figure(figsize=(10,6))
tols = [0.0001, 0.001, 0.01, 0.1, 1]

color = cm.rainbow(np.linspace(0,1,len(tols)))

for i,c in zip(tols,color):
    model = LassoCV(tol=i).fit(X, y)

    ymin, ymax = 2300, 3800
    plt.plot(m_log_alphas, model.mse_path_.mean(axis=-1), color=c,
             label='tol = {}'.format(i), linewidth=2)
    plt.legend()

    plt.xlabel('-log(alpha)')
    plt.ylabel('Mean square error')
    plt.axis('tight')
    plt.ylim(ymin, ymax)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.