Python in numpy module

Source: Internet
Author: User

The difference between From...import and import is that import imports the specified library directly, whereas From....import imports the specified module from the specified library.

Import...as is the import a as B, giving a library a nickname for a B, to help memory

In machine learning, an object is a line vector that contains a set of features. The most outstanding technology in this field is the GPU operation using graphics processor, one of the important features of vectorization programming is that we can directly convert the mathematical formula into the corresponding program code, the dimension refers to the number of parameters required to describe a mathematical object under certain premise, and the complete expression should be "object x based on premise A is N dimension".

The effect of scatter (x, y) and plot (x, y, ' * ') is to draw a little bit according to the X and Y coordinates.

Plot, by default, connects all points in a certain order into a polyline. When plot specifies linearity, it is possible to draw different images, such as plot (x, y, ' * ')

Here is a test procedure:

#-*-Coding:utf-8-*-
# Filename:mytest1.py
Import NumPy as NP # imports NumPy Library
From numpy import * # importing NumPy libraries
Import Matplotlib.pyplot as PLT # importing Matplotlib libraries
# test Data Set-two-D list
DataSet = [[ -0.017612,14.053064],[-1.395634, 4.662541],[-0.752157
, 6.538620],[-1.322371, 7.152853],[0.423363, 11.054677],[0.406704
, 7.067335],[0.667394, 12.741452], [-2.460150, 6.866805],[0.569411
, 9.548755],[-0.026632, 10.427743],[0.850433, 6.920334],[1.347183
, 13.175500],[1.176813, 3.167020],[-1.781871, 9.097953]
Datamat = Mat (DataSet). T # Convert the dataset to the NumPy matrix and transpose
Plt.scatter (datamat[0],datamat[1],c= ' red ', marker= ' O ') # Plot data hubs graph
# Draw a straight line graphic
X = Np.linspace ( -2,2,100) # produces a straight data set
# Establishing a linear equation
Y = 2.8*x+9
Plt.plot (x, y) # Draw a straight line graph
Plt.show () # shows the result after drawing

The output results are as follows:

Understanding Mathematical Formulae and Numpy

Import NumPy as NP
Myzero = Np.zeros ([3,5])
Print Myzero
print ' \ n '
Myones = Np.ones ([3,5])
Print Myones
print ' \ n '
Myrand = Np.random.rand (3,4)
Print Myrand
print ' \ n '
MyEye = Eye (3)
Print MyEye

Output Result:

[0.0.  0.0. 0.]
[0.0.  0.0. 0.]
[0.0.  0.0. 0.]


[1.1.  1.1. 1.]
[1.1.  1.1. 1.]
[1.1.  1.1. 1.]


[[0.08391638 0.45111372 0.13425541 0.4058907]
[0.4899189 0.09429184 0.49567921 0.05946378]
[0.9062396 0.34326417 0.43128689 0.73593377]]


[1.0. 0.]
[0.1. 0.]
[0.0. 1.]

Python in numpy module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.