SlideShare una empresa de Scribd logo
1 de 19
Descargar para leer sin conexión
ĐỀ TÀI 1
BOSTONHOUSING DATA
LÊ KHÁNH LY
DATA ANALYSIS SCHOOL - K7
Yêu cầu chung
Giải thích ý nghĩa các thư viện tính toán trong R
STT Tên package Ý nghĩa
1 tidyverse Dùng để quản lý và biên tập dữ liệu
2 ggplot2 Biểu đồ phẩm chất cao
Đề tài nhóm 1
> dt1 <- select(BostonHousing,CHAS,CRIM,INDUS,NOX)
> dt1
Gán cho dt1 dữ liệu được tạo từ các cột CHAS,CRIM,INDUS,NOX của dữ liệu gốc Boston Housing
Dt1 gồm có 506 quan sát và 4 biến
Giải thích ý nghĩa thành phần
STT Giá trị biến Ý nghĩa
1 CHAS 1: ven sông Charles River, 0: ngược lại
2 CRIM Tỷ lệ tội phạm trên đầu người
3 INDUS Tỷ lệ % không kinh doanh bán lẻ
4 NOX Mức độ ô nhiễm nitrogen oxide
Cấu trúc dt1
Str (dt1) : Dùng để tổng quát cấu trúc data, tổng số biến, quan sát và loại biến ( rời rạc hay phân nhóm)
Dữ liệu dt1 gồm 506 quan sát và 4 biến. Các biến đều ở dạng numeric
head (dt1) : Xem vài dòng đầu của data để kiểm tra dữ liệu dưới dạng mẫu
summary (dt1) : Giúp hiểu số liệu thống kê cơ bản của từng biến trong dữ liệu. (giá trị min –max, tứ phân vị)
Ma trận tương quan giữa các biến
Ý nghĩa: 0<p<1: 2 biến có tương quan đồng biến
 Tỷ lệ không bán lẻ (INDUS) có mối quan hệ đồng biến với mức độ tội phạm (CRIM) và mức độ ô
nhiễm (NOX).
Nếu mức độ tội phạm (CRIM) và mức độ ô nhiễm (NOX) tăng thì tỷ lệ không bán lẻ (INDUS) có thể sẽ
tăng
cor(dt1)
Ma trận tương quan giữa các biến
Tạo dataframe dt1.1 bao gồm các biến log_crim, NOX2,NOX3 từ dataframe dt1:
dt1.1 <- transmute(dt1,log_cirm= log(CRIM),NOX2=NOX^2,NOX3=NOX^3)
Tạo dataframe mới là dt được ghép từ dt1 và dt1.1. Ta được bảng mới như sau
dt <- data.frame(dt1,dt1.1)
dt
Ma trận tương quan giữa các biến
Ý nghĩa: Tỷ lệ không bán lẻ (INDUS) và log_crim có mối tương quan chặt hơn so với CRIM
cor(dt)
Vẽ biểu đồ cho từng cột dữ liệu
ggplot(dt,aes(x=CHAS))+geom_bar()+ theme_classic()
ggplot(dt,aes(x=log_crim))+geom_histogram()+ theme_classic()
ggplot(dt,aes(x=INDUS))+geom_histogram()+ theme_classic()
ggplot(dt,aes(x=NOX))+geom_histogram()+ theme_classic()
Vẽ biểu đồ cho từng cột dữ liệu
Vẽ biểu đồ Box_plot
ggplot(dt,aes(x=NOX))+geom_boxplot()+ theme_classic()
ggplot(dt,aes(x=INDUS))+geom_boxplot()+ theme_classic()
ggplot(dt,aes(x=CRIM))+geom_boxplot()+ theme_classic()
Vẽ biểu đồ tương quan
ggplot(dt,aes(NOX,INDUS))+geom_point()+geom_smooth()
ggplot(dt,aes(log_crim,INDUS))+geom_point()+geom_smooth()
ggplot(dt,aes(log_crim,NOX))+geom_point()+geom_smooth()
Dự báo tỷ lệ không có hoạt động bán lẻ
(indus) do tội phạm (log_crim)
INDUS = 12.947 + 2.319 * log_crim + e
Ví dụ
Với log_crim= -2.427128428
Theo mô hình -> INDUS= 7.318489175 +e
Thực tế: INDUS = 7.87
 Mức độ tội phạm theo (log_crim) giải thích được 53,41%
tỷ lệ không bán lẻ INDUS
ĐÁNH GIÁ MÔ HÌNH
Dự báo tỷ lệ không có hoạt động bán lẻ
(indus) do tội phạm (nox)
INDUS = 19.14 – 175.03*NOX + 453.56*NOX2 -291.31
*NOX3 + e
Ví dụ
Với NOX= 0.524 NOX2= 0.274576 NOX3= 0.14387782
Theo mô hình -> INDUS= 10.0623106
Thực tế: INDUS = 7.87
 Mức độ ô nhiễm giải thích được 63,59% tỷ lệ không bán
lẻ
ĐÁNH GIÁ MÔ HÌNH
Dự báo tỷ lệ không có hoạt động bán lẻ
(indus) do tội phạm và mức độ ô nhiễm
INDUS = 2.8437 – 58.1813*NOX+222.0390*NOX2 -
155.6045*NOX3+ 0.6728*log_crim +e
 Với mô hình này mức độ tội phạm và ô nhiễm giải thích
được 64,85% tỷ lệ không bán lẻ
ĐÁNH GIÁ MÔ HÌNH
Tăng cường chính xác bằng chas và không chas
Tạo ra bộ dữ liệu dt2 với điều kiện CHAS ==1
Tạo ra bộ dữ liệu dt3 với điều kiện CHAS ==0
CHAS==1
INDUS = -99.6706 + 371.8444*NOX -360.7045*NOX2
+104.2718*NOX3 - 0.5326*log_crim +e
 Với mô hình này mức độ tội phạm và ô nhiễm giải thích
được 87,35% tỷ lệ không bán lẻ, tỷ lệ cao hơn so với tỷ lệ
tương ứng ở bộ dữ liệu dt.
ĐÁNH GIÁ MÔ HÌNH
CHAS==0
INDUS = -8.5154 -85.2835*NOX +264.2591*NOX2 -
177.3208*NOX3 +0.7026*log_crim +e
 Với mô hình này mức độ tội phạm và ô nhiễm giải thích
được 63,81% tỷ lệ không bán lẻ, tỷ lệ thấp hơn so với tỷ
lệ tương ứng ở bộ dữ liệu dt.
ĐÁNH GIÁ MÔ HÌNH
Thanks for reading!

Más contenido relacionado

Destacado

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Destacado (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

DE_TAI_1__LE_KHANH_LY_K7.pdf

  • 1. ĐỀ TÀI 1 BOSTONHOUSING DATA LÊ KHÁNH LY DATA ANALYSIS SCHOOL - K7
  • 2. Yêu cầu chung Giải thích ý nghĩa các thư viện tính toán trong R STT Tên package Ý nghĩa 1 tidyverse Dùng để quản lý và biên tập dữ liệu 2 ggplot2 Biểu đồ phẩm chất cao
  • 3. Đề tài nhóm 1 > dt1 <- select(BostonHousing,CHAS,CRIM,INDUS,NOX) > dt1 Gán cho dt1 dữ liệu được tạo từ các cột CHAS,CRIM,INDUS,NOX của dữ liệu gốc Boston Housing Dt1 gồm có 506 quan sát và 4 biến
  • 4. Giải thích ý nghĩa thành phần STT Giá trị biến Ý nghĩa 1 CHAS 1: ven sông Charles River, 0: ngược lại 2 CRIM Tỷ lệ tội phạm trên đầu người 3 INDUS Tỷ lệ % không kinh doanh bán lẻ 4 NOX Mức độ ô nhiễm nitrogen oxide
  • 5. Cấu trúc dt1 Str (dt1) : Dùng để tổng quát cấu trúc data, tổng số biến, quan sát và loại biến ( rời rạc hay phân nhóm) Dữ liệu dt1 gồm 506 quan sát và 4 biến. Các biến đều ở dạng numeric head (dt1) : Xem vài dòng đầu của data để kiểm tra dữ liệu dưới dạng mẫu summary (dt1) : Giúp hiểu số liệu thống kê cơ bản của từng biến trong dữ liệu. (giá trị min –max, tứ phân vị)
  • 6. Ma trận tương quan giữa các biến Ý nghĩa: 0<p<1: 2 biến có tương quan đồng biến  Tỷ lệ không bán lẻ (INDUS) có mối quan hệ đồng biến với mức độ tội phạm (CRIM) và mức độ ô nhiễm (NOX). Nếu mức độ tội phạm (CRIM) và mức độ ô nhiễm (NOX) tăng thì tỷ lệ không bán lẻ (INDUS) có thể sẽ tăng cor(dt1)
  • 7. Ma trận tương quan giữa các biến Tạo dataframe dt1.1 bao gồm các biến log_crim, NOX2,NOX3 từ dataframe dt1: dt1.1 <- transmute(dt1,log_cirm= log(CRIM),NOX2=NOX^2,NOX3=NOX^3) Tạo dataframe mới là dt được ghép từ dt1 và dt1.1. Ta được bảng mới như sau dt <- data.frame(dt1,dt1.1) dt
  • 8. Ma trận tương quan giữa các biến Ý nghĩa: Tỷ lệ không bán lẻ (INDUS) và log_crim có mối tương quan chặt hơn so với CRIM cor(dt)
  • 9. Vẽ biểu đồ cho từng cột dữ liệu ggplot(dt,aes(x=CHAS))+geom_bar()+ theme_classic() ggplot(dt,aes(x=log_crim))+geom_histogram()+ theme_classic() ggplot(dt,aes(x=INDUS))+geom_histogram()+ theme_classic() ggplot(dt,aes(x=NOX))+geom_histogram()+ theme_classic()
  • 10. Vẽ biểu đồ cho từng cột dữ liệu
  • 11. Vẽ biểu đồ Box_plot ggplot(dt,aes(x=NOX))+geom_boxplot()+ theme_classic() ggplot(dt,aes(x=INDUS))+geom_boxplot()+ theme_classic() ggplot(dt,aes(x=CRIM))+geom_boxplot()+ theme_classic()
  • 12. Vẽ biểu đồ tương quan ggplot(dt,aes(NOX,INDUS))+geom_point()+geom_smooth() ggplot(dt,aes(log_crim,INDUS))+geom_point()+geom_smooth() ggplot(dt,aes(log_crim,NOX))+geom_point()+geom_smooth()
  • 13. Dự báo tỷ lệ không có hoạt động bán lẻ (indus) do tội phạm (log_crim) INDUS = 12.947 + 2.319 * log_crim + e Ví dụ Với log_crim= -2.427128428 Theo mô hình -> INDUS= 7.318489175 +e Thực tế: INDUS = 7.87  Mức độ tội phạm theo (log_crim) giải thích được 53,41% tỷ lệ không bán lẻ INDUS ĐÁNH GIÁ MÔ HÌNH
  • 14. Dự báo tỷ lệ không có hoạt động bán lẻ (indus) do tội phạm (nox) INDUS = 19.14 – 175.03*NOX + 453.56*NOX2 -291.31 *NOX3 + e Ví dụ Với NOX= 0.524 NOX2= 0.274576 NOX3= 0.14387782 Theo mô hình -> INDUS= 10.0623106 Thực tế: INDUS = 7.87  Mức độ ô nhiễm giải thích được 63,59% tỷ lệ không bán lẻ ĐÁNH GIÁ MÔ HÌNH
  • 15. Dự báo tỷ lệ không có hoạt động bán lẻ (indus) do tội phạm và mức độ ô nhiễm INDUS = 2.8437 – 58.1813*NOX+222.0390*NOX2 - 155.6045*NOX3+ 0.6728*log_crim +e  Với mô hình này mức độ tội phạm và ô nhiễm giải thích được 64,85% tỷ lệ không bán lẻ ĐÁNH GIÁ MÔ HÌNH
  • 16. Tăng cường chính xác bằng chas và không chas Tạo ra bộ dữ liệu dt2 với điều kiện CHAS ==1 Tạo ra bộ dữ liệu dt3 với điều kiện CHAS ==0
  • 17. CHAS==1 INDUS = -99.6706 + 371.8444*NOX -360.7045*NOX2 +104.2718*NOX3 - 0.5326*log_crim +e  Với mô hình này mức độ tội phạm và ô nhiễm giải thích được 87,35% tỷ lệ không bán lẻ, tỷ lệ cao hơn so với tỷ lệ tương ứng ở bộ dữ liệu dt. ĐÁNH GIÁ MÔ HÌNH
  • 18. CHAS==0 INDUS = -8.5154 -85.2835*NOX +264.2591*NOX2 - 177.3208*NOX3 +0.7026*log_crim +e  Với mô hình này mức độ tội phạm và ô nhiễm giải thích được 63,81% tỷ lệ không bán lẻ, tỷ lệ thấp hơn so với tỷ lệ tương ứng ở bộ dữ liệu dt. ĐÁNH GIÁ MÔ HÌNH