DATA MUNGING
DATA CLEANING PYTHON
MACHINE LEARNING RECIPES
PANDAS CHEATSHEET
ALL TAGS
# How to determine Spearmans correlation in Python?

# How to determine Spearmans correlation in Python?

This recipe helps you determine Spearmans correlation in Python

Spearman"s correlation is very important statical data that we need many times. We can calculate it manually but it takes time.

So this is the recipe on how we can determine Spearman"s correlation in Python

```
import matplotlib.pyplot as plt
import scipy.stats
import pandas as pd
import random
import seaborn as sns
```

We have imported stats, seaborn and pandas which is needed.

We have created a empty dataframe and then added rows to it with random numbers.
```
df = pd.DataFrame()
df["x"] = random.sample(range(1, 100), 75)
df["y"] = random.sample(range(1, 100), 75)
print(); print(df.head())
```

We hawe defined a function with differnt steps that we will see.

- We have calculated rank of x and y and passed it in the function scipy.stats.spearmanr().
- We have printed the result as well as the x and y values.

```
xranks = pd.Series(xs).rank()
yranks = pd.Series(ys).rank()
return scipy.stats.spearmanr(xranks, yranks)
```

```
result = spearmans_rank_correlation(df.x, df.y)[0]
print()
print("spearmans_rank_correlation is: ", result)
```

We are ploting regression plot with the fit.
```
sns.lmplot("x", "y", data=df, fit_reg=True)
plt.show()
```

x y 0 90 79 1 50 14 2 47 52 3 74 67 4 54 33 spearmans_rank_correlation is: 0.21755334281650068

The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

Deep Learning Project- Learn to apply deep learning paradigm to forecast univariate time series data.

In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.

In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.

Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.

In this data science project, you will learn how to perform market basket analysis with the application of Apriori and FP growth algorithms based on the concept of association rule learning.

In this machine learning project, we will use binary leaf images and extracted features, including shape, margin, and texture to accurately identify plant species using different benchmark classification techniques.

Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

Use the Amazon Reviews/Ratings dataset of 2 Million records to build a recommender system using memory-based collaborative filtering in Python.