本文整理汇总了Python中mlxtend.classifier.SoftmaxRegression类的典型用法代码示例。如果您正苦于以下问题:Python SoftmaxRegression类的具体用法?Python SoftmaxRegression怎么用?Python SoftmaxRegression使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SoftmaxRegression类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_multi_logistic_regression_gd_acc
def test_multi_logistic_regression_gd_acc():
lr = SoftmaxRegression(epochs=200,
eta=0.005,
minibatches=1,
random_seed=1)
lr.fit(X, y)
assert (y == lr.predict(X)).all()
示例2: test_progress_2
def test_progress_2():
lr = SoftmaxRegression(epochs=1,
eta=0.005,
minibatches=1,
print_progress=2,
random_seed=1)
lr.fit(X_bin, y_bin) # 0, 1 class
示例3: test_score_function
def test_score_function():
lr = SoftmaxRegression(epochs=200,
eta=0.005,
minibatches=1,
random_seed=1)
lr.fit(X, y)
acc = lr.score(X, y)
assert acc == 1.0, acc
示例4: test_multi_logistic_regression_gd_weights
def test_multi_logistic_regression_gd_weights():
t = np.array([[-0.95, -2.45, 3.4],
[-3.95, 2.34, 1.59]])
lr = SoftmaxRegression(epochs=200,
eta=0.005,
minibatches=1,
random_seed=1)
lr.fit(X, y)
np.testing.assert_almost_equal(lr.w_, t, 2)
示例5: test_binary_logistic_regression_sgd
def test_binary_logistic_regression_sgd():
t = np.array([[0.13, -0.12],
[-3.06, 3.05]])
lr = SoftmaxRegression(epochs=200,
eta=0.005,
minibatches=len(y_bin),
random_seed=1)
lr.fit(X_bin, y_bin) # 0, 1 class
np.testing.assert_almost_equal(lr.w_, t, 2)
assert (y_bin == lr.predict(X_bin)).all()
示例6: test_binary_logistic_regression_gd
def test_binary_logistic_regression_gd():
t = np.array([[-0.2, 0.2],
[-3.09, 3.09]])
lr = SoftmaxRegression(epochs=200,
eta=0.005,
minibatches=1,
random_seed=1)
lr.fit(X_bin, y_bin)
np.testing.assert_almost_equal(lr.w_, t, 2)
assert((y_bin == lr.predict(X_bin)).all())
示例7: test_multi_logistic_probas
def test_multi_logistic_probas():
lr = SoftmaxRegression(epochs=200,
eta=0.005,
minibatches=1,
random_seed=1)
lr.fit(X, y)
idx = [0, 50, 149] # sample labels: 0, 1, 2
y_pred = lr.predict_proba(X[idx])
exp = np.array([[0.99, 0.01, 0.00],
[0.01, 0.88, 0.11],
[0.00, 0.02, 0.98]])
np.testing.assert_almost_equal(y_pred, exp, 2)
示例8: test_binary_l2_regularization_gd
def test_binary_l2_regularization_gd():
t = np.array([[-0.17, 0.17],
[-2.26, 2.26]])
lr = SoftmaxRegression(epochs=200,
eta=0.005,
l2=1.0,
minibatches=1,
random_seed=1)
lr.fit(X_bin, y_bin)
np.testing.assert_almost_equal(lr.w_, t, 2)
assert (y_bin == lr.predict(X_bin)).all()
示例9: test_binary_l2_regularization_gd
def test_binary_l2_regularization_gd():
lr = SoftmaxRegression(eta=0.005,
epochs=200,
minibatches=1,
l2_lambda=1.0,
random_seed=1)
lr.fit(X_bin, y_bin)
y_pred = lr.predict(X_bin)
expect_weights = np.array([[-0.316, 0.317],
[-2.265, 2.265]])
np.testing.assert_almost_equal(lr.w_, expect_weights, 3)
acc = sum(y_pred == y_bin) / len(y_bin)
assert(acc == 1.0)
示例10: test_refit_weights
def test_refit_weights():
t = np.array([[0.13, -0.12],
[-3.07, 3.05]])
lr = SoftmaxRegression(epochs=100,
eta=0.005,
minibatches=1,
random_seed=1)
lr.fit(X_bin, y_bin)
w1 = lr.w_[0][0]
w2 = lr.w_[0][0]
lr.fit(X_bin, y_bin, init_params=False)
assert w1 != lr.w_[0][0]
assert w2 != lr.w_[1][0]
np.testing.assert_almost_equal(lr.w_, t, 2)