2023 Huashu Cup Mathematical Modeling C Question Complete 5 Questions Code Idea Analysis

At present, the complete code of all 5 questions and a 42-page paper (30 pages for the main text, and the abstract of the paper part are as follows:

This paper addresses five issues in total, involving the relationship between infant behavioral characteristics, sleep quality, and mother's physical and psychological indicators, and how to optimize infant behavioral characteristics and sleep quality.

For question 1, we preprocessed the data, processed the infant behavioral characteristics data, and converted them into numerical data, and then used the Pearson correlation coefficient to study the relationship between the mother's physical and psychological indicators and the infant's behavioral characteristics and sleep quality. relationship between.

For question 2, we divided the behavioral characteristics of infants into three types: quiet, moderate, and ambivalent. In order to establish a relationship model between the infant's behavioral characteristics and the mother's physical and psychological indicators, we have established a variety of classification models, such as logistic regression, support vector machine, decision tree, random forest, XGBoost model, etc. We then used these models to predict the type of infants whose behavioral characteristics were removed, judging the behavioral characteristics of the last 20 groups (numbers 391-410) of infants in the data table. The prediction results show that,  …

For question 3, we used the provided data to establish a linear model between treatment costs and reduced scores, and calculated the maximum treatment costs for infants (number 238) whose current behavioral characteristics were ambivalent. Then, use the XGBoost classification model established in the second question to predict the behavior characteristics of the infant under different CBTS, EPDS and HADS scores, so as to find the score reduction scheme that minimizes the treatment cost. The result of the solution is: the minimum treatment cost to change the behavior characteristics into a medium type: , the adjustment plan: ; the minimum treatment cost to make the behavior characteristics into a quiet type: , the adjustment plan:  ….

For question 4, we use the TOPSIS comprehensive evaluation method based on the entropy weight method to classify and evaluate the baby's sleep quality, use the entropy weight method to determine the index weight to avoid the subjectivity brought by expert empowerment, and use data standardization and forwardization methods to construct scoring model. Then the rating results were used to establish a regression model to predict the comprehensive sleep quality rating. For question 5, on the basis of question 3, we adjusted the baby's sleep quality rating to excellent, and re-predicted sleep quality. The result of the solution is: the minimum treatment cost to make the sleep quality 4.0 (excellent): ......, the adjustment plan:  …

Taken together, this study provides important insights and solutions for understanding the mother-infant relationship and optimizing infant behavioral characteristics and sleep quality.

The code for all 5 questions is as follows

1. Restatement of the problem... 4

2. Problem analysis... 5

2.1 Analysis of Problem 1... 5

2.2 Analysis of Problem 2... 6

2.3 Analysis of Question 3... 6

2.4 Analysis of Question 4... 6

2.5 Analysis of Question 5... 6

3. Model assumptions... 7

4. Description of symbols... 7

V. Model establishment and solution... 8

5.1 Establishment and solution of problem 1 model... 8

5.1.1 Data preprocessing... 8

5.1.2 Pearson correlation coefficient analysis... 8

5.2 Establishment and solution of problem 2 model... 10

5.2.1 Establishment of logical classification model... 11

5.2.2 Establishment of support vector machine classification model... 12

5.2.3 Establishment of decision tree classification model... 12

5.2.4 Establishment of random forest classification model... 13

5.2.5 Establishment of XGBoost classification model... 13

5.2.6 Comparison and Analysis of Prediction Results... 14

5.3 Establishment and solution of problem three model... 15

5.3.1 Linear model of treatment cost and score... 15

5.3.2 Optimal solution model for minimum treatment cost... 16

5.3.3 Solution results and analysis of treatment plan... 18

5.4 Establishment and solution of problem 4 model... 19

5.4.1 TOPSIS evaluation model based on entropy weight method... 19

5.4.2 Data forwardization... 19

5.4.3 Data standardization... 21

5.4.4 Entropy weight method to determine the weight... 21

5.4.5 Scoring model construction... 23

5.4.6 Comprehensive evaluation score of sleep quality... 24

5.4.7 XGBoost correlation model establishment for sleep quality... 24

5.4.8 Comprehensive sleep quality prediction results... 25

5.5 Establishment and solution of problem 5 model... 26

5.5.1 Sleep quality adjustment treatment plan... 26

5.5.2 Treatment strategy for problem five... 28

6. Model evaluation and promotion... 28

7. References... 30

VIII. Appendix... 31

1. Restatement of the problem

Question C of the 2023 Huashu Cup Mathematical Contest in Modeling:

A mother is one of the most important people in a baby's life, providing not only nutrition and physical protection but also emotional support and a sense of security. Adverse conditions in the mother's mental health, such as depression, anxiety, and stress, may have negative effects on the baby's cognition, emotion, and social behavior. A stressed mother can negatively affect a baby's physical and psychological development, such as affecting sleep.

The appendix presents data on 390 infants aged 3 to 12 months and their mothers. The data cover a variety of subjects, with physical indicators of mothers including age, marital status, education, duration of pregnancy, mode of delivery, and maternal psychological indicators CBTS (Partnership-related Post Traumatic Stress Disorder Questionnaire), EPDS (Edinburgh Postpartum Depression Scale) , HADS (Hospital Anxiety and Depression Scale) and indicators of infant sleep quality including duration of sleep throughout the night, number of awakenings and falling asleep patterns.

Please refer to the relevant literature, understand the professional background, build a mathematical model based on the topic data, and answer the following questions.

1. Many studies have shown that the mother's physical and psychological indicators have an impact on the baby's behavioral characteristics and sleep quality. Is there such a rule? Do research based on the data in the attachment.

2. The Infant Behavior Questionnaire is a scale used to assess behavioral characteristics of infants, which contains a number of questions about the infant's emotions and reactions. We divide the behavioral characteristics of infants into three types: quiet, moderate, and ambivalent. Please establish a relationship model between the baby's behavioral characteristics and the mother's physical and psychological indicators.

In the last 20 groups of infants (No. 391-410) in the data table, the behavior characteristics information has been deleted. Please judge what type they belong to.

3. Intervention on maternal anxiety can help improve the mother's mental health, improve the quality of mother-infant interaction, and promote the infant's cognitive, emotional and social development. The change rate of the treatment cost of CBTS, EPDS, and HADS relative to the degree of illness is proportional to the treatment cost. After investigation, the treatment costs corresponding to the two scores are given, as shown in Table 1. There is an infant whose behavioral characteristics are ambivalent, numbered 238. Please build a model to analyze how much treatment cost is required to change the baby's behavioral characteristics from contradictory to moderate? How would the treatment plan need to be adjusted in order to change his behavioral profile to a quieter type?

4. The baby's sleep quality indicators include the sleep time of the whole night, the number of times of waking up, and the way of falling asleep. Please make a comprehensive evaluation of the baby's sleep quality in four categories: excellent, good, medium, and poor, and establish a correlation model between the baby's comprehensive sleep quality and the mother's physical and psychological indicators, and predict the last 20 groups (No. 391-410) of babies comprehensive sleep quality.

5. On the basis of Question 3, if it is necessary to make the sleep quality of baby No. 238 rated as excellent, does the treatment strategy for Question 3 need to be adjusted? How to adjust?

2. Problem analysis

2.1 Analysis of Problem 1

Question 1: To analyze the influence of the mother's physical and psychological indicators on the infant's behavioral characteristics and sleep quality. This is a correlation analysis problem. First, the data is preprocessed, including data cleaning and transformation. The Pearson correlation coefficient was then used to measure the correlation between the mother's physical and psychological indicators and the infant's behavioral characteristics and sleep quality.

Method: Pearson correlation coefficient analysis

import numpy as np
from scipy.stats import pearsonr, spearmanr
import statsmodels.api as sm
import seaborn as sns
import matplotlib.pyplot as plt

# 设置中文字体
plt.rcParams['font.sans-serif'] = ['SimHei']
# 设置负数的符号
plt.rcParams['axes.unicode_minus'] = False

# 建立新的变量,取data的前391行数据
data_analysis = data.head(391)

# 进行皮尔逊相关系数分析
correlation_matrix = data_analysis.corr(method='pearson')
print(correlation_matrix)

# 可视化绘图
plt.figure(figsize=(10, 8))
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', linewidths=0.5)
plt.title('Pearson Correlation Heatmap')
plt.show()

2.2 Analysis of Problem 2

Question 2: Establish a relationship model between the infant's behavioral characteristics and the mother's physical and psychological indicators. This is a multi-classification problem. By establishing a classification model, the infant's behavioral characteristics were divided into three types: quiet, moderate, and contradictory.

Method: Use a variety of classification models (such as decision trees, random forests, XGBoost, etc.) to build models, and then classify and predict the behavioral characteristics of infants.

Part of the code is as follows:

# 选择母亲的身体指标和心理指标,以及婴儿的行为特征作为数据分析的子集
subset_columns = ['EPDS', 'HADS', 'CBTS', '母亲年龄', '婚姻状况', '教育程度', '妊娠时间(周数)', '分娩方式', '婴儿行为特征']
data_analysis = data.loc[:, subset_columns]

# 划分训练集和测试集,其中删除的婴儿信息为测试集
train_data = data_analysis.loc[1:390, :]
test_data = data_analysis.loc[391:411, :]

# 将婴儿的行为特征作为目标变量
y_train = train_data['婴儿行为特征']
y_test = test_data['婴儿行为特征']

# 将母亲的身体指标和心理指标作为特征变量
X_train = train_data[['EPDS', 'HADS', 'CBTS', '母亲年龄', '婚姻状况', '教育程度', '妊娠时间(周数)', '分娩方式']]
X_test = test_data[['EPDS', 'HADS', 'CBTS', '母亲年龄', '婚姻状况', '教育程度', '妊娠时间(周数)', '分娩方式']]

2.3 Analysis of Question 3

Question 3: Establish a model to analyze the minimum cost of treatment to change the infant's behavioral characteristics from contradictory to moderate; how to adjust the treatment plan to change the behavioral characteristics of the infant to quiet.

Method: First, it is necessary to calculate the maximum treatment cost of the infant whose current behavioral characteristics are contradictory (No. 238). Then, use the XGBoost classification model established in the second question to predict the behavior characteristics of the infant under different CBTS, EPDS and HADS scores, so as to find the score reduction scheme that minimizes the treatment cost.

2.4 Analysis of Question 4

Question 4: Carry out a comprehensive evaluation of the baby's sleep quality in four categories: excellent, good, medium, and poor, and establish a correlation model between the baby's comprehensive sleep quality and the mother's physical and psychological indicators, and predict the comprehensive sleep quality of the last 20 groups of babies.

Methods: TOPSIS method was used for comprehensive evaluation to classify infants' sleep quality. Then the XGBoost regression model was established, and the mother's physical and psychological indicators were used as features, and the baby's comprehensive sleep quality rating was used as the target variable for regression analysis.

2.5 Analysis of Question 5

Question 5: On the basis of question 3, adjust the baby's sleep quality rating to be excellent, and then re-establish the model to predict the comprehensive sleep quality of the last 20 groups of babies.

Method: According to the model obtained in question 3, the sleep quality rating in question 3 was adjusted to be excellent, and the XGBoost regression model was re-established. Prediction of composite sleep quality ratings for the final 20 cohorts of infants.

3. Model assumptions

4. Description of symbols

5. Model establishment and solution

5.1 Establishment and solution of problem 1 model

Question 1 requires data analysis to explore whether the mother's physical and psychological indicators have an impact on the infant's behavioral characteristics and sleep quality. In such cases, statistical and machine learning techniques can be used to perform correlation and regression analyzes to identify relationships between indicators. Proceed as follows:

1. Data preprocessing: First, clean and preprocess the data. This may involve steps such as handling missing values, converting categorical data to numerical data, standardizing data, etc.

2. Correlation analysis: Use correlation analysis to understand the correlation between indicators. A linear or non-linear relationship between variables can be measured by calculating the Pearson correlation coefficient or the Spearman rank correlation coefficient.

3. Regression analysis: If sufficient data are available, regression analysis can be used to build a model to predict the relationship between infant behavioral characteristics and sleep quality and mother's physical and psychological indicators. You can try multiple linear regression or other suitable regression methods.

4. Statistical significance test: In regression analysis, it is necessary to conduct a statistical significance test on the model to determine whether the prediction effect of the model is significant.

5. Interpretation of the results: According to the results of the analysis, explain the degree of influence of the mother's physical and psychological indicators on the baby's behavioral characteristics and sleep quality. It is important to note that correlation does not imply causation, so the results need to be interpreted with caution.

5.1.1 Data preprocessing

We need to process the baby behavior characteristic data and convert it into numerical data.

5.1.2 Pearson correlation coefficient analysis

Pearson correlation coefficient analysis can be used when we want to understand the correlation between two variables. It is a statistical method used to measure the degree of linear correlation between two continuous variables. In simple terms, the Pearson correlation coefficient can tell us whether the two variables are positively correlated, negatively correlated, or not correlated at all.

The principle of the Pearson correlation coefficient is based on the concepts of covariance and standard deviation. It measures the degree to which two variables co-variate by calculating their covariance, which is then divided by their respective standard deviations, resulting in a value between -1 and 1, representing the correlation between two variables.

How to download documents and codes:

https://mbd.pub/o/bread/mbd-ZJyXkppx

Guess you like

Origin blog.csdn.net/qq_45857113/article/details/132095565