Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Working with Dataset | What is the Linear Regression?
Explore the Linear Regression Using Python
course content

Conteúdo do Curso

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

bookWorking with Dataset

First of all, we need data on which we will work on. Scikit-learn comes with a few small standard datasets that do not require downloading and are very helpful for learning new models in machine learning. In this course, we will become high-class sommeliers and determine the quality of wine using statistics and regression. Wine recognition dataset provides a large variety of characteristics of wine: Alcohol, Ash, Magnesium, Total phenols, Color intensity, and so on.

12
from sklearn.datasets import load_wine wine = load_wine()
copy

We also create pandas DataFrame for easier manipulation:

12345678
# Import the libraries import pandas as pd # Show all features pd.set_option('display.max_rows', None, 'display.max_columns', None) # Create DataFrame data = pd.DataFrame(data = wine['data'], columns = wine['feature_names'])
copy

If you don't feel comfortable working with pandas library, check out our course on this topic.

To inspect our data, we should know the number of records and which columns it contains. In such situations, it would be better to use functions .shape and .columns. The first one returns the number of records and columns, and the second lets us know all columns' names.

12345
#Get the number of records and columns print(data.shape) # Get the names of all columns print(data.columns)
copy

Okay, so now we know how to load our dataset and get some information about data. But what if we want to get a certain number of records from our wine database? Pulling all information can be very inconvenient, primarily if we work with Big Data in the future where millions of records can be stored. To see the first rows of DataFrame use .head(n), where n is the number of rows to be selected. By default, it’s 5 rows.

Look at the following example. This code shows the first 5 rows of our dataset:

12
# Print first 5 rows print(data.head())
copy

To sum up the learned functions and their usage below:

Tarefa

Let’s explore our dataset. Using the functions discussed in this chapter, find out the number of records and columns that are in our set and the names of these columns. Print the first 9 rows of the wine dataset.

  1. [Lines #2-3] Import the library pandas and load our wine dataset.
  2. [Line #12] Set DataFrame using the function pd.DataFrame() with parameters.
  3. [Lines #15-19] Use functions .shape, .columns to get information about records. Print the first 9 rows using function head(n) where n is 9.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 4
toggle bottom row

bookWorking with Dataset

First of all, we need data on which we will work on. Scikit-learn comes with a few small standard datasets that do not require downloading and are very helpful for learning new models in machine learning. In this course, we will become high-class sommeliers and determine the quality of wine using statistics and regression. Wine recognition dataset provides a large variety of characteristics of wine: Alcohol, Ash, Magnesium, Total phenols, Color intensity, and so on.

12
from sklearn.datasets import load_wine wine = load_wine()
copy

We also create pandas DataFrame for easier manipulation:

12345678
# Import the libraries import pandas as pd # Show all features pd.set_option('display.max_rows', None, 'display.max_columns', None) # Create DataFrame data = pd.DataFrame(data = wine['data'], columns = wine['feature_names'])
copy

If you don't feel comfortable working with pandas library, check out our course on this topic.

To inspect our data, we should know the number of records and which columns it contains. In such situations, it would be better to use functions .shape and .columns. The first one returns the number of records and columns, and the second lets us know all columns' names.

12345
#Get the number of records and columns print(data.shape) # Get the names of all columns print(data.columns)
copy

Okay, so now we know how to load our dataset and get some information about data. But what if we want to get a certain number of records from our wine database? Pulling all information can be very inconvenient, primarily if we work with Big Data in the future where millions of records can be stored. To see the first rows of DataFrame use .head(n), where n is the number of rows to be selected. By default, it’s 5 rows.

Look at the following example. This code shows the first 5 rows of our dataset:

12
# Print first 5 rows print(data.head())
copy

To sum up the learned functions and their usage below:

Tarefa

Let’s explore our dataset. Using the functions discussed in this chapter, find out the number of records and columns that are in our set and the names of these columns. Print the first 9 rows of the wine dataset.

  1. [Lines #2-3] Import the library pandas and load our wine dataset.
  2. [Line #12] Set DataFrame using the function pd.DataFrame() with parameters.
  3. [Lines #15-19] Use functions .shape, .columns to get information about records. Print the first 9 rows using function head(n) where n is 9.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 4
toggle bottom row

bookWorking with Dataset

First of all, we need data on which we will work on. Scikit-learn comes with a few small standard datasets that do not require downloading and are very helpful for learning new models in machine learning. In this course, we will become high-class sommeliers and determine the quality of wine using statistics and regression. Wine recognition dataset provides a large variety of characteristics of wine: Alcohol, Ash, Magnesium, Total phenols, Color intensity, and so on.

12
from sklearn.datasets import load_wine wine = load_wine()
copy

We also create pandas DataFrame for easier manipulation:

12345678
# Import the libraries import pandas as pd # Show all features pd.set_option('display.max_rows', None, 'display.max_columns', None) # Create DataFrame data = pd.DataFrame(data = wine['data'], columns = wine['feature_names'])
copy

If you don't feel comfortable working with pandas library, check out our course on this topic.

To inspect our data, we should know the number of records and which columns it contains. In such situations, it would be better to use functions .shape and .columns. The first one returns the number of records and columns, and the second lets us know all columns' names.

12345
#Get the number of records and columns print(data.shape) # Get the names of all columns print(data.columns)
copy

Okay, so now we know how to load our dataset and get some information about data. But what if we want to get a certain number of records from our wine database? Pulling all information can be very inconvenient, primarily if we work with Big Data in the future where millions of records can be stored. To see the first rows of DataFrame use .head(n), where n is the number of rows to be selected. By default, it’s 5 rows.

Look at the following example. This code shows the first 5 rows of our dataset:

12
# Print first 5 rows print(data.head())
copy

To sum up the learned functions and their usage below:

Tarefa

Let’s explore our dataset. Using the functions discussed in this chapter, find out the number of records and columns that are in our set and the names of these columns. Print the first 9 rows of the wine dataset.

  1. [Lines #2-3] Import the library pandas and load our wine dataset.
  2. [Line #12] Set DataFrame using the function pd.DataFrame() with parameters.
  3. [Lines #15-19] Use functions .shape, .columns to get information about records. Print the first 9 rows using function head(n) where n is 9.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

First of all, we need data on which we will work on. Scikit-learn comes with a few small standard datasets that do not require downloading and are very helpful for learning new models in machine learning. In this course, we will become high-class sommeliers and determine the quality of wine using statistics and regression. Wine recognition dataset provides a large variety of characteristics of wine: Alcohol, Ash, Magnesium, Total phenols, Color intensity, and so on.

12
from sklearn.datasets import load_wine wine = load_wine()
copy

We also create pandas DataFrame for easier manipulation:

12345678
# Import the libraries import pandas as pd # Show all features pd.set_option('display.max_rows', None, 'display.max_columns', None) # Create DataFrame data = pd.DataFrame(data = wine['data'], columns = wine['feature_names'])
copy

If you don't feel comfortable working with pandas library, check out our course on this topic.

To inspect our data, we should know the number of records and which columns it contains. In such situations, it would be better to use functions .shape and .columns. The first one returns the number of records and columns, and the second lets us know all columns' names.

12345
#Get the number of records and columns print(data.shape) # Get the names of all columns print(data.columns)
copy

Okay, so now we know how to load our dataset and get some information about data. But what if we want to get a certain number of records from our wine database? Pulling all information can be very inconvenient, primarily if we work with Big Data in the future where millions of records can be stored. To see the first rows of DataFrame use .head(n), where n is the number of rows to be selected. By default, it’s 5 rows.

Look at the following example. This code shows the first 5 rows of our dataset:

12
# Print first 5 rows print(data.head())
copy

To sum up the learned functions and their usage below:

Tarefa

Let’s explore our dataset. Using the functions discussed in this chapter, find out the number of records and columns that are in our set and the names of these columns. Print the first 9 rows of the wine dataset.

  1. [Lines #2-3] Import the library pandas and load our wine dataset.
  2. [Line #12] Set DataFrame using the function pd.DataFrame() with parameters.
  3. [Lines #15-19] Use functions .shape, .columns to get information about records. Print the first 9 rows using function head(n) where n is 9.

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Seção 1. Capítulo 4
Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
some-alt