{"id":1259,"date":"2023-07-27T02:41:58","date_gmt":"2023-07-27T02:41:58","guid":{"rendered":"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/"},"modified":"2023-07-27T02:41:58","modified_gmt":"2023-07-27T02:41:58","slug":"correlacao-lanceiro-python","status":"publish","type":"post","link":"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/","title":{"rendered":"Como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de spearman em python"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Nas estat\u00edsticas, <strong>a correla\u00e7\u00e3o<\/strong> refere-se \u00e0 for\u00e7a e \u00e0 dire\u00e7\u00e3o de uma rela\u00e7\u00e3o entre duas vari\u00e1veis. O valor de um coeficiente de correla\u00e7\u00e3o pode variar de -1 a 1, com as seguintes interpreta\u00e7\u00f5es:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>-1:<\/strong> uma rela\u00e7\u00e3o negativa perfeita entre duas vari\u00e1veis<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>0:<\/strong> nenhuma rela\u00e7\u00e3o entre duas vari\u00e1veis<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>1:<\/strong> uma rela\u00e7\u00e3o positiva perfeita entre duas vari\u00e1veis<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Um tipo especial de correla\u00e7\u00e3o \u00e9 chamado <strong>de correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman<\/strong> , que \u00e9 usada para medir a correla\u00e7\u00e3o entre duas vari\u00e1veis classificadas. (por exemplo, a classifica\u00e7\u00e3o da pontua\u00e7\u00e3o no exame de matem\u00e1tica de um aluno em rela\u00e7\u00e3o \u00e0 classifica\u00e7\u00e3o da pontua\u00e7\u00e3o no exame de ci\u00eancias em uma turma).<\/span><\/p>\n<p> <span style=\"color: #000000;\">Este tutorial explica como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman entre duas vari\u00e1veis em Python<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Exemplo: correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Suponha que temos o seguinte DataFrame do pandas que cont\u00e9m<\/span> <span style=\"color: #000000;\">a pontua\u00e7\u00e3o do exame de matem\u00e1tica e a pontua\u00e7\u00e3o do exame de ci\u00eancias de 10 alunos em uma turma espec\u00edfica:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd<\/span>\n\n#createDataFrame<\/span>\ndf = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({'student': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'],\n                   'math': [70, 78, 90, 87, 84, 86, 91, 74, 83, 85],\n                   'science': [90, 94, 79, 86, 84, 83, 88, 92, 76, 75]})\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Para calcular a correla\u00e7\u00e3o do Spearman Rank entre as pontua\u00e7\u00f5es de matem\u00e1tica e ci\u00eancias, podemos usar a fun\u00e7\u00e3o <a href=\"https:\/\/docs.scipy.org\/doc\/scipy\/reference\/generated\/scipy.stats.spearmanr.html\" target=\"_blank\" rel=\"noopener noreferrer\">spearmanr()<\/a> em <strong>scipy.stats<\/strong> :<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\"><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">from<\/span> scipy. <span style=\"color: #3366ff;\">stats<\/span> <span style=\"color: #008000;\">import<\/span> spearmanr\n<\/span>\n#calculate Spearman Rank correlation and corresponding p-value<\/span><\/span>\nrho, p = spearmanr(df[' <span style=\"color: #008000;\">math<\/span> '], df[' <span style=\"color: #008000;\">science<\/span> '])\n\n<span style=\"color: #008080;\">#print Spearman rank correlation and p-value\n<\/span><span style=\"color: #3366ff;\">print<\/span> (rho)\n\n-0.41818181818181815\n\n<span style=\"color: #3366ff;\">print<\/span> (p)\n\n0.22911284098281892\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">A partir do resultado, podemos ver que a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman \u00e9 <strong>-0,41818<\/strong> e o valor p correspondente \u00e9 <strong>0,22911<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Isso indica que h\u00e1 uma correla\u00e7\u00e3o negativa entre as notas dos exames de ci\u00eancias e matem\u00e1tica.<\/span><\/p>\n<p> <span style=\"color: #000000;\">No entanto, como o valor p da correla\u00e7\u00e3o n\u00e3o \u00e9 inferior a 0,05, a correla\u00e7\u00e3o n\u00e3o \u00e9 estatisticamente significativa.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Observe que tamb\u00e9m poder\u00edamos usar a seguinte sintaxe para simplesmente extrair o coeficiente de correla\u00e7\u00e3o ou valor p:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#extract Spearman Rank correlation coefficient\n<\/span>spearmanr(df[' <span style=\"color: #008000;\">math<\/span> '], df[' <span style=\"color: #008000;\">science<\/span> '])[0]\n\n-0.41818181818181815\n\n<span style=\"color: #008080;\">#extract p-value of Spearman Rank correlation coefficient<\/span>\nspearmanr(df[' <span style=\"color: #008000;\">math<\/span> '], df[' <span style=\"color: #008000;\">science<\/span> '])[1] \n\n0.22911284098281892\n<\/span><\/span><\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Recursos adicionais<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/pt\/teste-de-correlacao-em-r\/\" target=\"_blank\" rel=\"noopener noreferrer\">Como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em R<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/correlacao-de-classificacao-de-lanceiro-excel\/\" target=\"_blank\" rel=\"noopener noreferrer\">Como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman no Excel<\/a><br \/> <a href=\"https:\/\/statorials.org\/pt\/correlacoes-estatisticas\/\" target=\"_blank\" rel=\"noopener noreferrer\">Como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman no Stata<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nas estat\u00edsticas, a correla\u00e7\u00e3o refere-se \u00e0 for\u00e7a e \u00e0 dire\u00e7\u00e3o de uma rela\u00e7\u00e3o entre duas vari\u00e1veis. O valor de um coeficiente de correla\u00e7\u00e3o pode variar de -1 a 1, com as seguintes interpreta\u00e7\u00f5es: -1: uma rela\u00e7\u00e3o negativa perfeita entre duas vari\u00e1veis 0: nenhuma rela\u00e7\u00e3o entre duas vari\u00e1veis 1: uma rela\u00e7\u00e3o positiva perfeita entre duas vari\u00e1veis [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-1259","post","type-post","status-publish","format-standard","hentry","category-guia"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python<\/title>\n<meta name=\"description\" content=\"Este tutorial explica como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python, com v\u00e1rios exemplos.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python\" \/>\n<meta property=\"og:description\" content=\"Este tutorial explica como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python, com v\u00e1rios exemplos.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-27T02:41:58+00:00\" \/>\n<meta name=\"author\" content=\"Dr. benjamim anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr. benjamim anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo estimado de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/\",\"url\":\"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/\",\"name\":\"Como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/pt\/#website\"},\"datePublished\":\"2023-07-27T02:41:58+00:00\",\"dateModified\":\"2023-07-27T02:41:58+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\"},\"description\":\"Este tutorial explica como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python, com v\u00e1rios exemplos.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Lar\",\"item\":\"https:\/\/statorials.org\/pt\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de spearman em python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/pt\/#website\",\"url\":\"https:\/\/statorials.org\/pt\/\",\"name\":\"Statorials\",\"description\":\"O seu guia para a literacia estat\u00edstica!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/pt\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"pt-PT\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666\",\"name\":\"Dr. benjamim anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\/\/statorials.org\/pt\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr. benjamim anderson\"},\"description\":\"Ol\u00e1, sou Benjamin, um professor aposentado de estat\u00edstica que se tornou professor dedicado na Statorials. Com vasta experi\u00eancia e conhecimento na \u00e1rea de estat\u00edstica, estou empenhado em compartilhar meu conhecimento para capacitar os alunos por meio de Statorials. Saber mais\",\"sameAs\":[\"https:\/\/statorials.org\/pt\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python","description":"Este tutorial explica como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python, com v\u00e1rios exemplos.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/","og_locale":"pt_PT","og_type":"article","og_title":"Como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python","og_description":"Este tutorial explica como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python, com v\u00e1rios exemplos.","og_url":"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/","og_site_name":"Statorials","article_published_time":"2023-07-27T02:41:58+00:00","author":"Dr. benjamim anderson","twitter_card":"summary_large_image","twitter_misc":{"Escrito por":"Dr. benjamim anderson","Tempo estimado de leitura":"2 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/","url":"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/","name":"Como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python","isPartOf":{"@id":"https:\/\/statorials.org\/pt\/#website"},"datePublished":"2023-07-27T02:41:58+00:00","dateModified":"2023-07-27T02:41:58+00:00","author":{"@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666"},"description":"Este tutorial explica como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de Spearman em Python, com v\u00e1rios exemplos.","breadcrumb":{"@id":"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/pt\/correlacao-lanceiro-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Lar","item":"https:\/\/statorials.org\/pt\/"},{"@type":"ListItem","position":2,"name":"Como calcular a correla\u00e7\u00e3o de classifica\u00e7\u00e3o de spearman em python"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/pt\/#website","url":"https:\/\/statorials.org\/pt\/","name":"Statorials","description":"O seu guia para a literacia estat\u00edstica!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/pt\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"pt-PT"},{"@type":"Person","@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/e08f98e8db95e0aa9c310e1b27c9c666","name":"Dr. benjamim anderson","image":{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/statorials.org\/pt\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/pt\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr. benjamim anderson"},"description":"Ol\u00e1, sou Benjamin, um professor aposentado de estat\u00edstica que se tornou professor dedicado na Statorials. Com vasta experi\u00eancia e conhecimento na \u00e1rea de estat\u00edstica, estou empenhado em compartilhar meu conhecimento para capacitar os alunos por meio de Statorials. Saber mais","sameAs":["https:\/\/statorials.org\/pt"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/1259","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/comments?post=1259"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/posts\/1259\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/media?parent=1259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/categories?post=1259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/pt\/wp-json\/wp\/v2\/tags?post=1259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}