Skip to content

4. Customize Your Script!

AHdezS edited this page Jan 23, 2026 · 2 revisions

The intuitive and user-friendly GUI is not the only way to use sarlib. For users seeking flexibility and automation, sarlib provides a range of advanced functions and class methods that can be easily configured to meet specific needs.

This configuration is managed through various arguments in functions and parameters in class methods. All of the following have default values:

Functions

show_scatter(x, y, x_name=None, y_name=None, block=False)

  • x_name (list, optional): Names of the predictor variables
  • y_name (str, optional): Name of the response variable
  • block (bool, optional): Whether to block execution until the plot window is closed

Class SAR Methods

__init__(self, n_realiz=100, norm='epsins', eps_0=None, alpha=0.05, mode='resusb', bound='pacbayes', eta=0.5, dropout_rate=0.5)

  • n_realiz (int): Number of Monte Carlo realizations
  • norm (str): Norm of loss function ('epsins' for epsilon-insensitive, 'rmse' for root mean squared error)
  • eps_0 (float, optional): Threshold parameter for loss. If None, uses SVR epsilon
  • alpha (float): Significance level for hypothesis testing
  • mode (str): Validation mode ('resusb' for resubstitution, 'kfold' for k-fold CV, 'leaveoo' for leave-one-out CV)
  • bound (str): Bound type ('pacbayes', 'vapnik', 'igp', 'igp_approx')
  • eta (float): Confidence parameter for bounds
  • dropout_rate (float): Dropout rate parameter for Bayesian bound

fit(self, x, y, n=None, seed=None, verbose=True)

  • n (int, optional): Sample size per realization. If None, use all samples
  • seed (int, optional): Random seed for reproducibility
  • verbose (bool, optional): Print summary table

Class OLS Methods

__init__(self, n_realiz=100, alpha=0.05)

  • n_realiz (int): Number of Monte Carlo realizations for permutation testing
  • alpha (float): Significance level for hypothesis testing

fit(self, x, y, n=None, seed=None, verbose=True)

  • n (int, optional): Sample size per realization. If None, use all samples
  • seed (int, optional): Random seed for reproducibility
  • verbose (bool, optional): Print summary table

Class SampleSizeAnalysis Methods

__init__(self, model=SAR, x, y, steps=7, seed=None, verbose=True)

  • model (OLS or SAR): Model instance to analyze
  • steps (int): Number of sample sizes to analyze
  • seed (int, optional): Random seed for reproducibility
  • verbose (bool, optional): Print progress

plot_loss(self, block=False), plot_pvalue(self, block=False), plot_coef(self, block=False)

  • block (bool, optional): Whether to block execution until plot is closed