Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
1
Turning DataintoInsight
https://www.youtube.com/watch?v=6jDjeNJrN14
Peerapong E.(aka. PE)Professional Petroleum Engineer
Specialized in Production Optimization
Inventor of Optimization Intellectual Property
Education
• Msc, Petroleum Engineering (Optimization),
Texas A&M University [Fulbright Scholarship]
• Certified Rapidminer Analyst
Work Experience
• PTT Group RD&T Gold Award Team Leader
• PTTEP, Data Sci Team Leader, PTTEP Digital Transformation
• Founder of FB page Elephant Data
Thailand (ข่ีช้างจบัข้อมลู)
• Founder of DEXTRACT solution3
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Charity Workshop: Battle of Top Data-Sci Software
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
• Workshop ในระดบั introduction เพ่ือช่วยให้บคุคลทัว่ไปที่สนใจสามารถตดัสินใจเลือก application ท่ีเหมาะสม
• เปรียบเทียบการท างานของ software หลายๆตวั ในการแก้ปัญหาแบบเดียวกนั เพ่ือดโูครงสร้างของ programming language และ demo application
• Free event น าเงินบริจาคให้การกศุลทัง้หมด
• Slide ทัง้หมด จะ upload ให้ใน FB เพจ ข่ีช้างจบัข้อมลู นะครับ
ท่ีมาของ charity workshop อนัน้ี
พีWeb scraping
พี่เอกRapidminer
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
มาท าบุญดว้ยกนัเงินบริจาคทั้งหมด ไม่หกัค่าใชจ่้าย บริจาคใหก้บั
6
สนบัสนนุกลุ่มลกูเหรียง เพ่ือเป็นทนุการศกึษาของเด็กสามจงัหวดัชายแดนใต้ ท่ีครอบครัวเสียชีวิตจากเหตไุม่สงบ
บริจาคให้สตัว์พกิาร ท่ีมลูนิธิบ้านสงเคราะห์สตัว์พกิาร
บริจาคเพ่ือช่วยซือ้เคร่ืองช่วยหายใจในเด็กกบัโรงพยาบาลเด็ก
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Why Programming?
Programming trend for new generation
8
Write application with Python
Basic Programming with Python
Code with drag & drop
(Scratch)
Logical Thinking
9
It will be 3rd language for Thai student
https://www.blognone.com/node/102435
Why is it so hard to start something
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
The very first questions before getting startedเหตุการณ์สมมุติจากเร่ืองจริง หลายๆคร้ัง
พี อยากเรียนเขียน code
เอาดิ เริ่มเลย
เริ่มเรียนตัวไหนดี
มีสามตัวแนะน า
R มี function stat เยอะ syntax ไม่ยาก
Python ท าอะไรได้หลากหลาย ตัวเดียวครบ
RapidMiner ท า data sci ได้ไม่ต้องเขียน code
ลองหาดู มีเรียน online เยอะเลย
www.udemy.com
www.datacamp.com
www.coursera.org
Read10:00
Read10:05
Read10:05
Read10:06
Read10:06
Read10:06
Read10:07
Read10:07
Read10:07
9:58
10:02
นาย ก. (นามสมมตุ)ิ
เป็นไงบ้าง เรียนไปถึงไหนละ
เรื่องไรวะ
ที่บอกว่าจะเรียนเขียน program ไง
มาๆ งั้นจัด Workshop สอน Intro ให้หมดเลย
สึดดดด แล้วจะได้เริ่มม๊ัยยยย
Read09:13
Read09:16
Read09:17
Read09:12
นาย ก. (นามสมมตุ)ิ6 months later …
งานยุ่งว่ะ ยังไม่ได้เริ่มเลย T_T
Read09:15
Read09:05
Read09:14
แล้วมาท าVisualize Power BI สวยๆ ฟรีด้วยRead10:06
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Learning curve
http://spatial-ecology.net/?p=725
Which Applications to
get started?
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
KDnuggets Poll 2018
About KDnuggetshttps://www.kdnuggets.com/about/index.html
2018 KDnuggets Poll:
What software you used for
Analytics, Data Mining, Data
Science, Machine Learning
projects in the past 12 months?
“Not competition, but collaboration”
หา Condoราคาไม่แพงใกลอ้อฟฟิศ
วิเคราะห์ ราคาคอนโด ใน กรุงเทพ และ แนวโน้มราคาในอนาคต
Data Sci Workflow
Data collection Data Cleaning Data Mining Visualization
Data Geek
Require Intensive Coding
Business User
Expensive+
Various software
This Workshop
Get big picture of
workflow + Compare various
software
Searching Condo Ver 0.4
Searching condo for Thailand 4.0Condo price: Hipflat.com
Collect price from all condo with Python web scraping
Data collection Data Cleaning Data Mining Visualization
Scikit Learn in Python20
Simple Machine Learning Example
Same Data set and algorithm, Various Method
Data collection Data Cleaning Data Mining Visualization
Data Cleansing and Mining
Linear Regression Multivariate Linear Regression
Simplified Workflow using Multivariate Linear Regression*Only regression part, no cross-validation, feature engineering …*
Data collection Data Cleaning Data Mining Visualization
Every web has it’s own insightCondo price: Hipflat – Sales Price
Data Visualization with Power BI
Full loop data analytics workshop
Data collection Data Cleaning Data Mining Visualization
Data Visualization with Power BI
Our Instructors
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Agenda
Schedule Topic Instructor
08:30 Registration
09:00 Introduction to the eventWeb Scraping for data preparationMachine Learning Example
Peerapong
09:40 Introduction to Rapidminer studioMachine Learning Example
Dr. Eakasit
10:20 Break
10:40 Power of Analytics with RMachine Learning Example
Dr. Kanokwan
11:20 Introduction to Power BIData Visualization and analytics
Rapheephan
11:50 Games (with free gift)
12:00 Finish
26
Python as an opensource programming
27
The Infinity Libraries
• Python Anaconda Package Introduction
• Demo : Web Scraping with BeautifulSoup
• Demo : Multivariate Linear Regression
• Optional Demo : Web Scraping with Selenium
28
Section#1 Python
29
Anaconda Package
30
Anaconda is…
Umm, yes it is; but it’s not anaconda we mention here
31
Without the interface (IDE)
Text file (.py)
Running script in command prompt
This is the conventional way to run Python
การรัน Python แบบดัง้เดิม ท่ีเห็น Geek รันกนั แตเ่ราจะท าอีกแบบท่ีง่ายกว่านัน้
• Anaconda is a free and open source distribution of the Python and Rprogramming languages for data science and machine learning related applications
• That aims to simplify package management and deployment.
• The Anaconda distribution is used by over 6 million users, and itincludes more than 250 popular data science packages suitable for Windows, Linux, and MacOS.[5]
32
Anaconda is…
Yes!!!Everyone can
develop
Originally support
Python, R is added later
With anaconda, (most of) Python environment is ready to use
The pre-installed “infinity stones”
Download Anaconda
33
www.anaconda.com
Open via Anaconda Navigator
34
Open via Anaconda Navigator
35
We will use the Jupyternotebook for this workshop
For practical development, recommend Spyder
Notebook Shellstyle coding
Top-Down conventional style coding
IDE สองตวัท่ีจะใช้ใน class คือ Spyder และ Jupyter เพ่ือท าให้ชีวิตง่ายขึน้36
Spyder IDE
http://sjbyrnes.com/python/37
Spyder แบง่แยก Partition ของการท างาน คล้ายๆ Rstudio (ส าหรับคนท่ีเคยเขียน R มา)
Jupyter Notebook
https://techtalktone.wordpress.com/2017/03/28/running-jupyter-notebooks-on-a-remote-server-via-ssh/
38
Jupyter จะใช้เป็นหลกัใน workshop นี ้จะเน้นการสอดแทรก Text และ รัน code ทีละ step
Notebook Shellstyle coding
Top-Down conventional style coding
39เปรียบเทียบหน้าตา Spyder รันรวดเดียวจบ Jupyter รันทีละ cell
การมีข้อมลู
จุดเร่ิมตน้ของการวเิคราะห์ขอ้มูลคือ
40
41
The Fundamental Step of Data
Turning Unstructured Data to be Structured
Python for Scraping
https://medium.com/the-andela-way/introduction-to-web-scraping-87edf94ac692
What is web scraping?
Web scraping is a technique for gathering data or information on web pages. A scraper is a script that parses an html site. Scrapers are bound to fail in cases of site re-design.
As much as there’re many libraries that support web scraping, we will delve into web scraping using python libraries.
Why python?
Python is one of the most popular languages for web crawling. In this tutorial, I will use beautiful soup since it is easy and highly efficient.
42
Scraping คือการเอา data จาก Website ดงึมาอยูใ่นรูปแบบที่เราสามารถใช้งานตอ่ได้ เช่น Excel, CSV, Text
Key Idea in this workshop
Web Data Excel
ExtractionSummarize Further
work
43
เราจะเน้น Technique ในการดงึข้อมลูจากเวปในรูปแบบตา่งๆ แล้วน ามาเก็บไว้ใน Excel โดยใช้ Jupyter Notebook เป็นตวัช่วย
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
BeautifulSoup
Web Scraping in Python
Selenium Scrapy
• Quick Easy to implement web scraping
• Entry library for web scraping
• Automated web testing automation
• Can perform human-like task
• Can handle web wthjavascript
• Framework for large scale web scraping
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Html code inside the web
• Right Click at any place on the web page• Select inspect element
• HTML code show up
45
ข้างใน Web ถกูเขียนด้วย HTML structure
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
• Extract multiple elements from Hipflat using
beautifulsoup library
Workshop46
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Let’s do the exercise
SC-14_Hipflat_Abstracts
47
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Export data to Excel with openpyxl library
48
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Openpyxl library
https://openpyxl.readthedocs.io/en/stable/
Openpyxl is a Python library for reading and writing Excel 2010• Xlsx (will use in this workshop)• xlsm• xltx• xltm
49
Library เพ่ือให้ Python ติดต่อกบั Excel
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Idea Flowchart
func_Scrape- Input = URL- Operation = Web scraping- Output = Data from web
func_PrintExcel- Input = data to be printed- Operation→ print to excel and save
New URL:For loop
50
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Let’s do the exercise
Scraping and save to ExcelSC-15_Hipflat_Full_Loop
51
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Machine Learning Project: Condo PricePrediction
Proj-03_CondoPricePrediction
52
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Common form of Data Mining
Use Correlation to predict “Number”
Use Correlation to Classify Type
53
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Multivariated Linear Regression
Linear Regression Multivariated Regression
54
y = f(x) y = f(x1,x2,x3,x4,…)
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
Multivariated Linear Regression55
Input:- Year Built
- Number of Floor
- Distance to BTS/MRT Station
- Distance to Siam Paragon
Output:- Sale Price
Model Matching
Prediction
- Use the model to predicted sales price of 30th floor condo
- At predefined location (100 locations)- Year built from 2018 – 2025
FB Page: ข่ีช้างจบัข้อมลู www.elephant-analytics.com
PJ-3A_ScikitLearn
Workshop on Python MultivariatedRegrssion