コード例 #1
0
ファイル: test_data.py プロジェクト: zkuncheva/scikit-learn
def test_robust_scale_axis1():
    X = iris.data
    X_trans = robust_scale(X, axis=1)
    assert_array_almost_equal(np.median(X_trans, axis=1), 0)
    q = np.percentile(X_trans, q=(25, 75), axis=1)
    iqr = q[1] - q[0]
    assert_array_almost_equal(iqr, 1)
コード例 #2
0
def test_robust_scale_axis1():
    X = iris.data
    X_trans = robust_scale(X, axis=1)
    assert_array_almost_equal(np.median(X_trans, axis=1), 0)
    q = np.percentile(X_trans, q=(25, 75), axis=1)
    iqr = q[1] - q[0]
    assert_array_almost_equal(iqr, 1)
コード例 #3
0
ファイル: weird.py プロジェクト: neurotronix/ROIFi
    def decision_function(self, X):

        """ Compute the (weighted) sum of votes.
        Parameters
        ----------
        X : np.ndarray, List
            Data in the form of rows x columns = samples x features
        Returns
        -------
        The (weighted) sum of votes.
        """
        if self.centroid_weighting:
            votes = robust_scale(abs(X - self.averages[0, :]) - abs(X - self.averages[1, :]),
                                 with_centering=False, axis=1)
        else:
            votes = (abs(X - self.averages[0, :]) > abs(X - self.averages[1, :])) - 0.5
        if self.stats_weighting is None:
            dec = np.sum(votes, 1) / votes.shape[1]
        else:
            dec = _weighted_sum(votes, self.feature_importances_) / votes.shape[1]
        return dec