- 博客(42)
- 资源 (5)
- 收藏
- 关注

原创 python scipy.optimize curve_fit拟合非线性函数
# -*- coding: utf-8 -*-"""Created on Wed Dec 1 23:27:21 2021@author: Machi"""import matplotlib.pyplot as pltimport numpy as npfrom scipy.optimize import curve_fitimport seaborn as snssns.set(color_codes=True)np.random.seed(20211201)e = np.r
2021-12-01 23:36:34
1994
原创 深度学习------神经网络图像识别(tensorflow实现)
本指南将训练一个神经网络模型,对运动鞋和衬衫等服装图像进行分类。即使您不理解所有细节也没关系;这只是对完整 TensorFlow 程序的快速概述,详细内容会在您实际操作的同时进行介绍。本指南使用了 tf.keras,它是 TensorFlow 中用来构建和训练模型的高级 API。
2022-05-13 23:01:31
2135
4
原创 用python计算矩阵特征值和特征向量
import numpy as npA = np.array([[1, -1, 3],[-5, 3, 9],[1, 0, -2]])eigenvalue, featurevector = np.linalg.eig(A)print(eigenvalue)print(featurevector)<<<[-3.27491722 1. 4.27491722][[ 0.43401893 0.6882472 -0.33619158][ 0.83410767 0.6
2022-04-16 14:50:12
6403
2
原创 机器学习决策树
决策树(DTs)是一种用于分类和回归的非参数有监督学习方法。其目标是创建一个模型,通过学习从数据特性中推断出的简单决策规则来预测目标变量的值。决策树的一些优点:1.易于理解和解释。树可以被可视化。2.能够处理多输出问题。3.使用白盒模型。如果给定的情况在模型中是可以观察到的,那么对条件的解释就很容易用布尔逻辑来解释。相反,在黑箱模型中(例如,在人工神经网络中),结果可能很难解释。4.可以使用统计测试验证模型。这样就有可能对模型的可靠性作出解释。5.即使它的假设在某种程度上被生成数据的真实模型所违
2022-04-03 22:13:16
1969
原创 使用SQL Server创建一个表
CREATE TABLE website ( id int NOT NULl, name varchar(20) NOT NULL, url varchar(30), age tinyint NOT NULL, alexa int NOT NULL, PRIMARY KEY (id));--创建一个表sp_help website;--查看表的结构
2022-04-03 21:32:46
160
原创 用python matplotlib进行绘图
Errorbar limit selectionIllustration of selectively drawing lower and/or upper limit symbols on errorbars using the parameters , of errorbar.uplimslolimsAlternatively, you can use 2xN values to draw errorbars in only one direction.Similarly and can be u
2021-12-09 23:17:57
979
原创 python scipy.optimize least_squares实现最小二乘法
Least-squares minimization (least_squares)The code below implements least-squares estimation of and finally plots the original data and the fitted model function:X
2021-12-04 22:56:52
2978
原创 用python进行时间序列分析
import pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport seaborn as sns from statsmodels.graphics.tsaplots import plot_acf from statsmodels.tsa.stattools import adfuller as ADF from statsmodels.graphics.tsaplots import plot_pa
2021-11-20 11:33:06
1854
原创 用python画散点图
# -*- coding: utf-8 -*-"""Created on Tue Nov 16 20:38:41 2021@author: Machi"""import numpy as npimport matplotlib.pyplot as plt# Fixing random state for reproducibility%config InlineBackend.figure_format = 'retina'np.random.seed(19680801)N =
2021-11-16 20:41:12
774
原创 利用python,使用直方图绘制累积分布图
import numpy as npimport matplotlib.pyplot as plt%config InlineBackend.figure_format = 'retina'np.random.seed(190801)mu = 200sigma = 25n_bins = 50x = np.random.normal(mu, sigma, size=100)fig, ax = plt.subplots(figsize=(8, 4))# plot the cumulat
2021-11-16 20:34:34
3505
原创 用python进行方差分析(简单版)
from scipy.stats import f_onewayimport numpy as npx = np.random.normal(10, 5, 20)y = np.random.normal(10, 5, 20)result = f_oneway(x,y)print(result)F_onewayResult(statistic=0.05215619706951725, pvalue=0.8205774635543236)
2021-11-16 12:52:37
2056
原创 利用python的matplotlib库进行简单的绘图
# -*- coding: utf-8 -*-"""Created on Mon Nov 15 21:19:53 2021@author: Machi"""import matplotlib.pyplot as pltimport numpy as np%config InlineBackend.figure_format = 'retina'x = np.linspace(0, 2, 100)# Note that even in the OO-style, we use `.py
2021-11-15 21:30:28
729
原创 用python进行方差分析
# -*- coding: utf-8 -*-"""Created on Sun Nov 14 11:09:44 2021@author: Machi"""import numpy as npimport pandas as pdimport seaborn as snsimport matplotlib.pyplot as pltfrom statsmodels.formula.api import olsfrom statsmodels.stats.anova import an
2021-11-14 12:52:15
893
原创 用r语言进行方差分析
a = rnorm(200)b = rnorm(200)table = data.frame( x = c(a), y = c(b) )aov.manu <- aov(y ~ x, data=table)summary(aov.manu)
2021-11-14 00:08:56
1283
原创 用python实现牛顿法,求解非线性方程的解
# -*- coding: utf-8 -*-"""Created on Sat Nov 13 09:29:27 2021@author: Machi"""import sympy as spx = sp.symbols('x')def f(x): return x**3 - xdef df_value(x,x_value): dy = sp.diff(f(x),x) y_value = float(dy.evalf(
2021-11-13 10:25:10
1075
原创 r语言拟合MA模型,及时序图,自相关图,偏自相关图
e<-rnorm(100)x1<-filter(e,filter = c(1,-0.5),method = "convolution",circular = T)plot(x1)acf(x1)pacf(x1)
2021-11-11 22:52:06
4000
原创 用python求导
# -*- coding: utf-8 -*-"""Created on Mon Nov 8 21:36:35 2021@author: Machi"""import sympy as spx, y, z = sp.symbols('x y z')func = z * sp.sin(2 * sp.pi ** x + x ** y / 5)func_x = sp.diff(func, x)func_y = sp.diff(func, y)func_z = sp.diff(func,
2021-11-08 21:41:33
811
原创 用python求cdf和分位数
# -*- coding: utf-8 -*-"""Created on Fri Nov 5 21:44:19 2021@author: Machi"""from scipy.stats import normq = norm.cdf(0,0,1) print(q)print(norm.ppf(q,0,1)) 0.50.0
2021-11-05 21:47:31
995
原创 正态性检验(偏度和峰度)python
# -*- coding: utf-8 -*-"""Created on Mon Nov 1 20:20:05 2021@author: 86158"""import numpy as npfrom scipy.stats import normaltestv = np.random.normal(size=100)print(normaltest(v))结果:NormaltestResult(statistic=0.2786470828038562, pvalue=0.86
2021-11-01 20:26:03
914
原创 用python求方程的解
# -*- coding: utf-8 -*-"""Created on Mon Nov 1 20:20:05 2021@author: Machi"""from scipy.optimize import rootfrom math import cosdef f(x): return x + cos(x+4)myroot = root(f, 0)print(myroot.x)# 查看更多信息print(myroot)[0.35232971]fjac: array
2021-11-01 20:23:21
335
原创 Python 输出指定范围内的素数
# -*- coding: utf-8 -*-"""Created on Sun Oct 31 22:56:48 2021@author: Machi"""# take input from the userlower = int(input("输入区间最小值: "))upper = int(input("输入区间最大值: "))for num in range(lower,upper + 1): # 素数大于 1 if num > 1: for i in range(2
2021-10-31 22:59:35
481
原创 用python实现牛顿-柯特斯公式
import numpy as npimport mathfrom scipy import integratedef f(x): return math.exp(-x**2)def g(x): return math.exp(-x**2)def func(a,b,n,g): x = np.linspace(a,b,n+1) sum = 0 h =(b-a)/n for i in range(n):
2021-10-30 13:59:36
1477
原创 python求行列式的值
# -*- coding: utf-8 -*-"""Created on Thu Oct 28 16:36:24 2021@author: 86158"""import numpy as npfrom scipy import linalgarr = np.array([[2, 2],[3, 4]])print(arr)a = linalg.det(arr)print(a)输出[[2 2][3 4]]2.0
2021-10-28 16:41:40
618
原创 python安装 和更新所有包的方法
#Install a packagepip install xxxx#View information about installed packagespip list#View packages that can be updatedpip --outdate#The command for pip to update a single package is as followspip install --upgrade xxxxx#Use another plug-in to u
2021-10-28 11:15:04
724
原创 用python计算定积分
# -*- coding: utf-8 -*-"""Created on Tue Oct 26 20:43:46 2021@author: Machi"""from sympy import *x = symbols('x')a = integrate(x**2,(x,0,1))print(a)1/3
2021-10-26 21:09:47
855
原创 用python求积分
from scipy import integratedef f(x): return xvalue, error = integrate.quad(f,-0, 1)print (value,error)0.5 5.551115123125783e-15
2021-10-26 20:58:37
253
原创 用python对数据进行正态性检验(Q-Q检验,KS检验,W检验,偏峰检验)
# -*- coding: utf-8 -*-"""Created on Fri Oct 22 18:07:52 2021@author: Machi"""import numpy as npfrom scipy import statsimport matplotlib.pyplot as pltimport seaborn as snsimport statsmodels.api as sm#Used to display Chinese labelsplt.rcParams
2021-10-22 18:31:36
1608
原创 用python画概率分布图
# -*- coding: utf-8 -*-"""Created on Thu Oct 21 10:07:55 2021@author: Machi"""import pandas as pdimport seaborn as snsdf = pd.read_csv('BSdata.csv')sns.distplot(df['身高'],kde = True, bins = 20,rug = True)
2021-10-21 10:16:10
6441
原创 用python绘制椭圆图
# -*- coding: utf-8 -*-"""Created on Wed Oct 20 21:16:48 2021@author: 86158"""import numpy as npimport mathimport matplotlib.pyplot as plt%config InlineBackend.figure_format = 'retina't = np.linspace(0, 2*math.pi)x = 2*np.sin(t)y = 3*np.cos(
2021-10-20 21:30:24
1548
1
原创 R 数据框Data frame
Data frame can be understood as what we often call “table”.Data frame is the data structure of R language and a special two-dimensional list.Each column of the data frame has a unique column name with equal length. The data types of the same column need
2021-10-16 13:21:28
160
原创 用python创建一个DataFrame
Dataframe is one of the important data structures of pandas and one of the most commonly used structures in the process of using pandas for data analysis. It can be said that if you master the usage of dataframe, you will have the basic ability to learn da
2021-10-16 09:55:29
389
2
原创 用python处理csv文件的重复值
原始数据# -*- coding: utf-8 -*-"""Created on Thu Oct 14 22:09:50 2021@author: Machi"""import pandas as pddf = pd.read_csv('data.csv')df1 = df['x'].drop_duplicates()print(df)print()print(df1)运行结果
2021-10-14 22:18:16
1870
原创 用r语言拟合平稳AR序列,并画出自相关图
Autoregressive model is a statistical method to deal with time series. It uses the same variable, such as the previous periods of X, that is, X1 to xt-1, to predict the performance of XT in this period, and assumes that they are a linear relationship.
2021-10-14 19:41:10
1503
原创 用R语言生成服从正态分布的随机数,并画出直方图。
用R语言生成服从正态分布的随机数,并画出直方图。set.seed(567)x<-rnorm(1000000,0,1)hist(x)效果图
2021-10-14 10:16:33
12170
原创 使用pandas库生成序列(Series)
# -*- coding: utf-8 -*-"""Created on Tue Oct 5 16:55:28 2021@author: Machi"""import pandas as pda = [1, 2, 3,5,7,3,4]aser = pd.Series(a)print(aser)print(aser[1])输出
2021-10-05 17:02:51
665
原创 用python进行多元线性回归,对数据进行中心化和标准化
原始数据# -*- coding: utf-8 -*-"""Created on Tue Oct 5 10:06:41 2021@author: Machi"""import pandas as pdimport statsmodels.formula.api as smfimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dfrom statsmodels.stats.api import an
2021-10-05 11:51:00
2321
原创 用python计算方差,标准差和百分位数
方差是在概率论和统计方差衡量随机变量或一组数据时离散程度的度量。概率论中方差用来度量随机变量和其数学期望(即均值)之间的偏离程度。 标准差(Standard Deviation) ,是离均差平方的算术平均数(即:方差)的算术平方根,用σ表示。标准差也被称为标准偏差,或者实验标准差,在概率统计中最常使用作为统计分布程度上的测量依据。 百分位数,统计学术语,如果将一组数据从小到大排序,并计算相应的累计百分位,则某一百分位所对应数据的值就称为这一百分位的百分位数。可表示为:一组n个观测值按数值大...
2021-09-27 22:09:32
1663
原创 用python计算平均数,中位数和众数
# -*- coding: utf-8 -*-"""Created on Sun Sep 26 22:06:52 2021@author: Machi"""import numpy as nyfrom scipy import statsx = [9,8,8,8,11,8,10,8,9,7,7,8,]#Calculate the average of the X listx_mean = ny.mean(x)#Use the function to find the media
2021-09-26 22:48:10
477
原创 用r语言画时序图和自相关图,并检验纯随机性
p<-ts(data$水位,start=c(1860),frequency=1)#Draw a sequence diagramplot(p,type = "o")#Draw autocorrelation diagramacf(p,lag.max = 25)#Check whether the sequence is a pure random sequenceBox.test(p,lag = 12,type = "Ljung-Box")效果图运行结果Box-Ljun
2021-09-25 09:11:13
4118
2
原创 用python画散点图,建立一元线性回归模型。
原始数据xy15330203452536530405354454045045455import pandas as pdimport matplotlib.pyplot as pltimport statsmodels.formula.api as smf#read filedf = pd.read_csv('2.csv')print(df)#Draw a scatter diagramplt.figure(fi
2021-09-24 15:12:16
3440
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人