Skip to content

Commit

Permalink
chore: docstring typos
Browse files Browse the repository at this point in the history
chore: fix typo

chore: fix typos

chore: fix typo
  • Loading branch information
mei28 authored and Optimox committed Dec 24, 2020
1 parent 41f42d7 commit 61c294a
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ clf.fit(
)
```

The loss function has been normalized to be independant of `pretraining_ratio`, `batch_size` and number of features in the problem.
The loss function has been normalized to be independent of `pretraining_ratio`, `batch_size` and number of features in the problem.
A self supervised loss greater than 1 means that your model is reconstructing worse than predicting the mean for each feature, a loss bellow 1 means that the model is doing better than predicting the mean.

A complete example can be found within the notebook `pretraining_example.ipynb`.
Expand Down Expand Up @@ -302,7 +302,7 @@ A complete example can be found within the notebook `pretraining_example.ipynb`.
/!\ Only for TabNetClassifier
Sampling parameter
0 : no sampling
1 : automated sampling with inverse class occurences
1 : automated sampling with inverse class occurrences
dict : keys are classes, values are weights for each class

- `loss_fn` : torch.loss or list of torch.loss
Expand Down
6 changes: 3 additions & 3 deletions pytorch_tabnet/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ class EarlyStopping(Callback):
minimum change in monitored value to qualify as improvement.
This number should be positive.
patience : integer
number of epochs to wait for improvment before terminating.
the counter be reset after each improvment
number of epochs to wait for improvement before terminating.
the counter be reset after each improvement
"""

Expand Down Expand Up @@ -154,7 +154,7 @@ def on_train_end(self, logs=None):
self.trainer.network.load_state_dict(self.best_weights)

if self.stopped_epoch > 0:
msg = f"\nEarly stopping occured at epoch {self.stopped_epoch}"
msg = f"\nEarly stopping occurred at epoch {self.stopped_epoch}"
msg += (
f" with best_epoch = {self.best_epoch} and "
+ f"best_{self.early_stopping_metric} = {round(self.best_loss, 5)}"
Expand Down
8 changes: 4 additions & 4 deletions pytorch_tabnet/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def UnsupervisedLoss(y_pred, embedded_x, obf_vars, eps=1e-9):
y_pred : torch.Tensor or np.array
Reconstructed prediction (with embeddings)
embedded_x : torch.Tensor
Orginal input embedded by network
Original input embedded by network
obf_vars : torch.Tensor
Binary mask for obfuscated variables.
1 means the variable was obfuscated so reconstruction is based on this.
Expand Down Expand Up @@ -59,7 +59,7 @@ class UnsupMetricContainer:
y_pred : torch.Tensor or np.array
Reconstructed prediction (with embeddings)
embedded_x : torch.Tensor
Orginal input embedded by network
Original input embedded by network
obf_vars : torch.Tensor
Binary mask for obfuscated variables.
1 means the variables was obfuscated so reconstruction is based on this.
Expand Down Expand Up @@ -351,7 +351,7 @@ def __call__(self, y_true, y_score):
class RMSLE(Metric):
"""
Mean squared logarithmic error regression loss.
Scikit-imeplementation:
Scikit-implementation:
https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_log_error.html
Note: In order to avoid error, negative predictions are clipped to 0.
This means that you should clip negative predictions manually after calling predict.
Expand Down Expand Up @@ -399,7 +399,7 @@ def __call__(self, y_pred, embedded_x, obf_vars):
y_pred : torch.Tensor or np.array
Reconstructed prediction (with embeddings)
embedded_x : torch.Tensor
Orginal input embedded by network
Original input embedded by network
obf_vars : torch.Tensor
Binary mask for obfuscated variables.
1 means the variables was obfuscated so reconstruction is based on this.
Expand Down
2 changes: 1 addition & 1 deletion pytorch_tabnet/multiclass_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ def infer_multitask_output(y_train):

if len(y_train.shape) < 2:
raise ValueError(
"y_train shoud be of shape (n_examples, n_tasks)"
"y_train should be of shape (n_examples, n_tasks)"
+ f"but got {y_train.shape}"
)
nb_tasks = y_train.shape[1]
Expand Down
2 changes: 1 addition & 1 deletion pytorch_tabnet/pretraining.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def fit(
a PyTorch loss function
should be left to None for self supervised and non experts
pretraining_ratio : float
Between 0 and 1, percentage of featue to mask for reconstruction
Between 0 and 1, percentage of feature to mask for reconstruction
weights : np.array
Sampling weights for each example.
max_epochs : int
Expand Down
2 changes: 1 addition & 1 deletion pytorch_tabnet/pretraining_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def create_dataloaders(
X_train, eval_set, weights, batch_size, num_workers, drop_last, pin_memory
):
"""
Create dataloaders with or wihtout subsampling depending on weights and balanced.
Create dataloaders with or without subsampling depending on weights and balanced.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion pytorch_tabnet/sparsemax.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _threshold_and_support(input, dim=-1):


class Entmoid15(Function):
""" A highly optimized equivalent of labda x: Entmax15([x, 0]) """
""" A highly optimized equivalent of lambda x: Entmax15([x, 0]) """

@staticmethod
def forward(ctx, input):
Expand Down
2 changes: 1 addition & 1 deletion pytorch_tabnet/tab_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __post_init__(self):

def weight_updater(self, weights):
"""
Updates weights dictionnary according to target_mapper.
Updates weights dictionary according to target_mapper.
Parameters
----------
Expand Down
34 changes: 17 additions & 17 deletions pytorch_tabnet/tab_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ def __init__(
n_a : int
Dimension of the attention layer (usually between 4 and 64)
n_steps : int
Number of sucessive steps in the newtork (usually betwenn 3 and 10)
Number of successive steps in the network (usually between 3 and 10)
gamma : float
Float above 1, scaling factor for attention updates (usually betwenn 1.0 to 2.0)
Float above 1, scaling factor for attention updates (usually between 1.0 to 2.0)
n_independent : int
Number of independent GLU layer in each GLU block (default 2)
n_shared : int
Expand Down Expand Up @@ -224,9 +224,9 @@ def __init__(
n_d : int
Dimension of the prediction layer (usually between 4 and 64)
n_steps : int
Number of sucessive steps in the newtork (usually betwenn 3 and 10)
Number of successive steps in the network (usually between 3 and 10)
gamma : float
Float above 1, scaling factor for attention updates (usually betwenn 1.0 to 2.0)
Float above 1, scaling factor for attention updates (usually between 1.0 to 2.0)
n_independent : int
Number of independent GLU layer in each GLU block (default 2)
n_shared : int
Expand Down Expand Up @@ -320,7 +320,7 @@ def __init__(
if self.n_steps <= 0:
raise ValueError("n_steps should be a positive integer.")
if self.n_independent == 0 and self.n_shared == 0:
raise ValueError("n_shared and n_independant can't be both zero.")
raise ValueError("n_shared and n_independent can't be both zero.")

self.virtual_batch_size = virtual_batch_size
self.embedder = EmbeddingGenerator(input_dim, cat_dims, cat_idxs, cat_emb_dim)
Expand Down Expand Up @@ -407,9 +407,9 @@ def __init__(
n_a : int
Dimension of the attention layer (usually between 4 and 64)
n_steps : int
Number of sucessive steps in the newtork (usually betwenn 3 and 10)
Number of successive steps in the network (usually between 3 and 10)
gamma : float
Float above 1, scaling factor for attention updates (usually betwenn 1.0 to 2.0)
Float above 1, scaling factor for attention updates (usually between 1.0 to 2.0)
n_independent : int
Number of independent GLU layer in each GLU block (default 2)
n_shared : int
Expand Down Expand Up @@ -515,9 +515,9 @@ def __init__(
n_a : int
Dimension of the attention layer (usually between 4 and 64)
n_steps : int
Number of sucessive steps in the newtork (usually betwenn 3 and 10)
Number of successive steps in the network (usually between 3 and 10)
gamma : float
Float above 1, scaling factor for attention updates (usually betwenn 1.0 to 2.0)
Float above 1, scaling factor for attention updates (usually between 1.0 to 2.0)
cat_idxs : list of int
Index of each categorical column in the dataset
cat_dims : list of int
Expand Down Expand Up @@ -558,7 +558,7 @@ def __init__(
if self.n_steps <= 0:
raise ValueError("n_steps should be a positive integer.")
if self.n_independent == 0 and self.n_shared == 0:
raise ValueError("n_shared and n_independant can't be both zero.")
raise ValueError("n_shared and n_independent can't be both zero.")

self.virtual_batch_size = virtual_batch_size
self.embedder = EmbeddingGenerator(input_dim, cat_dims, cat_idxs, cat_emb_dim)
Expand Down Expand Up @@ -604,7 +604,7 @@ def __init__(
input_dim : int
Input size
output_dim : int
Outpu_size
Output_size
virtual_batch_size : int
Batch size for Ghost Batch Normalization
momentum : float
Expand Down Expand Up @@ -657,10 +657,10 @@ def __init__(
input_dim : int
Input size
output_dim : int
Outpu_size
Output_size
shared_layers : torch.nn.ModuleList
The shared block that should be common to every step
n_glu_independant : int
n_glu_independent : int
Number of independent GLU layers
virtual_batch_size : int
Batch size for Ghost Batch Normalization within GLU block(s)
Expand Down Expand Up @@ -707,7 +707,7 @@ def forward(self, x):

class GLU_Block(torch.nn.Module):
"""
Independant GLU block, specific to each step
Independent GLU block, specific to each step
"""

def __init__(
Expand Down Expand Up @@ -778,7 +778,7 @@ class EmbeddingGenerator(torch.nn.Module):
"""

def __init__(self, input_dim, cat_dims, cat_idxs, cat_emb_dim):
"""This is an embedding module for an entier set of features
"""This is an embedding module for an entire set of features
Parameters
----------
Expand All @@ -791,7 +791,7 @@ def __init__(self, input_dim, cat_dims, cat_idxs, cat_emb_dim):
Positional index for each categorical features in inputs
cat_emb_dim : int or list of int
Embedding dimension for each categorical features
If int, the same embdeding dimension will be used for all categorical features
If int, the same embedding dimension will be used for all categorical features
"""
super(EmbeddingGenerator, self).__init__()
if cat_dims == [] or cat_idxs == []:
Expand Down Expand Up @@ -830,7 +830,7 @@ def __init__(self, input_dim, cat_dims, cat_idxs, cat_emb_dim):

def forward(self, x):
"""
Apply embdeddings to inputs
Apply embeddings to inputs
Inputs should be (batch_size, input_dim)
Outputs will be of size (batch_size, self.post_embed_dim)
"""
Expand Down
2 changes: 1 addition & 1 deletion pytorch_tabnet/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def create_dataloaders(
X_train, y_train, eval_set, weights, batch_size, num_workers, drop_last, pin_memory
):
"""
Create dataloaders with or wihtout subsampling depending on weights and balanced.
Create dataloaders with or without subsampling depending on weights and balanced.
Parameters
----------
Expand Down

0 comments on commit 61c294a

Please sign in to comment.