Python sklearn.linear_model 模块,PassiveAggressiveRegressor() 实例源码

我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用sklearn.linear_model.PassiveAggressiveRegressor()

项目:Parallel-SGD    作者:angadgill    | 项目源码 | 文件源码
def test_regressor_correctness():
    y_bin = y.copy()
    y_bin[y != 1] = -1

    for loss in ("epsilon_insensitive", "squared_epsilon_insensitive"):
        reg1 = MyPassiveAggressive(C=1.0,
                                   loss=loss,
                                   fit_intercept=True,
                                   n_iter=2)
        reg1.fit(X, y_bin)

        for data in (X, X_csr):
            reg2 = PassiveAggressiveRegressor(C=1.0,
                                              loss=loss,
                                              fit_intercept=True,
                                              n_iter=2, shuffle=False)
            reg2.fit(data, y_bin)

            assert_array_almost_equal(reg1.w, reg2.coef_.ravel(), decimal=2)
项目:dask-ml    作者:dask    | 项目源码 | 文件源码
def test_basic(self, single_chunk_regression):
        X, y = single_chunk_regression
        a = lm.PartialPassiveAggressiveRegressor(random_state=0,
                                                 max_iter=100,
                                                 tol=1e-3)
        b = lm_.PassiveAggressiveRegressor(random_state=0, max_iter=100,
                                           tol=1e-3)
        a.fit(X, y)
        b.partial_fit(X, y)
        assert_estimator_equal(a, b, exclude=['loss_function_'])
项目:MENGEL    作者:CodeSpaceHQ    | 项目源码 | 文件源码
def train_sgd_regressor():
    # Picking model
    return mp.ModelProperties(regression=True, online=True), linear_model.SGDRegressor()


# http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.PassiveAggressiveRegressor.html#sklearn.linear_model.PassiveAggressiveRegressor
项目:MENGEL    作者:CodeSpaceHQ    | 项目源码 | 文件源码
def train_passive_aggressive_regressor():
    # Picking model
    return mp.ModelProperties(regression=True, online=True), linear_model.PassiveAggressiveRegressor()
项目:yellowbrick    作者:DistrictDataLabs    | 项目源码 | 文件源码
def test_isclassifier(self):
        model = PassiveAggressiveRegressor()
        message = 'This estimator is not a classifier; try a regression or clustering score visualizer instead!'
        classes = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']

        with self.assertRaisesRegexp(yellowbrick.exceptions.YellowbrickError, message):
            ConfusionMatrix(model, classes=classes)
项目:Parallel-SGD    作者:angadgill    | 项目源码 | 文件源码
def test_regressor_mse():
    y_bin = y.copy()
    y_bin[y != 1] = -1

    for data in (X, X_csr):
        for fit_intercept in (True, False):
            reg = PassiveAggressiveRegressor(C=1.0, n_iter=50,
                                             fit_intercept=fit_intercept,
                                             random_state=0)
            reg.fit(data, y_bin)
            pred = reg.predict(data)
            assert_less(np.mean((pred - y_bin) ** 2), 1.7)
项目:Parallel-SGD    作者:angadgill    | 项目源码 | 文件源码
def test_regressor_partial_fit():
    y_bin = y.copy()
    y_bin[y != 1] = -1

    for data in (X, X_csr):
        reg = PassiveAggressiveRegressor(C=1.0,
                                         fit_intercept=True,
                                         random_state=0)
        for t in range(50):
            reg.partial_fit(data, y_bin)
        pred = reg.predict(data)
        assert_less(np.mean((pred - y_bin) ** 2), 1.7)
项目:Parallel-SGD    作者:angadgill    | 项目源码 | 文件源码
def test_regressor_undefined_methods():
    reg = PassiveAggressiveRegressor()
    for meth in ("transform",):
        assert_raises(AttributeError, lambda x: getattr(reg, x), meth)