课程: Machine Learning with Python: Foundations

今天就学习课程吧!

今天就开通帐号,24,100 门业界名师课程任您挑!

How to sample data in Python

How to sample data in Python

- Prior to training the supervised machine learning model, we usually have to split the roles in our data into training and test sets using one of several sampling approaches. To illustrate how to split data using sampling, let's import and preview a dataset of vehicles evaluated by the EPA between the years 1984 and 2018. Before we split our data, you must first separate the dependent variable from the independent variables. If we assume that the CO2 emissions column is a dependent variable, then we can create a data frame called Y based on that column alone. To do this, we create a string variable called response for the name of the dependent variable column, CO2 emissions. Next, we create our data frame by sub-setting based on this variable. And we preview our data frame. To create a data frame of the independent variables, we first create a list called predictors of all the columns in the vehicles data frame.…

内容