官术网_书友最值得收藏!

Importing modules

Python itself, like any language, is fairly limited in what it can do. The real power of using Python for machine learning and data mining and data science is the power of all the external libraries that are available for it for that purpose. One of those libraries is called NumPy, or numeric Python, and, for example, here we can import the Numpy package, which is included with Canopy as np.

This means that I'll refer to the NumPy package as np, and I could call that anything I want. I could call it Fred or Tim, but it's best to stick with something that actually makes sense; now that I'm calling that NumPy package np, I can refer to it using np:

import numpy as np

In this example, I'll call the random function that's provided as part of the NumPy package and call its normal function to actually generate a normal distribution of random numbers using these parameters and print them out. Since it is random, I should get different results every time:

import numpy as np
A = np.random.normal(25.0, 5.0, 10)
print (A)

The output should look like this:

Sure enough, I get different results. That's pretty cool.

主站蜘蛛池模板: 蒲江县| 奉贤区| 蛟河市| 阜康市| 宁晋县| 黑山县| 沙雅县| 凯里市| 大田县| 卓资县| 特克斯县| 迁安市| 丹东市| 崇州市| 庆阳市| 岳阳市| 昌图县| 金溪县| 子洲县| 陆良县| 馆陶县| 页游| 定陶县| 垫江县| 临泽县| 沁水县| 金乡县| 八宿县| 秀山| 邵武市| 兰考县| 乌拉特中旗| 法库县| 巴林左旗| 平度市| 石台县| 旬阳县| 四会市| 株洲县| 德化县| 内丘县|