Python implements the WOA intelligent whale optimization algorithm to optimize the LightGBM regression model (LGBMRegressor algorithm) project practice

Note: This is amachine learning practical project (comes with data + code + documentation + video Explanation), if you needdata + code + documentation + video explanation, you can go directly to the end of the article to get it.

1.Item background

The whale optimization algorithm (WOA) is a new swarm intelligence optimization algorithm proposed by Mirjalili et al. of Griffith University in Australia in 2016. Its advantages include simple operation, few parameters to adjust, and the ability to jump out of the local optimum. strong ability.

This project uses the WOA intelligent whale optimization algorithm to find optimal parameter values ​​to optimize the LightGBM regression model.

2.number acquisition

The modeling data for this time comes from the Internet (compiled by the author of this project). The statistics of the data items are as follows:

serial number 

variable name

describe

1

x1

2

x2

3

x3

4

x4

5

x5

6

x6

7

x7

8

x8

9

x9

10

x10

11

and

dependent variable

The data details are as follows (partially displayed):

3.Data preprocessing

3.1 用PandasTools

Use the head() method of the Pandas tool to view the first five rows of data:

Key code:

3.2 View with missing data

Use the info() method of the Pandas tool to view data information:

   

As you can see from the picture above, there are a total of 11 variables, no missing values ​​in the data, and a total of 1,000 pieces of data.

Key code:  

3.3Number prescriptiveness calculation 

Use the describe() method of the Pandas tool to view the mean, standard deviation, minimum value, quantile, and maximum value of the data.

The key code is as follows:    

4.Exploratory data analysis

4.1y change square picture 

Use the hist() method of the Matplotlib tool to draw a histogram:

As you can see from the picture above, the y variable is mainly concentrated between -400 and 400.

4.2 Correlation analysis

As can be seen from the figure above, the larger the value, the stronger the correlation. Positive values ​​are positive correlations, and negative values ​​are negative correlations.

5.Special expedition process

5.1 Create feature data and label data

The key code is as follows:

5.2 Dataset Splitting

The train_test_split() method is used to divide 80% of the training set and 20% of the test set. The key code is as follows:

6. Construct the WOA intelligent whale optimization algorithm to optimize the LightGBM regression model

The WOA smart whale optimization algorithm is mainly used to optimize the LightGBM regression algorithm for target regression.

6.1 The optimal parameters found by WOA intelligent whale optimization algorithm   

Optimal parameters:

   

6.2 Build model with optimal parameter values

serial number

Model name

parameter

1

LightGBM regression model

n_estimators=best_n_estimators

2

learning_rate=best_learning_rate

7.Model introduction

7.1 Evaluation indicators and results

Evaluation indicators mainly include explainable variance value, mean absolute error, mean square error, R-squared value, etc.

Model name

Indicator name

Index value

test set

LightGBM regression model

  R square

0.8742

mean square error

5173.8696

explained variance

0.8743

mean absolute error

56.0685

As can be seen from the above table, R square is 0.8742, which means the model has good effect.

The key code is as follows:

7.2 Comparison chart between true value and predicted value

It can be seen from the above figure that the fluctuations of the real value and the predicted value are basically consistent, and the model fitting effect is good.​    

8.Conclusion outlook

To sum up, this article uses the WOA intelligent whale optimization algorithm to find the optimal parameter values ​​of the LightGBM regression algorithm to build a regression model, which ultimately proves that the model we proposed works well. This model can be used for predictions of everyday products.

# 本次机器学习项目实战所需的资料,项目资源如下:
 
# 项目说明:

链接:https://pan.baidu.com/s/19ZVfo4Tf2kQ9Xv4cvxnguQ 
提取码:ggfp


For more practical projects, please see the list of practical machine learning projects:

Machine learning project practical collection list_Machine learning practical project_Pang Ge’s really good blog-CSDN blog


Guess you like

Origin blog.csdn.net/weixin_42163563/article/details/134647544