ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Day 15:一些数据分析、机器学习和深度学习包和框架&&入门案例

2021-07-04 15:00:40  阅读:223  来源: 互联网

标签:plt 15 print && np import numpy Day polynomial


NumPy

简单介绍一下数值计算库numpy, 主要用来存储和计算矩阵。https://numpy.org/

主要功能包括:

  1. N 维数组对象 Array(最基本的数据结构)
  2. 成熟的广播机制
  3. 能够解决线性代数、随机数生成数相关问题
import numpy as np
import numpy.linalg as lg #求逆

 

 

 

#了解线性代数例程
# Import required modules/ libraries
import numpy as np
from scipy import linalg
 
# We are trying to solve a linear algebra system which can be given as:
#               1x + 2y =5
#               3x + 4y =6
# Create input array
A= np.array([[1,2],[3,4]])
 
# Solution Array
B= np.array([[5],[6]])
 
# Solve the linear algebra
X= linalg.solve(A,B)
print(X)
 
# Checking Results
print("\n Checking results, following vector should be all zeros")
print(A.dot(X)-B)

output:
[[-4. ]
 [ 4.5]]

 Checking results, following vector should be all zeros
[[0.]
 [0.]]

 

SciPy

 基于 Python,也是用于数学计算的工具包。https://www.scipy.org/

import scipy
import numpy
#多项式
from numpy import poly1d
myPolynomial = poly1d([1,2,3])
print(myPolynomial)

print("\nSquaring the polynomial: \n")
print(myPolynomial* myPolynomial)

print("\nIntegrating the polynomial: \n")
print(myPolynomial.integ(k=3))

print("\nFinding derivative of the polynomial: \n")
print(myPolynomial.deriv())

print("\nSolving the polynomial for 2: \n")
print(myPolynomial(2))

output:
   2
1 x + 2 x + 3

Squaring the polynomial: 

   4     3      2
1 x + 4 x + 10 x + 12 x + 9

Integrating the polynomial: 

        3     2
0.3333 x + 1 x + 3 x + 3

Finding derivative of the polynomial: 

 
2 x + 2

Solving the polynomial for 2: 

11
View Code
#科学傅立叶变换 (SciPy Fourier Transforms)
# Import Fast Fourier Transformation requirements
from scipy.fftpack import fft
import numpy as np
 
# Number of sample points
N = 600
 
# sample spacing
T = 1.0 / 800.0
x = np.linspace(0.0, N*T, N)
y = np.sin(50.0 * 2.0*np.pi*x) + 0.5*np.sin(80.0 * 2.0*np.pi*x)
yf = fft(y)
xf = np.linspace(0.0, 1.0/(2.0*T), N//2)
 
# matplotlib for plotting purposes
import matplotlib.pyplot as plt
plt.plot(xf, 2.0/N * np.abs(yf[0:N//2]))
plt.grid()
plt.show()

 

 使用Matplotlib绘制图表。

 

 

   SciPy的特殊子软件包定义了许多数学物理学的功能。 可用功能包括通风,贝塞尔,贝塔,椭圆,伽马,超几何,开尔文,马修,抛物柱面,球面波和曲面。

  让我们看一下贝塞尔函数例子。

# Import special package
from scipy import special
import numpy as np
def drumhead_height(n, k, distance, angle, t):
    kth_zero = special.jn_zeros(n, k)[-1]
    return np.cos(t) * np.cos(n*angle) * special.jn(n, distance*kth_zero)
theta = np.r_[0:2*np.pi:50j]
radius = np.r_[0:1:50j]
x = np.array([r * np.cos(theta) for r in radius])
y = np.array([r * np.sin(theta) for r in radius])
z = np.array([drumhead_height(1, 1, r, theta, 0.5) for r in radius])
 
# Plot the results for visualization
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
fig = plt.figure()
ax = Axes3D(fig)
ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap=cm.jet)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
plt.show()

 

 

 

Pandas

Pandas 是 Python 中,功能强大的数据分析库。提供关于数据分析高级的数据结构,各种各样的分析工具,确保整个数据处理的过程更加容易。https://pandas.pydata.org/

Matplotlib

python 中非常强大的 2D 绘图工具。提供方便易用的绘图接口,能使用在 Python 脚本,IPython shell、Jupyter Notebook、Web 应用服务器等。https://matplotlib.org/

Seaborn

Seaborn 是一个基于 Matplotlib 的 Python 数据可视化库,提供绘制更加高层和优美的图形接口。http://seaborn.pydata.org/

scikit-learn

scikit-learn 是适用于数据处理和机器学习处理非常强大的库。提供数据降维、回归、聚类、分类等功能,是机器学习从业者的必备库之一。https://scikit-learn.org/

TensorFlow

TensorFlow 由 Google 与 Brain Team 合作开发,是一个采用数据流图(data flow graphs),用于数值计算的开源软件库。http://www.tensorfly.cn/

PyTorch

PyTorch 是使用 GPU 和 CPU 优化的深度学习张量库,也是深度学习的重要的一个库。

https://pytorch.org/

标签:plt,15,print,&&,np,import,numpy,Day,polynomial
来源: https://www.cnblogs.com/PiaYie/p/14968973.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有