先看该库的配置文件
from . import plots
from . import tools
from .plots import cm3, cm2
from .tools import discrete_scatter
from .plot_helpers import ReBl
__version__ = "0.1.7"
__all__ = ['tools', 'plots', 'cm3', 'cm2', 'discrete_scatter', 'ReBl']
下面是简单的理解,暂时写了4条:
1:这个库中的plots模块内有许多已经做好的数据视图。
列如:一行简单的代码,就可以查看线性回归在回归问题中的使用情况。
mglearn.plots.plot_linear_regression_wave()
2:这个库中的cm2、cm3内有配置好的配色方案,在用pyplot作图时可以方便的调用
这是定位到的源代码:
# create a smooth transition from the first to to the second color of cm3
# similar to RdBu but with our red and blue, also not going through white,
# which is really bad for greyscale
cdict = {'red': [(0.0, 0.0, cm2(0)[0]),
(1.0, cm2(1)[0], 1.0)],
'green': [(0.0, 0.0, cm2(0)[1]),
(1.0, cm2(1)[1], 1.0)],
'blue': [(0.0, 0.0, cm2(0)[2]),
(1.0, cm2(1)[2], 1.0)]}
ReBl = LinearSegmentedColormap("ReBl", cdict)
例:
ax.plot(X_train, y_train, '^', c=mglearn.cm2(0), markersize=8)
ax.plot(X_test, y_test, 'v', c=mglearn.cm2(1), markersize=8)
3.这个库中的sklearn.datasets模块内有加载和获取常用数据集的方法、人工生成数据集的工具、
4:这个库中的plots模块对matplotlib.pyplot做出了修改,更适合绘制类和集群。