python绘制dca曲线_Python数据处理从零开始----第四章(可视化)(9)线性相关曲线...
原文:Python數據處理從零開始----第四章(可視化)(9)線性相關曲線?www.jianshu.com
===============================================
通過python我們可以繪制兩個變量的相關圖,我所使用的是皮爾森相關,主要的參數是:①r相關系數②P值。一般對P值的評判標準是P< 0.05簡單的相關系數的分類
0.8-1.0 極強相關
0.6-0.8 強相關
0.4-0.6 中等程度相關
0.2-0.4 弱相關
0.0-0.2 極弱相關或無相關
r描述的是兩個變量間線性相關強弱的程度。r的取值在-1與+1之間,若r>0,表明兩個變量是正相關,即一個變量的值越大,另一個變量的值也會越大;若r<0,表明兩個變量是負相關,即一個變量的值越大另一個變量的值反而會越小。r 的絕對值越大表明相關性越強,要注意的是這里并不存在因果關系。
基礎擬合曲線繪制
# -*- coding: utf-8 -*- """ Created on Mon Nov 19 00:57:53 2018 @author: czh """ # In[*] #導入各種需要的包# import numpy as np import matplotlib.pyplot as plt from scipy import optimize import seaborn as sns sns.set() # In[*] import seaborn as sns sns.set(style="darkgrid") tips = sns.load_dataset("tips") g = sns.jointplot("total_bill", "tip", data=tips, kind="reg", xlim=(0, 60), ylim=(0, 12), color="m", height=7)
這是通過python語言繪制的線性相關曲線擬合圖,感覺比R語言在代碼上更簡潔,且圖片能展示的信息更多。
多分組擬合曲線繪制
# -*- coding: utf-8 -*- """ Created on Mon Nov 19 00:57:53 2018 @author: czh """ # In[*] #導入各種需要的包# import numpy as np import matplotlib.pyplot as plt from scipy import optimize import seaborn as sns sns.set() # In[*] # Load the iris dataset iris = sns.load_dataset("iris") # Plot sepal with as a function of sepal_length across days g = sns.lmplot(x="sepal_length", y="sepal_width",hue='species', truncate=True, height=5, data=iris) # Use more informative axis labels than are provided by default g.set_axis_labels("Sepal length (mm)", "Sepal width (mm)")
多變量子圖擬合曲線繪制
# -*- coding: utf-8 -*- """ Created on Wed Dec 26 11:17:56 2018 @author: czh """ %reset -f %clear # In[*] from matplotlib import pyplot as plt import numpy as np import pandas as pd import lifelines as ll from IPython.display import HTML %matplotlib inline import matplotlib.pyplot as plt import seaborn as sns import plotly.plotly as py import plotly.tools as tls from plotly.graph_objs import * import os from scipy import stats from lifelines.estimation import KaplanMeierFitter kmf = KaplanMeierFitter() from lifelines.statistics import logrank_test from sklearn.preprocessing import StandardScaler os.chdir("D:\\Rwork\\third\\Fig2") # In[*] # Import Data df = pd.read_csv("https://raw.githubusercontent.com/selva86/datasets/master/mpg_ggplot2.csv") df_select = df.loc[df.cyl.isin([4,8]), :] # Each line in its own column sns.set_style("white") gridobj = sns.lmplot(x="displ", y="hwy", data=df_select, height=7, robust=True, palette='Set1', col="cyl", scatter_kws=dict(s=60, linewidths=.7, edgecolors='black')) # Decorations gridobj.set(xlim=(0.5, 7.5), ylim=(0, 50)) plt.show()
總結
以上是生活随笔為你收集整理的python绘制dca曲线_Python数据处理从零开始----第四章(可视化)(9)线性相关曲线...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: [cognexVisionPro]错误:
- 下一篇: python打包代码中涉及的图片_pyi