zoukankan      html  css  js  c++  java
  • from scipy.interpolate import spline报错ImportError: cannot import name ‘spline‘

    from scipy.interpolate import spline报错ImportError: cannot import name ‘spline‘

    一、总结

    一句话总结:

    导入make_interp_spline而不是spline,spline这个函数现在没了
    from scipy.interpolate import make_interp_spline
    x_smooth = np.linspace(x.min(), x.max(), 300)
    y_smooth = make_interp_spline(x, y)(x_smooth)

    二、from scipy.interpolate import spline报错ImportError: cannot import name ‘spline‘

    转自或参考:from scipy.interpolate import spline报错ImportError: cannot import name ‘spline‘
    https://blog.csdn.net/lly1122334/article/details/104252039

    问题描述

    from scipy.interpolate import spline
    

    报错

    ImportError: cannot import name 'spline'
    




    解决方案

    导入make_interp_spline并进一步调用

    from scipy.interpolate import make_interp_spline
    
    x_smooth = np.linspace(x.min(), x.max(), 300)
    y_smooth = make_interp_spline(x, y)(x_smooth)
    




    实例

    import numpy as np
    from matplotlib import pyplot as plt
    from scipy.interpolate import make_interp_spline
    
    x = np.array([6, 7, 8, 9, 10, 11, 12])
    y = np.array([1.53E+03, 5.92E+02, 2.04E+02, 7.24E+01, 2.72E+01, 1.10E+01, 4.70E+00])
    x_smooth = np.linspace(x.min(), x.max(), 300)
    y_smooth = make_interp_spline(x, y)(x_smooth)
    plt.plot(x_smooth, y_smooth)
    plt.show()
    

    在这里插入图片描述




    参考文献

    1. matplotlib绘制平滑的曲线
    2. Plot smooth line with PyPlot
     
    我的旨在学过的东西不再忘记(主要使用艾宾浩斯遗忘曲线算法及其它智能学习复习算法)的偏公益性质的完全免费的编程视频学习网站: fanrenyi.com;有各种前端、后端、算法、大数据、人工智能等课程。
    博主25岁,前端后端算法大数据人工智能都有兴趣。
    大家有啥都可以加博主联系方式(qq404006308,微信fan404006308)互相交流。工作、生活、心境,可以互相启迪。
    聊技术,交朋友,修心境,qq404006308,微信fan404006308
    26岁,真心找女朋友,非诚勿扰,微信fan404006308,qq404006308
    人工智能群:939687837

    作者相关推荐

  • 相关阅读:
    最近有点不顺心
    存储过程传入datatable
    mvc下添加 EntityFramework的引用
    vmstat,iostat,sar命令详解
    oracle job interval·相关事例
    dbms_job和dbmsi_job
    数据库hang住 处理过程
    Library cache lock 故障解决一例
    dbms_job涉及到的知识点
    V$SESSION_LONGOPS
  • 原文地址:https://www.cnblogs.com/Renyi-Fan/p/13953362.html
Copyright © 2011-2022 走看看