Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Useful Functions for Researching and Visualizing Dataset | What is the Linear Regression?
Explore the Linear Regression Using Python
course content

Course Content

Explore the Linear Regression Using Python

Explore the Linear Regression Using Python

1. What is the Linear Regression?
2. Correlation
3. Building and Training Model
4. Metrics to Evaluate the Model
5. Multivariate Linear Regression

Useful Functions for Researching and Visualizing Dataset

To get information on our dataset, we can also use the function .describe(). This method shows the summary statistics of your dataset: mean, median, standard deviation, and so on. For example, we are adding this line to the previous code to show all these characteristics of wines:

1
print(data.describe())
copy

If it is inconvenient for us to work with many digits, we can use method .round(n), where n is the number of decimal places to which you are rounding.

Numbers are great, but it's still not entirely clear what they represent. For this reason, we will use visualization to see what’s going on in our dataset. It is good to see the dataset's representation before building the regression line. The well-known library matplotlib.pyplot is irreplaceable in this situation. To see all our data as a histogram, just use method .hist(). To get a particular chart we are interested in, we can define it in parentheses. Moreover, we can set the bins by using the bins = argument.

For example, here we will see the histogram of color intensity having 20 bins:

1234567891011121314151617181920
# Import the libraries import matplotlib.pyplot as plt import pandas as pd from sklearn.datasets import load_wine # Load dataset wine = load_wine() # Configure pandas to show all features pd.set_option('display.max_rows', None, 'display.max_columns', None) # Convert data to a dataframe to view properly data = pd.DataFrame(data = wine['data'], columns = wine['feature_names']) # Get all information about our dataset print(data.describe()) # Visualize the data data.hist(column = 'color_intensity',bins = 20) plt.show()
copy

Output:

Task

Let’s see what's going on inside our set.

  1. [Line #7] Load wine set.
  2. [Line #16] Get and print all information about it using the function .describe().
  3. [Line #19] Visualize data about alcohol consistency in the set, setting column = 'alcohol' and defining bins = 15.

Task

Let’s see what's going on inside our set.

  1. [Line #7] Load wine set.
  2. [Line #16] Get and print all information about it using the function .describe().
  3. [Line #19] Visualize data about alcohol consistency in the set, setting column = 'alcohol' and defining bins = 15.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 1. Chapter 5
toggle bottom row

Useful Functions for Researching and Visualizing Dataset

To get information on our dataset, we can also use the function .describe(). This method shows the summary statistics of your dataset: mean, median, standard deviation, and so on. For example, we are adding this line to the previous code to show all these characteristics of wines:

1
print(data.describe())
copy

If it is inconvenient for us to work with many digits, we can use method .round(n), where n is the number of decimal places to which you are rounding.

Numbers are great, but it's still not entirely clear what they represent. For this reason, we will use visualization to see what’s going on in our dataset. It is good to see the dataset's representation before building the regression line. The well-known library matplotlib.pyplot is irreplaceable in this situation. To see all our data as a histogram, just use method .hist(). To get a particular chart we are interested in, we can define it in parentheses. Moreover, we can set the bins by using the bins = argument.

For example, here we will see the histogram of color intensity having 20 bins:

1234567891011121314151617181920
# Import the libraries import matplotlib.pyplot as plt import pandas as pd from sklearn.datasets import load_wine # Load dataset wine = load_wine() # Configure pandas to show all features pd.set_option('display.max_rows', None, 'display.max_columns', None) # Convert data to a dataframe to view properly data = pd.DataFrame(data = wine['data'], columns = wine['feature_names']) # Get all information about our dataset print(data.describe()) # Visualize the data data.hist(column = 'color_intensity',bins = 20) plt.show()
copy

Output:

Task

Let’s see what's going on inside our set.

  1. [Line #7] Load wine set.
  2. [Line #16] Get and print all information about it using the function .describe().
  3. [Line #19] Visualize data about alcohol consistency in the set, setting column = 'alcohol' and defining bins = 15.

Task

Let’s see what's going on inside our set.

  1. [Line #7] Load wine set.
  2. [Line #16] Get and print all information about it using the function .describe().
  3. [Line #19] Visualize data about alcohol consistency in the set, setting column = 'alcohol' and defining bins = 15.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

Section 1. Chapter 5
toggle bottom row

Useful Functions for Researching and Visualizing Dataset

To get information on our dataset, we can also use the function .describe(). This method shows the summary statistics of your dataset: mean, median, standard deviation, and so on. For example, we are adding this line to the previous code to show all these characteristics of wines:

1
print(data.describe())
copy

If it is inconvenient for us to work with many digits, we can use method .round(n), where n is the number of decimal places to which you are rounding.

Numbers are great, but it's still not entirely clear what they represent. For this reason, we will use visualization to see what’s going on in our dataset. It is good to see the dataset's representation before building the regression line. The well-known library matplotlib.pyplot is irreplaceable in this situation. To see all our data as a histogram, just use method .hist(). To get a particular chart we are interested in, we can define it in parentheses. Moreover, we can set the bins by using the bins = argument.

For example, here we will see the histogram of color intensity having 20 bins:

1234567891011121314151617181920
# Import the libraries import matplotlib.pyplot as plt import pandas as pd from sklearn.datasets import load_wine # Load dataset wine = load_wine() # Configure pandas to show all features pd.set_option('display.max_rows', None, 'display.max_columns', None) # Convert data to a dataframe to view properly data = pd.DataFrame(data = wine['data'], columns = wine['feature_names']) # Get all information about our dataset print(data.describe()) # Visualize the data data.hist(column = 'color_intensity',bins = 20) plt.show()
copy

Output:

Task

Let’s see what's going on inside our set.

  1. [Line #7] Load wine set.
  2. [Line #16] Get and print all information about it using the function .describe().
  3. [Line #19] Visualize data about alcohol consistency in the set, setting column = 'alcohol' and defining bins = 15.

Task

Let’s see what's going on inside our set.

  1. [Line #7] Load wine set.
  2. [Line #16] Get and print all information about it using the function .describe().
  3. [Line #19] Visualize data about alcohol consistency in the set, setting column = 'alcohol' and defining bins = 15.

Switch to desktop for real-world practiceContinue from where you are using one of the options below

Everything was clear?

To get information on our dataset, we can also use the function .describe(). This method shows the summary statistics of your dataset: mean, median, standard deviation, and so on. For example, we are adding this line to the previous code to show all these characteristics of wines:

1
print(data.describe())
copy

If it is inconvenient for us to work with many digits, we can use method .round(n), where n is the number of decimal places to which you are rounding.

Numbers are great, but it's still not entirely clear what they represent. For this reason, we will use visualization to see what’s going on in our dataset. It is good to see the dataset's representation before building the regression line. The well-known library matplotlib.pyplot is irreplaceable in this situation. To see all our data as a histogram, just use method .hist(). To get a particular chart we are interested in, we can define it in parentheses. Moreover, we can set the bins by using the bins = argument.

For example, here we will see the histogram of color intensity having 20 bins:

1234567891011121314151617181920
# Import the libraries import matplotlib.pyplot as plt import pandas as pd from sklearn.datasets import load_wine # Load dataset wine = load_wine() # Configure pandas to show all features pd.set_option('display.max_rows', None, 'display.max_columns', None) # Convert data to a dataframe to view properly data = pd.DataFrame(data = wine['data'], columns = wine['feature_names']) # Get all information about our dataset print(data.describe()) # Visualize the data data.hist(column = 'color_intensity',bins = 20) plt.show()
copy

Output:

Task

Let’s see what's going on inside our set.

  1. [Line #7] Load wine set.
  2. [Line #16] Get and print all information about it using the function .describe().
  3. [Line #19] Visualize data about alcohol consistency in the set, setting column = 'alcohol' and defining bins = 15.

Switch to desktop for real-world practiceContinue from where you are using one of the options below
Section 1. Chapter 5
Switch to desktop for real-world practiceContinue from where you are using one of the options below
We're sorry to hear that something went wrong. What happened?
some-alt