示例#1
0
    def _data_preprocess(self, dataset, fold, split):
        """Preprocess the dataset.
    
    Returns feature, label and previous features.
    
    Args:
      - dataset: temporal, static, label, time, treatment information
      - fold: Cross validation fold
      - split: 'train', 'valid' or 'test'
      
    Returns:
      - x: temporal feature
      - y: labels
      - previous_x: previous features
    """
        # Set temporal, static, label, and time information
        x, s, y, t, _ = dataset.get_fold(fold, split)

        # Concatenate static features
        if self.static_mode == 'concatenate':
            if s is not None:
                x = concate_xs(x, s)

        # Concatenate time information
        if self.time_mode == 'concatenate':
            if t is not None:
                x = concate_xt(x, t)

        # Define previous temporal features (push one time stamp)
        previous_x = x.copy()
        for i in range(len(x)):
            previous_x[i][1:, :] = previous_x[i][:-1, :]
            previous_x[i][0, :] = -np.ones([len(x[i][0, :])])

        return x, y, previous_x
    def data_preprocess(self, dataset, fold, split):
        """Preprocess the dataset.
    
    Args:
      - dataset: temporal, static, label, time, treatment information
      - fold: Cross validation fold
      - split: 'train', 'valid' or 'test'
      
    Returns:
      - x: temporal feature
      - y_hat: predictions of the predictor model
    """
        # Set temporal, static, and time information
        x, s, _, t, _ = dataset.get_fold(fold, split)
        # Label is the prediction of the predictor
        y_hat = self.predictor_model.predict(dataset, test_split=split)
        # Static & Time information concatenating
        if self.static_mode == 'concatenate':
            if s is not None:
                x = concate_xs(x, s)
        if self.time_mode == 'concatenate':
            if t is not None:
                x = concate_xt(x, t)

        return x, y_hat
  def _data_preprocess(self, dataset, fold, split):
    """Preprocess the dataset.

    Returns feature and label.

    Args:
      - dataset: temporal, static, label, time, treatment information
      - fold: Cross validation fold
      - split: 'train', 'valid' or 'test'

    Returns:
      - x: temporal feature
      - y: labels
    """
    # Set temporal, static, label, and time information
    x, s, y, t, _ = dataset.get_fold(fold, split)

    if self.static_mode == 'concatenate':
      if s is not None:
        x = concate_xs(x, s)

    if self.time_mode == 'concatenate':
      if t is not None:
        x = concate_xt(x, t)

    return x, y