皮尔逊相关系数 相似系数_皮尔逊相关系数

皮尔逊相关系数 相似系数

数据科学和机器学习统计 (STATISTICS FOR DATA SCIENCE AND MACHINE LEARNING)

In the last post, we analyzed the relationship between categorical variables and categorical and continuous variables. In this case, we will analyze the relation between two ratio level or continuous variables.

在上一篇文章中,我们分析了类别变量与类别变量和连续变量之间的关系。 在这种情况下,我们将分析两个比率级别或连续变量之间的关系。

Peason’s Correlation, sometimes just called correlation, is the most used metric for this purpose, it searches the data for a linear relationship between two variables.

Peason的相关性 (有时也称为相关性 )是为此目的最常用的度量标准,它在数据中搜索两个变量之间的线性关系。

Analyzing the correlations is one of the first steps to take in any statistics, data analysis, or machine learning process, it allows data scientists to early detect patterns and possible outcomes of the machine learning algorithms, so it guides us to choose better models.

分析相关性是进行任何统计,数据分析或机器学习过程的第一步之一,它使数据科学家能够及早发现机器学习算法的模式和可能的结果,从而指导我们选择更好的模型。

Correlation is a measure of relation between variables, but cannot prove causality between them.

相关性是变量之间关系的度量,但不能证明变量之间的因果关系。

Some examples of random correlations that exist in the world are found un this website.

在此网站上可以找到世界上存在的随机相关性的一些示例。

Image for post
This example is taken from https://tylervigen.com/spurious-correlations.
此示例取自https://tylervigen.com/spurious-correlations。

In the case of the last graph, it’s clearly not true that one of these variables implies the other one, even having a correlation of 99.79%

在最后一张图的情况下,显然这些变量中的一个隐含了另一个变量,即使相关性为99.79%

散点图 (Scatterplots)

To take the first look to our dataset, a good way to start is to plot pairs of continuous variables, one in each coordinate. Each point on the graph corresponds to a row of the dataset.

首先看一下我们的数据集,一个好的开始方法是绘制成对的连续变量,每个坐标中一个。 图上的每个点都对应于数据集的一行。

Scatterplots give us a sense of the overall relationship between two variables:

散点图使我们大致了解两个变量之间的整体关系:

  • Direction: positive or negative relation, when one variable increases the second one increases or decreases?

    方向:正向或负向关系,当一个变量增加时,第二个变量增加或减少?
  • Strength: how much a variable increases when the second one increases.

    强度:第二个变量增加时变量增加多少。
  • Shape: The relation is linear, quadratic, exponential…?

    形状:该关系是线性,二次方,指数...?

Using scatterplots is a fast technique for detecting outliers if a value is widely separated from the rest, checking the values for this individual will be useful.

如果值与其他值之间的距离较远,则使用散点图是检测异常值的快速技术,检查该个人的值将非常有用。

We will go with the most used data frame when studying machine learning, Iris, a dataset that contains information about iris plant flowers, and the objective of this one is to classify the flowers into three groups: (setosa, versicolor, virginica).

在研究机器学习时,我们将使用最常用的数据框架Iris,该数据集包含有关鸢尾花的信息,而该数据集的目的是将花分为三类:(setosa,versicolor,virginica)。

Image for post
Scatter plot of two iris dataset variables, self-generated.
自生成的两个虹膜数据集变量的散点图。

The objective of the iris dataset is to classify the distinct types of iris with the data that we have, to deliver the best approach to this problem, we want to analyze all the variables that we have available and their relations.

虹膜数据集的目的是用我们拥有的数据对虹膜的不同类型进行分类,以提供解决此问题的最佳方法,我们要分析所有可用变量及其关系。

In the last plot we have the petal length and width variables, and separate the distinct classes of iris in colors, what we can extract from this plot is:

在最后一个绘图中,我们具有花瓣的长度和宽度变量,并用颜色分隔了虹膜的不同类别,我们可以从该绘图中提取出以下内容:

  • There’s a positive linear relationship between both variables.

    这两个变量之间存在正线性关系。
  • Petal length increases approximately 3 times faster than the petal width.

    花瓣长度的增加速度大约是花瓣宽度的3倍。
  • Using these 2 variables the groups are visually differentiable.

    使用这两个变量,这些组在视觉上是可区分的。

散点图矩阵 (Scatter Plot Matrix)

To plot all relations at the same time and on the same graph, the best approach is to deliver a pair plot, it’s just a matrix of all variables containing all the possible scatterplots.

要同时在同一张图上绘制所有关系,最好的方法是绘制一对图,它只是包含所有可能的散点图的所有变量的矩阵。

As you can see, the plot of the last section is in the last row and third column of this matrix.

如您所见,最后一部分的图形位于此矩阵的最后一行和第三列中。

Image for post
Pair plot of two iris dataset variables, self-generated.
自生成两个虹膜数据集变量的配对图。

In this matrix, the diagonal can show distinct plots, in this case, we used the distributions of each one of the iris classes.

在此矩阵中,对角线可以显示不同的图,在这种情况下,我们使用了每个虹膜类别的分布。

Being a matrix, we have two plots for each combination of variables, there’s always a plot combining the same variables inverse of the (column, row), the other side of the diagonal.

作为一个矩阵,对于每种变量组合,我们都有两个图,总有一个图将(列,行)的反变量(对角线的另一侧)的相同变量组合在一起。

Using this matrix we can obtain all the information about all the continuous variables in the dataset easily.

使用此矩阵,我们可以轻松获取有关数据集中所有连续变量的所有信息。

皮尔逊相关系数 (Pearson Correlation Coefficient)

Scatter plots are an important tool for analyzing relations, but we need to check if the relation between variables is significant, to check the lineal correlation between variables we can use the Person’s r, or Pearson correlation coefficient.

散点图是分析关系的重要工具,但是我们需要检查变量之间的关系是否显着,要检查变量之间的线性相关性,可以使用Person的r或Pearson相关系数。

The range of the possible results of this coefficient is (-1,1), where:

该系数可能的结果范围是(-1,1) ,其中:

  • 0 indicates no correlation.

    0表示没有相关性。
  • 1 indicates a perfect positive correlation.

    1表示完全正相关。
  • -1 indicates a perfect negative correlation.

    -1表示完美的负相关。

To calculate this statistic we use the following formula:

要计算此统计信息,我们使用以下公式:

Image for post
Peason’s correlation formula, self-generated.
Peason的相关公式,自生成。

相关系数的检验显着性 (Test significance of correlation coefficient)

We need to check if the correlation is significant for our data, as we already talked about hypothesis testing, in this case:

我们已经讨论过假设检验,在这种情况下,我们需要检查相关性对我们的数据是否有意义:

  • H0 = The variables are unrelated, r = 0

    H0 =变量无关,r = 0

  • Ha = The variables are related, r ≠ 0

    Ha =变量相关,r≠0

This statistic has a t-student distribution with (n-2) degrees of significance, being n the number of values.

此统计信息的t学生分布的有意义度为(n-2)个,值为n个值。

The formula for the t value is the following, and we need to compare the result with the t-student table.

t值的公式如下,我们需要将结果与t学生表进行比较。

Image for post
Peason’s correlation t-student formula, self-generated.
Peason的相关t型学生公式,自生成的。

If our result is bigger than the table value we reject the null hypothesis and say that the variables are related.

如果我们的结果大于表值,则我们拒绝原假设,并说变量是相关的。

确定系数 (Coefficient of determination)

To calculate how much the variation of a variable can affect the variation of the other one, we can use the coefficient of determination, calculated as the . This measure will be very important in regression models.

为了计算一个变量的变化能对另一个变量的变化产生多大的影响,我们可以使用确定系数 ,计算为 。 该度量在回归模型中将非常重要。

摘要 (Summary)

In the last post, we talked about correlation for categorical data and mentioned that the correlation for continuous variables is easier, in this case, we explained how to perform this correlation analysis and how to check if it’s statistically significant.

在上一篇文章中,我们讨论了分类数据的相关性,并提到了连续变量的相关性更容易,在这种情况下,我们说明了如何执行此相关性分析以及如何检查其是否具有统计意义。

Adding to the typical analysis of the statistical significance will give a better understanding about how to use each variable.

除了对统计意义进行典型分析之外,还将对如何使用每个变量有更好的理解。

This is the eleventh post of my particular #100daysofML, I will be publishing the advances of this challenge at GitHub, Twitter, and Medium (Adrià Serra).

这是我特别#100daysofML第十一届文章中,我将出版在GitHub上,Twitter和中型企业(这一挑战的进步阿德里亚塞拉 )。

https://twitter.com/CrunchyML

https://twitter.com/CrunchyML

https://github.com/CrunchyPistacho/100DaysOfML

https://github.com/CrunchyPistacho/100DaysOfML

翻译自: https://medium.com/ai-in-plain-english/pearson-correlation-coefficient-14c55d32c1bb

皮尔逊相关系数 相似系数

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/388853.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【洛谷】P1641 [SCOI2010]生成字符串(思维+组合+逆元)

题目 传送门&#xff1a;QWQ 分析 不想画图。 https://www.luogu.org/problemnew/solution/P1641 好神仙的题啊。 代码 1 // luogu-judger-enable-o22 #include <bits/stdc.h>3 using namespace std;4 typedef long long ll;5 const int maxn15000000;6 const ll MOD2010…

Kubernetes持续交付-Jenkins X的Helm部署

Jenkins X 是一个集成化的 CI / CD 平台&#xff0c;可用于 部署在Kubernetes集群或云计算中心。支持在云计算环境下简单地开发和部署应用。本项目是在Kubernetes上的安装支持工具集。 本工具集中包含&#xff1a; Jenkins - 定制好的流水线和运行环境&#xff0c;完全整合CI/C…

中国石油大学(华东)暑期集训--二进制(BZOJ5294)【线段树】

问题 C: 二进制 时间限制: 1 Sec 内存限制: 128 MB提交: 8 解决: 2[提交] [状态] [讨论版] [命题人:]题目描述 pupil发现对于一个十进制数&#xff0c;无论怎么将其的数字重新排列&#xff0c;均不影响其是不是3的倍数。他想研究对于二进制&#xff0c;是否也有类似的性质。于…

2018年10个最佳项目管理工具及链接

要在任何业务中取得成功&#xff0c;对项目进行适当的管理非常重要。 项目管理是一系列活动&#xff0c;包括计划&#xff0c;执行&#xff0c;控制和完成项目。项目管理工具有助于简化此过程。这里是Best 10项目管理工具及其功能和下载链接的精选列表。1&#xff09;AsanaAsan…

Java 8 新特性之Stream API

1. 概述 1.1 简介 Java 8 中有两大最为重要的改革&#xff0c;第一个是 Lambda 表达式&#xff0c;另外一个则是 Stream API&#xff08;java.util.stream.*&#xff09;。 Stream 是 Java 8 中处理集合的关键抽象概念&#xff0c;它可以指定你希望对集合进行的操作&#xff0c…

[Python设计模式] 第17章 程序中的翻译官——适配器模式

github地址:https://github.com/cheesezh/python_design_patterns 适配器模式 适配器模式&#xff0c;将一个类的接口转换成客户希望的另外一个接口。Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作[DP]。 当系统的数据和行为都正确&#xff0c;但是接口…

Ubuntu中NS2安装详细教程

前言&#xff1a; NS2是指 Network Simulator version 2&#xff0c;NS&#xff08;Network Simulator&#xff09; 是一种针对网络技术的源代码公开的、免费的软件模拟平台&#xff0c;研究人员使用它可以很容易的进行网络技术的开发&#xff0c;而且发展到今天&#xff0c;它…

es6核心特性图

转载于:https://juejin.im/post/5c19e188e51d452db4753925

带你利用一句话完成转场动画

这篇文章主要给大家介绍了关于iOS如何利用一句话完成转场动画的相关资料&#xff0c;文中通过示例代码介绍的非常详细&#xff0c;对大家的学习或者工作具有一定的参考学习价值&#xff0c;需要的朋友们下面来一起学习学习吧前言本文介绍SS_AnimationTransition 的使用方法,利用…

14.vue路由脚手架

一.vue路由&#xff1a;https://router.vuejs.org/zh/ 1、定义 let router new VueRouter({mode:"history/hash",base:"基本路径" 加一些前缀 必须在history模式下有效linkActiveClass:"active", 范围选择linkExactActiveClass:"exact&qu…

工程师、产品经理、数据工程师是如何一起工作的?

做为一名工程师&#xff0c;免不了与产品经理打交道&#xff0c;如果公司大一些&#xff0c;数据量多一些&#xff0c;还会有数据工程师这个角色。今天会和你主要聊一聊在工作中&#xff0c;产品经理和数据工程师在哪些方面对我们工程师的帮助最大&#xff0c;以及我从他们身上…

linux-buff/cache过大导致内存不足-程序异常

2019独角兽企业重金招聘Python工程师标准>>> 问题描述 Linux内存使用量超过阈值&#xff0c;使得Java应用程序无可用内存&#xff0c;最终导致程序崩溃。即使在程序没有挂掉时把程序停掉&#xff0c;系统内存也不会被释放。 找原因的过程 这个问题已经困扰我好几个月…

Android 适配(一)

一、Android适配基础参数1.常见分辨率&#xff08;px&#xff09;oppx 2340x1080oppR15 2280x1080oppor11sp 2160*10801080*1920 (主流屏幕16&#xff1a;9)1080*216018:9 手机主流分辨率&#xff1a; 1080*2160高端 16:9 手机主流分辨率&#xff1a; 1080P (1080*1920) 或 2K …

Source Insight 创建工程(linux-2.6.22.6内核源码)

1. 软件设置 安装完Source Insight&#xff0c;需要对其进行设置添加对“.S”汇编文件的支持&#xff1a; 2. 新建linux-2.6.22.6工程 1&#xff09;选择工程存放的路径&#xff1a; 2&#xff09;下载linux-2.6.22.6内核源码&#xff0c;并解压。在Source Insight中 指定源码的…

课时20:内嵌函数和闭包

目录&#xff1a; 一、global关键字 二、内嵌函数 三、闭包 四、课时20课后习题及答案 ******************** 一、global关键字 ******************** 全局变量的作用域是整个模块&#xff08;整个代码段&#xff09;&#xff0c;也就是代码段内所有的函数内部都可以访问到全局…

从零开始学产品第六篇:更强大的测试,自动化测试和性能测试

本篇为【从零开始学产品】系列课第1章第5节欢迎到公众号菜单栏&#xff0c;获取产品经理课程更多资料 “测试就是拿点鼠标在电脑上瞎点&#xff0c;或者是用手机随便戳几下么&#xff1f;” “不&#xff0c;是有计划有意图的测试&#xff0c;比如说&#xff0c;边界测试&#…

Get 了滤镜、动画、AR 特效,速来炫出你的短视频开发特技!

在滤镜美颜、搞怪特效、炫酷场景等各种新奇玩法驱动下&#xff0c;短视频开始让人上瘾。 12 月 3 日&#xff0c;七牛云联合八大短视频特效平台共同推出了中国短视频开发者创意大赛&#xff08;China Short Video Contest&#xff09;&#xff0c;面向全国邀请广大开发者&#…

匿名函数、冒泡排序,二分法, 递归

匿名函数 lambda 匿名函数 格式 lambda 参数&#xff1a;返回值 函数名统一叫lambda&#xff0c;最多只能写一行普通的正常的函数 def func(n):return n * n lambda匿名函数写法 a lambda n : n**2 print(a(3)) 当有多个返回值时suiyi lambda x, y : (1, 2) # 笔试题 …

Redis源码剖析

Redis源码剖析和注释&#xff08;一&#xff09;---链表结构 Redis源码剖析和注释&#xff08;二&#xff09;--- 简单动态字符串 Redis源码剖析和注释&#xff08;三&#xff09;--- Redis 字典结构 Redis源码剖析和注释&#xff08;四&#xff09;--- 跳跃表(skiplist) Redis…

Android Activity生命周期

Android生命周期 Android的生命周期&#xff1a;onCreate() -> onStart() -> onResume() -> onPause() -> onStop() -> onDestroy() 如下图所示&#xff1a; 1.当activity启动时系统会先调用onCreate(),然后调用onStart(),最后调用**onResume()**方法&#xff0…