@@ -23,7 +23,6 @@ def plqERM_Ridge_path_sol(
2323 shrink = 1 ,
2424 warm_start = False ,
2525 return_time = True ,
26- plot_path = False
2726):
2827 """
2928 Compute the PLQ Empirical Risk Minimization (ERM) path over a range of regularization parameters.
@@ -44,10 +43,11 @@ def plqERM_Ridge_path_sol(
4443 constraint : list of dict, optional (default=[])
4544 List of constraints applied to the optimization problem. Each constraint should be represented
4645 as a dictionary compatible with the solver.
46+
4747
4848 eps : float, default=1e-3
49- Defines the range of regularization values when `Cs` is not provided. Specifically, the smallest
50- regularization value will be approximately ` eps` times the largest .
49+ Defines the length of the regularization path when `Cs` is not provided.
50+ The values of `C` will range from `10^log10( eps)` to `10^-log10(eps)` .
5151
5252 n_Cs : int, default=100
5353 Number of regularization values to evaluate if `Cs` is not provided.
@@ -64,6 +64,8 @@ def plqERM_Ridge_path_sol(
6464
6565 verbose : int, default=0
6666 Controls verbosity level of output. Set to higher values (e.g., 1 or 2) for detailed progress logs.
67+ When verbose = 1, only print path results table;
68+ when verbose = 2, print path results table and path solution plot.
6769
6870 shrink : float, default=1
6971 Shrinkage factor for the solver, potentially influencing convergence behavior.
@@ -108,22 +110,23 @@ def plqERM_Ridge_path_sol(
108110 >>> y = np.sign(X.dot(beta0) + np.random.randn(n))
109111 >>> # define loss function
110112 >>> loss = {'name': 'svm'}
111- >>> Cs = [2000, 3000, 4000]
112- >>> constrain = [{'name': 'none '}]
113+ >>> Cs = np.logspace(-1,3,15)
114+ >>> constraint = [{'name': 'nonnegative '}]
113115
114116
115117 >>> # calculate
116- >>> Cs, times, n_iters, losses, norms, coefs = plqERM_path_sol (
117- ... X, y, loss=loss, Cs=Cs, max_iter=100000,tol=1e-4,verbose=1 ,
118- ... warm_start=False, constrain=constrain , return_time=True, plot_path =True
118+ >>> Cs, times, n_iters, losses, norms, coefs = plqERM_Ridge_path_sol (
119+ ... X, y, loss=loss, Cs=Cs, max_iter=100000,tol=1e-4,verbose=2 ,
120+ ... warm_start=False, constraint=constraint , return_time=True
119121 ... )
120122
121123 """
122124
123125 n_samples , n_features = X .shape
124126
125127 if Cs is None :
126- Cs = np .logspace (- 2 , 3 , n_Cs )
128+ log_eps = np .log10 (eps )
129+ Cs = np .logspace (log_eps , - log_eps , n_Cs )
127130
128131 # Sort Cs to ensure computation starts from the smallest value
129132 Cs = np .sort (Cs )
@@ -194,7 +197,7 @@ def plqERM_Ridge_path_sol(
194197 avg_time_per_iter = total_time / sum (n_iters ) if sum (n_iters ) > 0 else float ("inf" )
195198
196199
197- if verbose :
200+ if verbose >= 1 :
198201 print ("\n PLQ ERM Path Solution Results" )
199202 print ("=" * 90 )
200203 print (f"{ 'C Value' :<15} { 'Iterations' :<15} { 'Time (s)' :<20} { 'Loss' :<20} { 'L2 Norm' :<20} " )
@@ -211,7 +214,7 @@ def plqERM_Ridge_path_sol(
211214 print (f"{ 'Avg Time/Iter' :<12} { avg_time_per_iter :.6f} sec" )
212215 print ("=" * 90 )
213216
214- if plot_path :
217+ if verbose >= 2 :
215218 import matplotlib .pyplot as plt
216219 plt .figure (figsize = (10 , 6 ))
217220 for i in range (n_features ):
0 commit comments