How to plot a figure similar to the one produced by lassoPlot.m to specify a regularization parameter?

后端 未结 1 602
再見小時候
再見小時候 2021-01-24 08:53

I am trying to apply a regularized optimization other than Lasso. How can I plot the figure similar to the one produced by lassoPlot.m included in MATLAB as shown b

相关标签:
1条回答
  • 2021-01-24 09:18

    If I had to create a plot like this manually, I'd do something like this:

    function q53809665
    
    DATASET = [
    0.601240818 459.5714648 6.549320679
    0.38951982  407.6789162 6.915203670
    0.250128593 366.9277664 8.668936114
    0.162048287 339.5657219 9.739510946
    0.104984588 307.3415556 8.790018144
    0.067415433 285.0615823 8.484338823
    0.043675756 269.5982984 11.06798324
    0.028295771 260.4386699 15.11267808
    0.018170016 257.2895579 18.61737927
    0.011771625 259.6377656 21.91891116
    0.007626364 263.2320447 26.44502524
    0.004897239 271.3708739 29.95587021
    0.003172725 281.8307622 33.79278025
    0.002055481 297.9101884 37.48077341
    0.001319919 313.8919378 41.61931914
    0.000855123 329.4338429 45.13891826
    0.000554000 343.8029749 48.41955847
    0.000355749 355.8266151 51.22206310
    0.000230475 364.9182681 53.60367903
    0.000149316 371.7376732 55.08113765
    9.58825E-05 376.5047798 56.84605825
    6.21184E-05 379.8791639 57.35674048
    4.02440E-05 382.3739682 57.86464961];
    
    figure(); 
    hEB = errorbar(DATASET(:,1), DATASET(:,2), DATASET(:,3),'.', 'MarkerEdgeColor','r',...
                   'MarkerSize',10, 'Color', 0.7*[1 1 1]);
    hEB.Parent.XDir = 'reverse';
    hEB.Parent.XScale = 'log';
    
    hold on;
    
    plot(DATASET(9,1), DATASET(9,2), 'og', 'MarkerSize', 10);
    plot(DATASET(7,1), DATASET(7,2), 'ob', 'MarkerSize', 10);
    xline(DATASET(9,1), ':g');
    xline(DATASET(7,1), ':b');
    
    xlabel('Lambda'); 
    title('Cross-Validated Devians of Lasso Fit');
    legend('Deviance with Error Bars', 'LambdaMinDeviance','Lambda1SE');
    

    Result:

    0 讨论(0)
提交回复
热议问题