Exemplo n.º 1
0
    def _dataPreprocessing(self, X_l, X_u):
        """
        Preprocess data: delete constant dimensions, Normalize input samples if needed

        INPUT:
            X_l          Input data lower bounds (rows = objects, columns = features)
            X_u          Input data upper bounds (rows = objects, columns = features)

        OUTPUT
            X_l, X_u were preprocessed
        """

        # delete constant dimensions
        #X_l, X_u = delete_const_dims(X_l, X_u)

        # Normalize input samples if needed
        if X_l.min() < self.loLim or X_u.min() < self.loLim or X_u.max(
        ) > self.hiLim or X_l.max() > self.hiLim:
            self.mins = X_l.min(axis=0)  # get min value of each feature
            self.maxs = X_u.max(axis=0)  # get max value of each feature
            X_l = normalize(X_l, [self.loLim, self.hiLim])
            X_u = normalize(X_u, [self.loLim, self.hiLim])
        else:
            self.isNorm = False
            self.mins = []
            self.maxs = []

        return (X_l, X_u)
Exemplo n.º 2
0
    def dataPreprocessing(self, X_l, X_u):
        """
        Preprocess data: delete constant dimensions, Normalize input samples if needed
        
        INPUT:
            X_l          Input data lower bounds (rows = objects, columns = features) datatype: numpy array
            X_u          Input data upper bounds (rows = objects, columns = features) datatype: numpy array
        
        OUTPUT
            X_l, X_u were preprocessed
        """

        # delete constant dimensions
        #X_l, X_u = delete_const_dims(X_l, X_u)

        # Normalize input samples if needed
        if X_l.min() < self.loLim or X_u.min() < self.loLim or X_u.max(
        ) > self.hiLim or X_l.max() > self.hiLim:
            self.mins = torch.from_numpy(
                X_l.min(axis=0)).float()  # get min value of each feature
            self.maxs = torch.from_numpy(
                X_u.max(axis=0)).float()  # get max value of each feature
            X_l = normalize(X_l, [self.loLim, self.hiLim])
            X_u = normalize(X_u, [self.loLim, self.hiLim])
        else:
            self.isNorm = False
            self.mins = torch.FloatTensor([])
            self.maxs = torch.FloatTensor([])

        return (X_l, X_u)
    def dataPreprocessing(self, Xh):
        """
        Preprocess data: delete constant dimensions, Normalize input samples if needed
        
        INPUT:
            Xh      Input data lower bounds (rows = objects, columns = features)
        
        OUTPUT
            Xh was preprocessed
        """

        # delete constant dimensions
        #Xh = delete_const_dims(Xh)

        # Normalize input samples if needed
        if Xh.min() < self.loLim or Xh.max() > self.hiLim:
            self.mins = Xh.min(axis=0)  # get min value of each feature
            self.maxs = Xh.max(axis=0)  # get max value of each feature
            Xh = normalize(Xh, [self.loLim, self.hiLim])
        else:
            self.isNorm = False
            self.mins = []
            self.maxs = []

        return Xh