Beispiel #1
0
    def __call__(self, data):
        """
        Project data into PCA feature space.

        :param data: input dataset

        :rtype: :obj:`~Orange.data.Table`
        """
        if type(data) != Orange.data.Table:
            data = Orange.data.Table([data])

        X = data.to_numpy_MA("a")[0]
        Xm, U = self.mean, self.eigen_vectors
        n, m = X.shape

        if m != len(self.stdev):
            raise orange.KernelException, "Invalid number of features"

        Xd = X - Xm

        if self.standardize:
            Xd /= self.stdev

        self.A = np.ma.dot(Xd, U.T)

        return Orange.data.Table(self.pc_domain, self.A.tolist())
Beispiel #2
0
    def __call__(self, data):
        """
        Project data into PCA feature space.

        :param data: input dataset

        :rtype: :obj:`~Orange.data.Table`
        """
        if type(data) != Orange.data.Table:
            data = Orange.data.Table([data])

        X = data.to_numpy_MA("a")[0]
        Xm, U = self.mean, self.eigen_vectors
        n, m = X.shape

        if m != len(self.stdev):
            raise orange.KernelException, "Invalid number of features"

        Xd = X - Xm

        if self.standardize:
            Xd /= self.stdev

        self.A = np.ma.dot(Xd, U.T)

        return Orange.data.Table(self.pc_domain, self.A.tolist())
Beispiel #3
0
def transpose(data):
    """
    Transpose the `data` (works on attributes part only).
    """
    domain = data.domain
    N = len(data)
    if not all(isinstance(attr,
                          (Orange.feature.Continuous, Orange.feature.Discrete))
               for attr in domain.attributes):
        raise TypeError

    trans_domain = Orange.data.Domain(
        [Orange.feature.Continuous("F%i" % (i + 1)) for i in range(N)]
    )
    X, = data.to_numpy_MA("A")
    return Orange.data.Table(trans_domain, X.T)
Beispiel #4
0
def transpose(data):
    """
    Transpose the `data` (works on attributes part only).
    """
    domain = data.domain
    N = len(data)
    if not all(isinstance(attr,
                          (Orange.feature.Continuous, Orange.feature.Discrete))
               for attr in domain.attributes):
        raise TypeError

    trans_domain = Orange.data.Domain(
        [Orange.feature.Continuous("F%i" % (i + 1)) for i in range(N)]
    )
    X, = data.to_numpy_MA("A")
    return Orange.data.Table(trans_domain, X.T)