先看该库的配置文件

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()

对mglearn库的理解

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做出了修改,更适合绘制类和集群。

相关文章:

  • 2021-12-22
  • 2021-11-14
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-12-05
  • 2022-01-08
猜你喜欢
  • 2021-08-15
  • 2021-05-29
  • 2022-12-23
  • 2021-07-05
  • 2022-12-23
  • 2021-06-09
  • 2021-09-23
相关资源
相似解决方案