docstr: Fits the neural network to the data.
  
  Parameters
  ----------
  X : pd.DataFrame
      The training data.
  y : pd.Series
      The training labels.
  s : pd.Series, optional
      The sensitive attribute.
docstr_tok: ["Fits","the","neural","network","to","the","data",".","Parameters","--","--","--","--","--","X",":","pd.DataFrame","The","training","data",".","y",":","pd.Series","The","training","labels",".","s",":","pd.Series",",","optional","The","sensitive","attribute","."]
code: def fit(
      self, X: pd.DataFrame, y: pd.Series, s: Optional[pd.Series] = None
  ) -> None:
      """Fits the neural network to the data.
  
      Parameters
      ----------
      X : pd.DataFrame
          The training data.
      y : pd.Series
          The training labels.
      s : pd.Series, optional
          The sensitive attribute.
      """
      super().fit(X=X, y=y, s=s)
      data = [[X.values[i], y.values[i]] for i in range(X.shape[0])]
      loss_function = import_object(self.loss_class)()
      loader = DataLoader(
          data, batch_size=self.batch_size, shuffle=True, num_workers=0
      )
      self.model._create_architecture(X.shape[1])
      self.logger.debug(
          f"Instantiating optimizer {self.optimizer_class}."
      )
      self.optimizer = import_object(self.optimizer_class)(
          params=self.model.parameters(),
          lr=self.learning_rate,
          weight_decay=self.weight_decay,
      )
  
      for _ in tqdm(range(self.epochs)):
          self.model.train()
  
          # Divide the dataset in batches of the specified size.
          for X_batch, y_batch in tqdm(loader):
              y_pred = self.model(X_batch.float()).cpu()
              loss = loss_function(y_pred.t()[0], y_batch.float())
              self.optimizer.zero_grad()
              loss.backward()
              self.optimizer.step()
  
file_path: aequitas/src/aequitas/fairflow/methods/base_estimator/neural_network.py
imports: from typing import Optional
  import pandas
  import torch
  from torch import nn, optim
  from torch.utils.data import DataLoader
  from tqdm import tqdm
  from ...utils import create_logger, import_object
  from .base_estimator import BaseEstimator
label_desc: Use image node_id 2 for calling the NeuralNetwork obj's underlying member method code with example usage: obj.fit(X, y, s) without return types