楼主: Lisrelchen
1177 9

[pysterior] Python Machine Learning Library [推广有奖]

  • 0关注
  • 62粉丝

VIP

已卖:4192份资源

院士

67%

还不是VIP/贵宾

-

TA的文库  其他...

Bayesian NewOccidental

Spatial Data Analysis

东西方数据挖掘

威望
0
论坛币
50278 个
通用积分
83.5106
学术水平
253 点
热心指数
300 点
信用等级
208 点
经验
41518 点
帖子
3256
精华
14
在线时间
766 小时
注册时间
2006-5-4
最后登录
2022-11-6

楼主
Lisrelchen 发表于 2017-9-10 21:05:32 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
pysterior

pysterior is a machine learning library for Python which aims to make Bayesian parametric regression and classification models accessible and easy to use. The library allows users to construct supervised learning models using an intuitive interface similar to that used by scikit-learn.

More documentation is to come - this is still a very new project.

Under the hood, pysterior uses the implementation of the No-U-Turn Sampler (Hoffman and Gelman, 2011) provided by the thoroughly wonderful pymc3. Pymc3 is a requirement to run pysterior; see the pymc3 page to find out how to get the latest version.

Download pysterior on PyPI: https://pypi.python.org/pypi/pysterior

You can install the latest version of this package from PyPI, where it is currently in alpha. The following models are currently supported:

  • regression module:
    • (Bayesian) Linear Regression
    • Ridge Regression
    • Lasso Regression
    • Robust Linear regression (Cauchy-distributed noise)
    • Polynomial regression
  • classification module:
    • Binary Logistic regression

Coming soon:

  • k-class Logistic regression
  • More non-linear models

本帖隐藏的内容

https://github.com/lmc2179/pysterior



二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Learning earning Library machine python

本帖被以下文库推荐

沙发
Lisrelchen 发表于 2017-9-10 21:06:40

Bayesian Regression using Pysterior

  1. import numpy as np
  2. from pysterior import regression
  3. %matplotlib inline
  4. from matplotlib import pyplot as plt
  5. import warnings
  6. warnings.filterwarnings("ignore")
  7. In [7]:
  8. TRUE_ALPHA, TRUE_SIGMA = 1, 1
  9. TRUE_BETA = 2.5
  10. size = 100
  11. X = np.linspace(0, 1, size)
  12. noise = (np.random.randn(size)*TRUE_SIGMA)
  13. y = (TRUE_ALPHA + TRUE_BETA*X + noise)

  14. lr = regression.LinearRegression()
  15. lr.fit(X, y, 5000)
  16. plt.plot(X, y, linewidth=0.0, marker='x', color='g')
  17. pred_post_points = [lr.get_predictive_posterior_samples(x) for x in X]
  18. transpose = list(zip(*pred_post_points))
  19. for y_values in transpose:
  20.     plt.plot(X, y_values, color='r')
  21. predicted_line = lr.predict(X)
  22. plt.plot(X, predicted_line)
  23. plt.show()
复制代码

藤椅
MouJack007 发表于 2017-9-10 21:08:35
谢谢楼主分享!

板凳
MouJack007 发表于 2017-9-10 21:08:52

报纸
Lisrelchen 发表于 2017-9-10 21:09:02
Highest Posterior Density Estimation
  1. import numpy as np
  2. from pysterior import regression
  3. %matplotlib inline
  4. from matplotlib import pyplot as plt
  5. import warnings
  6. warnings.filterwarnings("ignore")
  7. In [3]:
  8. TRUE_ALPHA, TRUE_SIGMA = 1, 1.0
  9. TRUE_BETA1 = 2.5
  10. TRUE_BETA2 = 6.5
  11. TRUE_BETA3 = 2.5
  12. TRUE_BETA4 = -10.5
  13. size = 10
  14. X = np.linspace(-1.0, 1.0, size)
  15. noise = (np.random.randn(size)*TRUE_SIGMA)
  16. y = (TRUE_ALPHA + TRUE_BETA1*X + TRUE_BETA2*X**2 + TRUE_BETA3*X**3  + TRUE_BETA4*X**4 + noise)

  17. holdout_X = np.array([0.23, 0.78])
  18. noise = (np.random.randn(len(holdout_X))*TRUE_SIGMA)
  19. holdout_y = (TRUE_ALPHA + TRUE_BETA1*holdout_X + TRUE_BETA2*holdout_X**2 + TRUE_BETA3*holdout_X**3  + TRUE_BETA4*holdout_X**4 + noise)

  20. lr = regression.PolynomialRegression(degree=4)
  21. lr.fit(X, y, 7000)

  22. for alpha, color in [(0.01, 'y'), (0.05, 'r'), (0.1, 'g'), (0.2, 'b')]:
  23.     intervals = lr.predict_hpd_interval(X, alpha)
  24.     lower_bound, upper_bound = zip(*intervals)
  25.     plt.plot(X, lower_bound, color=color)
  26.     plt.plot(X, upper_bound, color=color)

  27. predicted_line = lr.predict(X)
  28. plt.plot(X, predicted_line)
  29. plt.plot(X, y, linewidth=0.0, marker='x', color='g')
  30. plt.plot(holdout_X, holdout_y, linewidth=0.0, marker='x', color='r')
  31. plt.show()
复制代码

地板
Lisrelchen 发表于 2017-9-10 21:10:10
Polynomial Regression
  1. import numpy as np
  2. from pysterior import regression
  3. %matplotlib inline
  4. from matplotlib import pyplot as plt
  5. import warnings
  6. warnings.filterwarnings("ignore")
  7. In [5]:
  8. TRUE_ALPHA, TRUE_SIGMA = 1, 1.0
  9. TRUE_BETA1 = 2.5
  10. TRUE_BETA2 = 6.5
  11. TRUE_BETA3 = 2.5
  12. TRUE_BETA4 = -10.5
  13. size = 10
  14. X = np.linspace(-1.0, 1.0, size)
  15. noise = (np.random.randn(size)*TRUE_SIGMA)
  16. y = (TRUE_ALPHA + TRUE_BETA1*X + TRUE_BETA2*X**2 + TRUE_BETA3*X**3  + TRUE_BETA4*X**4 + noise)

  17. lr = regression.PolynomialRegression(4)
  18. lr.fit(X, y, 1000)
  19. pred_post_points = [lr.get_predictive_posterior_samples(x) for x in X]
  20. transpose = list(zip(*pred_post_points))
  21. for y_values in transpose:
  22.     plt.plot(X, y_values, color='r')
  23. predicted_line = lr.predict(X)
  24. plt.plot(X, predicted_line)
  25. plt.plot(X, y, linewidth=0.0, marker='x', color='g')
  26. plt.show()
复制代码

7
jjxm20060807 发表于 2017-9-10 21:47:17
谢谢分享

8
jinyizhe282 发表于 2017-9-10 21:53:23
hahhhhhh

9
yazxf 发表于 2017-9-10 21:55:23
谢谢你的书!

10
zhangxiangallen 在职认证  发表于 2017-9-10 22:11:56
赞楼主,楼主是好人

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-12 09:52