Python非线性回归

非线性样本

from matplotlib import pyplot as mp
y = [.4187, .0964, .0853, .0305, .0358, .0338, .0368, .0222, .0798, .1515]
x = [[i]for i in range(len(y))]
mp.scatter(x, y, s=99)
mp.show()

Sklearn回归汇总

非线性
线性

import matplotlib.pyplot as mp
# 训练集
y = [.27, .16, .06, .036, .044, .04, .022, .017, .022, .014, .017, .02, .019, .017, .011, .01, .03, .05, .066, .09]
ly, n = len(y), 100
x = [[i / ly]for i in range(ly)]
# 待测集
w = [[i / n] for i in range(n)]
# # x轴范围
# max_x = 1
# x, w = [[i[0]*max_x] for i in x], [[i[0]*max_x] for i in w]

def modeling(models):
    for i in range(len(models)):
        print(models[i].__name__)
        # 建模、拟合
        model = models[i]()
        model.fit(x, y)
        # 预测
        z = model.predict(w)
        # 可视化
        mp.subplot(3, 4, i + 1)
        mp.title(models[i].__name__, size=10)
        mp.xticks(())
        mp.yticks(())
        mp
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小基基o_O

您的鼓励是我创作的巨大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值