コード例 #1
0
    def __init__(self, samples, labels, weights=None, scale=None):
        # list_X = [r + [1] for r in samples]
        list_X = [r for r in samples]
        self.X = array(list_X)
        self.Y = array(labels)
        self.weights = weights

        if scale is None:
            self.scale = Scale.unit_scale(len(list_X[0]))
        else:
            # self.scale = scale.add_unit_elements(1)
            self.scale = scale
コード例 #2
0
    def __init__(self, train_data, train_labels, weights=None, scale=None):

        # Adding 1 at the end for the constant term
        list_X = [r + [1] for r in train_data]

        if scale is None:
            self.scale = Scale.unit_scale(len(list_X[0]))
        else:
            self.scale = scale.add_unit_elements(1)

        self.weights = weights

        self.X = self.scale(np.array(list_X))
        self.Y = np.array(train_labels)
コード例 #3
0
    def __init__(self, train_data, train_labels, weights=None, scale=None):

        # Adding 1 at the end for the constant term
        list_X = [r + [1] for r in train_data]

        if scale is None:
            self.scale = Scale.unit_scale(len(list_X[0]))
        else:
            self.scale = scale.add_unit_elements(1)

        self.weights = weights

        self.X = self.scale(np.array(list_X))
        self.Y = np.array(train_labels)
コード例 #4
0
 def test_unit_scale(self):
     scale = Scale.unit_scale(3)
     a = np.array([1, 2, 3])
     scaled_a = scale.scale(a)
     testing.assert_array_equal(a, scaled_a)
コード例 #5
0
 def test_mul(self):
     scale = Scale.unit_scale(3)
     two_scale = scale * 2
     a = np.array([1, 2, 3])
     scaled_a = two_scale.scale(a)
     testing.assert_array_equal(a * 2, scaled_a)