|
13 | 13 | # Author: Alexandre Gramfort <alexandre.gramfort@inria.fr> |
14 | 14 | # License: BSD 3 clause |
15 | 15 |
|
| 16 | +from itertools import cycle |
16 | 17 | import numpy as np |
17 | 18 | import matplotlib.pyplot as plt |
18 | 19 |
|
|
47 | 48 |
|
48 | 49 | plt.figure(1) |
49 | 50 | ax = plt.gca() |
50 | | -ax.set_color_cycle(2 * ['b', 'r', 'g', 'c', 'k']) |
51 | | -l1 = plt.plot(-np.log10(alphas_lasso), coefs_lasso.T) |
52 | | -l2 = plt.plot(-np.log10(alphas_enet), coefs_enet.T, linestyle='--') |
| 51 | + |
| 52 | +colors = cycle(['b', 'r', 'g', 'c', 'k']) |
| 53 | +neg_log_alphas_lasso = -np.log10(alphas_lasso) |
| 54 | +neg_log_alphas_enet = -np.log10(alphas_enet) |
| 55 | +for coef_l, coef_e, c in zip(coefs_lasso, coefs_enet, colors): |
| 56 | + l1 = plt.plot(neg_log_alphas_lasso, coef_l, c=c) |
| 57 | + l2 = plt.plot(neg_log_alphas_enet, coef_e, linestyle='--', c=c) |
53 | 58 |
|
54 | 59 | plt.xlabel('-Log(alpha)') |
55 | 60 | plt.ylabel('coefficients') |
|
60 | 65 |
|
61 | 66 | plt.figure(2) |
62 | 67 | ax = plt.gca() |
63 | | -ax.set_color_cycle(2 * ['b', 'r', 'g', 'c', 'k']) |
64 | | -l1 = plt.plot(-np.log10(alphas_lasso), coefs_lasso.T) |
65 | | -l2 = plt.plot(-np.log10(alphas_positive_lasso), coefs_positive_lasso.T, |
66 | | - linestyle='--') |
| 68 | +neg_log_alphas_positive_lasso = -np.log10(alphas_positive_lasso) |
| 69 | +for coef_l, coef_pl, c in zip(coefs_lasso, coefs_positive_lasso, colors): |
| 70 | + l1 = plt.plot(neg_log_alphas_lasso, coef_l, c=c) |
| 71 | + l2 = plt.plot(neg_log_alphas_positive_lasso, coef_pl, linestyle='--', c=c) |
67 | 72 |
|
68 | 73 | plt.xlabel('-Log(alpha)') |
69 | 74 | plt.ylabel('coefficients') |
|
74 | 79 |
|
75 | 80 | plt.figure(3) |
76 | 81 | ax = plt.gca() |
77 | | -ax.set_color_cycle(2 * ['b', 'r', 'g', 'c', 'k']) |
78 | | -l1 = plt.plot(-np.log10(alphas_enet), coefs_enet.T) |
79 | | -l2 = plt.plot(-np.log10(alphas_positive_enet), coefs_positive_enet.T, |
80 | | - linestyle='--') |
| 82 | +neg_log_alphas_positive_enet = -np.log10(alphas_positive_enet) |
| 83 | +for (coef_e, coef_pe, c) in zip(coefs_enet, coefs_positive_enet, colors): |
| 84 | + l1 = plt.plot(neg_log_alphas_enet, coef_e, c=c) |
| 85 | + l2 = plt.plot(neg_log_alphas_positive_enet, coef_pe, linestyle='--', c=c) |
81 | 86 |
|
82 | 87 | plt.xlabel('-Log(alpha)') |
83 | 88 | plt.ylabel('coefficients') |
|
0 commit comments