• Python项目:基于COVID-19做出的居民饮食结构调整方案


    Healthy Diet Plan against COVID-19

    1. Project Plan

    1.1 The Data

    This article imported 3 data sets, they are nutrition.csv, daily_nutrition_guidance.csvand Food_Supply_Quantity_kg_Data.csv. nutrition.csvand daily_nutrition_guidance.csvare used for Objective 1, Food_Supply_Quantity_kg_Data.csvis used for Objective 2.

    主要用了三个数据集,
    第一个是记录了8000种食物所含营养素的nutrition.csv

    第二个是5种人群(儿童、青少年、男性、女性、孕妇)的每日应摄取营养素daily_nutrition_guidance.csv

    第三个是各个国家每日摄取各类食物的重量以及对应的该国COVID-19确诊、死亡、治愈百分比Food_Supply_Quantity_kg_Data.csv

    1.2 Project Aim and Objectives

    My goal is to analyze people’s daily food intake and health, thus to find a proper food habit which is robust to COVID-19.

    To achieve this, I started from two perspectives:

    Fisrtly, from a personal view:
    Ensuring adequate intake of nutrients every day is a prerequisite for a strong body. Rather than blindly taking health products, which may cause some overdose ( for example, there is no need to take Vitamin C if you already ate a lot of fruits today ) and scarcity, is there any possible to know exactly what nutrients I should supplement every day?

    I created a Query Answering system
    for people to get the list of supplementary if only they input all types of foods and weight separatively

    Moreover, from a global view:
    As we all know, the COVID-19 is ravaging all over the world and the epidemic situation varies from different countries. (Regardless of policy factors) Can we learn anything from some well-controlled countries?

    • By Classification and compare the food composition of high-risk countries and low-risk countries we can find the Corellation of some kind of food with COVID-19 ( e.g people eat more fish are less likely to get infected with the COVID-19 probably because Omega3 is effective against it ). Therefore, we can adjust our diet structure based on this in order to gain stronger resistance.

    Specific Objective(s)

    • Objective 1: create a Python datastructure that can calculate a personal nutrient supplementary list.
    • Objective 2: find the correlation between food and COVID-19 using pandas and matplotlib.

    总体目标:分析用户每日摄取的营养素,量身定制一个根据COVID-19做出的调整计划。

    子目标一:
    个人角度:通过问答的形式,反馈给用户一张今日营养素缺乏和过量表,让用户可以针对地补充营养素(例如:保健品等)。

    子目标二:
    全球角度:通过观察世界各国居民受疫情的影响,分析低风险国家和高风险国家,找到能增强对COVID-19抵抗力的某类食物。

    2. System Design

    2.1 Architecture

    在这里插入图片描述

    2.2 Processing Modules and Algorithms
    • defining a function to data to float type

    I use a brief function ( convert_data(var, n) ) to uniformly convert nutrients with different units of measurement to float type, without use df.apply() one by one.

    • exception handling

    I introduced exception handling in where user inputs ( physical_records(), nutri_calculate() ) , so that when the user mis-input some values we had considered before, the program can be more robust and won’t terminate suddenly.

    • fuzzy matching

    In order to make this interactive system more intelligent, I introduced fuzzy matching in nutri_calculate(), so that when the user enters an incomplete food name, the system will give 10 related results for the user to refer to and re-enter. For example, if the user only remember he had fish today, the system will give a list of foods contains ‘fish’:

    Fish oil, salmon

    Fish, smoked, chinook, salmon

    Fish, raw, wild, coho, salmon

    • Categorizing the data set

    I use two for loops in Objective2 to divide the original dataframe into two dataframes, which represent well-controlled and poorly-controlled countries respectively based on my own defining standards.

    3. Program Code

    3.1 Objective1

    For a personal perspective:
    In this section, I created a calculator that allows users to query the three main energies percentage ( Fat/Protein/Carbohydrate ) of their daily food intake and give a supplementary list of what and how much nutrients they lack each day.

    计算用户每天摄入的三大营养素(脂肪、蛋白质、碳水化合物)占比,给出用户一个今日应该补充的微量元素表。

    3.1.1 Data Cleaning

    Filtering, checking, transposing and converting data format to float
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    3.1.2 Calculatation

    I used 4 functions to achieve an interactive question answering system.
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    3.2 Objective2

    For a global perspective:
    In this section, I found the correlation between different food types and the COVID-19 by analyzing the food habits of well-controlled countries and poorly-controlled countries.

    通过分析疫情控制得好的国家和疫情控制得差的国家,得出某种食物与COVID-19的联系。

    3.2.1 Data Cleaning

    Filtering, checking and Unifying data type
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    3.2.2 Comparative analysis

    The epidemic situation in different countries can be intuitively reflected via visualisation, thus conclusions can be drawn based on these statistical data.
    在这里插入图片描述
    As shown above, Figure 1 shows the different countries in ascending order of the number of confirmed cases. Figures 2 and 3 show the deaths and recovery rates of these countries at that order respectively. We found that the epidemic prevention situation of each country cannot be defined simply by the number of confirmed cases or the deaths(e.g. some Countries with a high number of confirmed cases actually have a small number of deaths).

    Therefore, I define countries with good epidemic prevention as: countries with low Confirmed cases and countries with low Mortality rates.(Here Mortality rates is equal to the number of deaths divided by the number of confirmed cases)

    通过画出154个国家COVID-19确诊率,死亡率和恢复率,我们发现,这三个数据都不能单一的作为一个国家疫情防控好坏的标准(有的国家虽然感染人数多,但是死亡率低,我视为低风险国家)。因此,我设定了一个新冠死亡率(确诊人数/死亡人数),通过确诊率和新冠死亡率,双向衡量一个国家的疫情防控。

    3.2.3 Classification

    divide the original dataframe Q_WD into two dataframes: GD_Q_WD and WS_Q_WD, representing COVID-19 well-controlled countries and poor-controlled countries respectively.

    GD_Q_WD取确诊率低的前50个国家+新冠死亡率后30的国家
    在这里插入图片描述
    在这里插入图片描述

    3.2.4 Comparison

    Calculate and analyze the average food habits of the two groups on five chosen categories.
    在这里插入图片描述
    good_control_mean_list是挑出5类食物来和good_control_mean_list作对比。
    good_whole_mean_list是为了得出防控好的国家居民每日膳食的每类食物种类的比例。

    3.2.5 Visualisation

    Through visual comparative analysis, find the correlation between food and COVID-19.

    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    4. Project Outcome

    4.1 Overview of Results

    In general, user Yingqi has insufficient fat and excessive protein intake today, and needs additional nutrients supplements(e.g health products): choline, vitamin_a, vitamin_e, calcium, magnesium, potassium and zink to maintain her health.

    I divide the countries around the world into two groups which is roughly equal: countries with well-controlled COVID-19 and countries with poorly-controlled COVID-19. Among them, countries with fewer confirmed cases or more confirmed cases but fewer deaths are defined as low-risk countries, and the rest of the countries are those with poor control of COVID-19.

    By comparing their average national daily eating, I found that people in countries with well-controlled COVID-19 eat more fish, cereals and vegetal products every day. However, people in countries where the COVID-19 is quite severe eat more other meat, and the two groups of people ate nearly the same amount of fruit every day.

    Hence, it can be concluded that fish, cereals and vegetal products is beneficial to strengthen the resistance so that one can fight against the COVID-19 more effectively. By observing the daily food composition of people in low-risk countries, it can be found that the daily intake of vegetal products and vegetables should account for half of the total daily food intake, and cereals should account for about 15%.

    Therefore, if user Yingqi wants to get a stronger body to resist the COVID-19, in addition to supplementing the above-mentioned vitamins and minerals, she also needs to adjust her diet structure based on the conclusions drawn above.

    4.2 Objective 1
    4.2.1 Explanation of Results

    According to the information input by user Yingqi, we can obtain:

    Yingqi, as a 23-year-old woman, ate 150g salmon, 200g cooked Chinese broccoli, 50g firm Tofu, 60g strawberry icecream and 200g cooked rice noodles today.

    Based on the nutrients contained in the food she had today and the recommended daily nutrients by U.S. Department of health & human services for a 23-year-old woman, Yingqi should take some supplements as 205mg choline, 317mcg vitamin_a, 12mg vitamin_e, 590mg calcium, 130mg magnesium, 617mg potassium and 4mg zink to achieve a healthier state.

    As we all know, fat, protein and carbohydrate are three basic energies required by the human body. These three energies usually appears on the food packages. According to U.S. Department of health & human services, the perfect ratio for fat, protein and carbohydrate in daily is 25%, 15%, 60%. Put Yingqi’s daily composition of these three energies in a pie chart, aside the recommended one, we can clearly know that Yingqi has consumed too much protein today, which is almost as twice as the recommended value. However, the fat intake is insufficient. For advice, Yingqi should adjust her diet, by appropriately reducing the total amount of meat or soy products, and supplementing some good fats ( such as avocado, which is rich in Omega3 ) to close to the perfect intake ratio.

    In Figure2, I displayed the recommended nutrient values of the group where Yingqi in and the value of Yingqi’s intake today as a bar chart in the form of coverage, so that Yingqi can clearly know what is insufficient today, and then take measures based on the supplementary list we have obtained above. Among the bars, the blue part is the value of vitamins or minerals which Yingqi is lack of today. If it is whole orange, it means that sufficient nutrients have been obtained (the values of vitamin_b12 and vitamin_b6 is too subtle to shown in the figure).

    4.2.2 Visualisation

    The following pie chart gives a vivid comparision of the ratio of fat, protein and cabrohydrate of user’s intake today and the recommended one.

    对比用户今日摄入的三大营养素总和和推荐摄入的比例。
    在这里插入图片描述
    在这里插入图片描述
    The following bar chart shows the situation of nutrients of user’s intake today with recommended one.
    在这里插入图片描述
    在这里插入图片描述
    用户今日摄入的微量元素与该类人群推荐值的对比,蓝色为该补充的,全为橙色则说明摄入过量。

    4.3 Objective 2
    4.3.1 Explanation of Results

    The data set Q_WD integrates the proportions of different types of food in people’s daily diet, as well as the obesity rate, undernourished rate, the confirmed, recovered populations and deaths in the COVID-19 of various countries. Therefore, we can analyze the relationship between them by combining different data.

    Here, I sort the entire dataframe in ascending order of the number of confirmed cases, and then draw the bar charts of the number of confirmed cases, the death rate and the recovery rate of these countries respectively.

    From this, I found that some countries have more confirmed cases but fewer deaths case. Thus, I defined a measurement standard——the mortality rate——to judge the control of the COVID-19 in each country. But relying solely on mortality cannot accurately distinguish well-controlled countries from poorly-controlled countries, as there are some countries where fewer people are infected but the death rate of infected patients is higher, resulting in a high mortality rate ( for example, a country with aging problem did very good in prevention and control policies. Few people are infected, but the elderly accounted for a large proportion of the infected population, so the death rate of infected patients is higher, which leading to a high mortality rate ).

    As a result, I have combined these two methods, which is taking the top 50 countries of less confirmed cases and top 30 countries of low mortality rate as well-controlled countries, the rest as poorly-controlled countries. In this way, the number of high-risk countries and low-risk countries is roughly equal.

    I selected five main food types (meat, fish, cereals, fruits and vegetal products ) and drew a bar chart of the preferences of people in high-risk countries and low-risk countries for these five types of food.

    Which can be observed is people in low-risk countries account for a higher proportion of daily intake of fish, cereals, and vegetal products. On the contrary, people in high-risk countries prefer other types of meat. What surprised me most was people in both countries have similar fruits intake.

    In addition, I also displayed the composition of people’s daily diet in low-risk countries with a pie chart, where you can clearly observe how many cereals, vegetal products, fruits, etc. they eat every day.

    4.3.2 Visualisation

    Due to analysis needs, the visualization functions have been embedded in the previous module. Here, we call these two functions again.

    The three bar charts below shows the general epidemic situation in different countries.
    在这里插入图片描述
    The following bar chart represents the comparision of average food habits in low-risk countries and high-risk countries vividly.
    在这里插入图片描述
    The following pie chart gives a detailed explanation about the composition of what peple in low-risk countries eat every day.
    在这里插入图片描述
    在这里插入图片描述

    5. Conclusion

    5.1 Achievements

    In conclusion, fish, cereals and vegetal products is beneficial to strengthen the resistance so that one can fight against the COVID-19 more effectively. I conjecture that this is because, fish is rich in omega3, which is helpful for heart health in research. Besides, there is a saying in ancient Chinese medicine that ‘grains for nourishment’, so eating more cereals can help us to strengthen our immunity.

    By observing the daily food composition of people in low-risk countries, it can be found that the daily intake of vegetal products and vegetables should account for half of the total daily food intake, and cereals and fish should account for about 15% and 2% respectively.

    As we calculated, the user Yingqi has consumed too much protein today, which is almost as twice as the recommended value. However, the fat intake is insufficient. For advice, Yingqi should adjust her diet, by appropriately reducing the total amount of meat or soy products, and supplementing some good fats ( such as avocado, which is rich in Omega3 ) to close to the perfect intake ratio. What’s more, Yingqi is better to increase the intake of fish and cereals in her future diet.

    5.2 Limitations

    This model does not consider the COVID-19 prevention policies of different countries as policies vary from different countries, even different states.

    5.3 Future Work

    For accuracy, we should consider the COVID-19 policies of different countries to reclassify high-risk and low-risk countries. Perhaps multi-level classification should be introduced according to the strictness of the COVID-19 prevention policy.

  • 相关阅读:
    react-routerV6版本和V5版本的详细对比
    Python列表条件筛选
    Android 弹出Dialog的时候如何弹出软键盘(输入法)
    Kalman滤波器--从高斯融合推导
    JavaScript实战游戏逻辑
    Chapter8.2:非线性控制系统分析
    【技术分享】SLA(服务等级协议)原理与配置
    基于thinkphp的良品铺子网站
    【Java 进阶篇】深入理解 Jackson:Java 对象转 JSON 的艺术
    C++命名空间与输入输出
  • 原文地址:https://blog.csdn.net/weixin_41206209/article/details/126678607