Documentation for train.py
            mylib.train
    Module description
              SyntheticBernuliDataset(n: int = 10, m: int = 100, seed: int = 42)
    
              Bases: object
Base class for synthetic dataset.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
n | 
            
                  int
             | 
            
               feature number. Defaults to 10.  | 
            
                  10
             | 
          
m | 
            
                  int
             | 
            
               object number. Defaults to 100.  | 
            
                  100
             | 
          
seed | 
            
                  int
             | 
            
               random state seed. Defaults to 42.  | 
            
                  42
             | 
          
            w = rs.randn(n)
  
      instance-attribute
  
    
            X = rs.randn(m, n)
  
      instance-attribute
  
    
            y = rs.binomial(1, expit(self.X @ self.w))
  
      instance-attribute
  
    
              Trainer(model, X: np.ndarray, Y: np.ndarray, seed: int = 42)
    
              Bases: object
Base class for all trainers.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
model | 
            
               The class with fit and predict methods.  | 
            required | |
X | 
            
                  ndarray
             | 
            
               The array of shape [num_elemennts, num_feature]  | 
            required | 
Y | 
            
                  ndarray
             | 
            
               [num_elements, num_answers]  | 
            required | 
seed | 
            
                  int
             | 
            
               random state seed. Defaults to 42.  | 
            
                  42
             | 
          
            model = model
  
      instance-attribute
  
    
            seed = seed
  
      instance-attribute
  
    
            train()
    Train model
            eval(output_dict: bool = False) -> str | dict
    Evaluate model for initial validadtion dataset.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
output_dict | 
            
                  bool
             | 
            
               If True, return output as dict.  | 
            
                  False
             | 
          
Returns:
| Type | Description | 
|---|---|
                  str | dict
             | 
            
               classification report  | 
          
            test(X: np.ndarray, Y: np.ndarray, output_dict: bool = False) -> str | dict
    Evaluate model for given dataset.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
X | 
            
                  ndarray
             | 
            
               The array of shape [num_elements, num_feature]  | 
            required | 
Y | 
            
                  ndarray
             | 
            
               The array of shape [num_elements, num_answers]  | 
            required | 
output_dict | 
            
                  bool
             | 
            
               If True, return output as dict. Defaults to False.  | 
            
                  False
             | 
          
Returns:
| Type | Description | 
|---|---|
                  str | dict
             | 
            
               classification report  | 
          
            cv_parameters(X: np.ndarray, Y: np.ndarray, seed: int = 42, minimal: float = 0.1, maximum: float = 25, count: int = 100) -> tuple[np.ndarray, list[float], list]
    Function for the experiment with different regularisation parameters ("Cs") and return accuracy and params for LogisticRegression for each parameter.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
X | 
            
                  ndarray
             | 
            
               The array of shape [num_elements, num_feature]  | 
            required | 
Y | 
            
                  ndarray
             | 
            
               The array of shape [num_elements, num_answers]  | 
            required | 
seed | 
            
                  int
             | 
            
               Seed for random state. Defaults to 42.  | 
            
                  42
             | 
          
minimal | 
            
                  float
             | 
            
               Minimum value for the Cs linspace. Defaults to 0.1.  | 
            
                  0.1
             | 
          
maximum | 
            
                  float
             | 
            
               Maximum value for the Cs linspace. Defaults to 25.  | 
            
                  25
             | 
          
count | 
            
                  int
             | 
            
               Number of the Cs points. Defaults to 100.  | 
            
                  100
             | 
          
Returns:
| Type | Description | 
|---|---|
                  ndarray
             | 
            
               Cs  | 
          
                  list[float]
             | 
            
               list of accuracies  | 
          
                  list
             | 
            
               list of params  |