sklearn学习

sklearn.preprocessing

包提供几种常用的效用函数及转换器类,用于更改原始特征向量表示形式以适应后续评估量。

sklearn.preprocessing.scale()函数

sklearn.preprocessing.scale(X, axis=0, with_mean=True, with_std=True, copy=True)

matplotlib

颜色

fill_between()函数

import matplotlib.pyplot as plt

import numpy as np

向下填充

#准备数据

x = np.array([i for i in range(30)])

y = np.random.rand(30)

#绘图

plt.plot(x, y)  # 划线

plt.fill_between(x, 0, y, facecolor='green', alpha=0.3) #向下填充

plt.show() #显示图形

参考https://blog.csdn.net/kabuto_hui/article/details/84979606

在2条线之间填充

x = np.array([i for i in range(15)])

y1 = np.random.rand(15)

y2 = np.random.rand(15)

#画线

plt.plot(x, y1)  # 先将图画出来

plt.plot(x, y2)  # 先将图画出来

plt.fill_between(x, y1, y2,where=y1>=y2,facecolor='green', alpha=0.3) #填图

plt.fill_between(x, y1, y2,where=y1<y2,facecolor='red', alpha=0.3)#填图

plt.show()

narray转换为Series、DataFrame

arr3=array([0, 1, 2, 3])                                        

pd.Series(arr3,index=['a','b','c','d'])    

pd.DataFrame(arr3,index=['a','b','c','d'])    

1

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容