python中numpy.ndarray与list的区别?以及用matplotlab.pyplot绘图时的注意事项。
发布日期:2021-05-10 09:17:27 浏览次数:26 分类:精选文章

本文共 780 字,大约阅读时间需要 2 分钟。

import matplotlib.pyplot as pltimport numpy as np# 创建numpy.ndarrayL=np.array([1,2,3,4,5])print('#'*50)print(L)print('L类型:\n{}'.format(type(L)))print('#'*50)L2=L.tolist()print(L2)print('L2类型:\n{}'.format(type(L2)))print('#'*50)plt.plot(L,'s',label='Ridge alpha=1')plt.show()
##################################################[1 2 3 4 5]L类型:
##################################################[1, 2, 3, 4, 5]L2类型:
##################################################

在这里插入图片描述

L3=np.array([[1,2,3,4,5],[2,3,4,5,6]])print('#'*50)print(L3)print('L3类型:\n{}'.format(type(L3)))print('#'*50)plt.plot(L3,'s',label='Ridge alpha=1')plt.show()
##################################################[[1 2 3 4 5] [2 3 4 5 6]]L3类型:
##################################################

在这里插入图片描述

上一篇:深入浅出python机器学习_4.3.1_岭回归的原理 4.3.2_岭回归的参数调节
下一篇:深入浅出python机器学习_4.2.1_线性回归的基本原理 4.2.2_线性回归的性能表现

发表评论

最新留言

初次前来,多多关照!
[***.217.46.12]2025年04月22日 05时24分45秒