python 工具箱_掌握python最佳运输工具箱第1部分的指南

python 工具箱

As a follow-up of the introductory article on optimal transport by Ievgen Redko, I will present below how you can solve Optimal Transport (OT) in practice using the Python Optimal Transport (POT) toolbox.

作为Ievgen Redko 关于最佳运输的入门文章的后续,我将在下面介绍如何使用Python最佳运输(POT)工具箱在实践中解决最佳运输(OT)。

To start with, let us install POT using pip from the terminal by simply running

首先,让我们简单地从终端使用pip安装POT

pip3 install pot

Or with conda

或用conda

conda install -c conda-forge pot

If everything went well, you now have POT installed and ready to use on your computer.

如果一切顺利,那么您现在已经安装了POT,可以在计算机上使用了。

POT Python最佳运输工具箱 (POT Python Optimal Transport Toolbox)

导入工具箱 (Import the toolbox)

import numpy as np # always need it
import scipy as sp # often use it
import pylab as pl # do the plotsimport ot # ot

获得帮助 (Getting help)

The online documentation of POT is available at http://pot.readthedocs.io, or you can check the inline help help(ot.dist) .

有关POT的在线文档,请访问http://pot.readthedocs.io,也可以查看内联帮助help(ot.dist)

We are now ready to start our example.

现在我们准备开始我们的示例。

简单的OT问题 (Simple OT Problem)

We will solve the Bakery/Cafés problem of transporting croissants from a number of Bakeries to Cafés in a City (in this case Manhattan). We did a quick google map search in Manhattan for bakeries and Cafés:

我们将解决面包店/咖啡馆将羊角面包从许多面包店运送到城市中的咖啡馆的问题(在本例中为曼哈顿)。 我们在曼哈顿进行了谷歌地图快速搜索,搜索面包店和咖啡馆:

We extracted from this search their positions and generated fictional production and sale number (that both sum to the same value).

我们从此搜索中提取了他们的职位,并生成了虚构的生产和销售数量(两者的总和为相同的值)。

We have access to the position of Bakeries bakery_pos and their respective production bakery_prod which describe the source distribution. The Cafés where the croissants are sold are defined also

你可能感兴趣的:(python)