Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added .gitbook/assets/1_1_image_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/1_1_image_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
163 changes: 163 additions & 0 deletions atom/1-data-strategy-and-metrics/1.1-data-strategy.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,168 @@
# 1.1 - Data Strategy

![](../../.gitbook/assets/1_1_image_1.png)

## WHAT Data?

![](../../.gitbook/assets/1_1_image_2.png)

1. Dữ liệu phổ biến nhất có dạng bảng, gồm nhiều dòng (records) và cột (thông tin)
2. Dữ liệu dạng bảng nằm ở: Sao kê ngân hàng, hoá đơn, danh sách đăng ký, thu chi trong tháng...

Ví dụ 1. Danh sách đăng ký | Ví dụ 2. Hoá đơn
:-------------------------:|:-------------------------:
![](../../.gitbook/assets/1_1_image_3.png) | ![](../../.gitbook/assets/1_1_image_4.png)

### Big Data

![](../../.gitbook/assets/1_1_image_5.png)

1. Big Data trở thành “buzzword"
2. Tăng lên về:
- Khối lượng (Volume)
- Tần suất (Velocity)
- Sự Đa Dạng(Variety)
- Chất lượng (Veracity)
3. Khi nhấn mạnh “Big" ta quên đi chữ “V" thứ 5: VALUE

### Take-away #1: SMART Data not Big Data

1. Every Business can Data (Mọi DN đều tạo ra dữ liệu)
2. Dữ liệu không phải lúc nào cũng hữu ích. DN nhỏ càng cần chọn lọc
3. Dữ liệu chỉ có ý nghĩa khi tạo ra giá trị. Dữ liệu cần giải quyết một vấn đề/nhu cầu cụ thể của DN (Chiến lược Dữ liệu)
4. Bắt đầu bằng Chiến lược thay vì Data (bạn đang có)

## WHERE Data FROM?

1. Bất kỳ Doanh Nghiệp (DN) nào cũng là một DN dữ liệu
2. Bất kỳ Quy trình nào cũng có thể tracking => Dữ liệu => Dùng dữ liệu để tối ưu hoá chính quy trình đó

![](../../.gitbook/assets/1_1_image_6.png)

### Data Solution - Hai-mươi-bảy Pre-order

Quy Trình Pre-ordering:
1. Độc giả:
- Truy cập website
- Điền thông tin Đơn Hàng (MS, Tên, địa chỉ, số lượng…)
- Nhấn nút “request" cập nhật Trạng Thái Đơn Hàng (Nhận chuyển khoản, Đã gửi, Đã nhận)
2. Người bán:
- Check các Đơn Hàng
- Trạng Thái Đơn Hàng (Nhận chuyển khoản, Đã gửi, Đã nhận)
3. Reporting Dashboard (Project members):
- Đã bán được bao nhiêu sách
- Bao nhiêu đã chuyển khoản, gửi đi...

![](../../.gitbook/assets/1_1_image_7.png)

Database | Visualize
:-------------------------:|:-------------------------:
![](../../.gitbook/assets/1_1_image_8.png) | ![](../../.gitbook/assets/1_1_image_9.png)

### Take-away #2: Giải Pháp Dữ liệu Bình Dân

1. Không đủ kinh phí không nên là mối bận tâm
2. Có nhiều giải pháp Dữ liệu giá cả rất bình dân, sử dụng Cloud Service + Open-source (Gần như miễn phí cho scale nhỏ và siêu nhỏ)
3. “Lợi thế của người đến sau” - Tận dụng các giải pháp mới (modernized & democratized)

## Data Strategy - HOW?

![](../../.gitbook/assets/1_1_image_10.png)

### Data Strategy - Câu hỏi lớn

1. Khoanh vùng các mảng:
- Customer/Market
- Fin (Rev/Cost)
- Operations (CVR, Channel)
- People
2. Các câu hỏi trong từng mảng
3. Xác định mức độ ưu tiên => Shortlist
- Các câu hỏi quan trọng nhất?
- Câu nào trước câu nào sau?
- Đi từng mảng hay tất cả (các mảng nào liên quan)
4. Các Metrics để trả lời?
5. Visualize, Insights, Communications

| <br>Mảng | <br>Câu hỏi | <br>Metrics | <br>Giải pháp |
|--- |--- |--- |--- |
| Khách hàng/ Thị trường | 1. Tập khách hàng quan trọng nhất?<br>2. Họ là ai?<br>3. Xu hướng thị trường? <br>4. Khách hàng thích gì? | 1. Lifetime Value (bao nhiêu giao dịch, giá trị mỗi giao dịch)<br>2. CVR (Conversion Rate): Visit, Order, Chuyển khoản<br>3. Ratings | 1. User Segmentation<br><br>2. LTV / Churn prediction<br>3. User Path |
| Tài chính (Revenue/Cost) | 1. Đang lời/lỗi?<br>2. Mảng sinh lời nhiều nhất?<br>3. Hiệu quả? | 1. Revenue/Cost/Profit<br>2. ROI | 1. Time-series Prediction<br>2. Break-down (leading metrics) |
| Vận Hành | 1. Khách hàng đang “kẹt" ở bước nào?<br>2. Mảng nào đang hoạt động tốt? | 1. CVR<br>2. Engagement Metrics<br>3. Quality metrics<br>4. Capacities/ Resource Allocation | 1. Dynamic Allocation<br>2. Dynamic Pricing |
| Con người | 1. Nhân viên nào đang hoạt động hiệu quả?<br>2. Nhân viên nào quan trọng | 1. Activity metrics (calls/emails)<br>2. CVR<br>3. KPI (final target) | 1. Segmentation |

### Data Solution - Cycle of Development

**1. Tìm hiểu các Dữ liệu DN đang có**
- Files rời rạc, update thủ công, không tạo thành bức tranh toàn cảnh.
**2. Đề xuất Data Model cho DN**
- Phục vụ việc tổ chức data hiệu quả và linh động.
**3. Initial Insights & Data Strategy**
- Phân tích tìm insights nếu có trong dữ liệu hiện tại
- Đề xuất Chiến lược dữ liệu

### Data Solution - Event Avenue Booking Business

Câu hỏi lớn của DN
- Khách hàng
- Ai là khách hàng quan trọng nhất?
- Làm gì với từng nhóm khách hàng khác nhau?
- Vận hành
- Khía cạnh nào trong sản phẩm không được đánh giá cao?
- Tối ưu chúng như thế nào?

![](../../.gitbook/assets/1_1_image_11.png)

### Case Study

#### Cải Thiện Sản Phẩm

1. Phân tích tương quan giữa các yếu tố ratings
2. Hệ số tương quan: -1 tới +1
3. Metrics:
- Lần booking gần nhất (min_ddiff_since_last_booking)
- Số lần booking (acc_freq)
- Size (avg_no_of_attendee)

![](../../.gitbook/assets/1_1_image_12.png)

#### Phân Loại Khách Hàng

1. Pareto 80:20
2. RFM (Recency - Frequency - Monetary)
3. Before:
- Tập trung vào các khách hàng lớn
- Insights: Khách hàng nhỏ trở lại thường xuyên hơn và tạo ra nhiều Revenue hơn

![](../../.gitbook/assets/1_1_image_13.png)

#### Dự đoán

![](../../.gitbook/assets/1_1_image_14.png)

### Take-away #3: DN nhỏ và siêu nhỏ vẫn có thể có Chiến lược dữ liệu

1. Một chiến lược tốt không phục thuộc vào việc DN đang có dữ liệu gì?
2. Xoay quanh các vấn đề cụ thể mà DN quan tâm, cần giải quyết
3. Chiến lược cần đem lại các giá trị hữu hình
4. Bắt đầu “thật" đơn giản: Không cần trả lời tất cả câu hỏi

## Data Strategy in Action

1. SMART
- Specific
- Measurable
- Achievable
- Releastic
- Timely
2. Ownership: “Sự nghiệp của mọi nhà"
3. Chia-để-Trị: Milestones
4. Data-driven Culture
- Tin và sử dụng data trong vận hành và ra quyết định
- BI tools (Dashboard)
- Data Literacy


## Nguồn tham khảo

> Slide: [DATACracy \| Datatalk Premium\#1 \| Data Strategy](https://docs.google.com/presentation/d/1YRDjcK6as04WxGga0rPQMyd1AwJmL3ySFDfgVUCpGjs/edit#slide=id.gcf12cb55cb_0_0)
Expand Down
169 changes: 169 additions & 0 deletions atom/2-data-tools-1/2.2-python-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,183 @@ fruit = apple + orange

## Import Modules & .

Module tương đương với một file `.py` chứa những câu lệnh python. Và một module có thể được sử dụng lại trong mã khác bằng việc thực thi một lệnh import trong các file khác

```text
import math
math.pi
# 3.141592653589793
```

Có nhiều phương thức để cho phép chỉ `import` một phần của module hoặc đổi tên module khi chúng ta import nó.

Ví dụ dưới đây chỉ import giá trị `pi` từ module `math`

```text
from math import pi
pi
# 3.141592653589793

math.pi
# NameError: name 'math' is not defined
```

```text
from math import pi as PI
PI
# 3.141592653589793
```

## Functions

Function là một đơn vị cơ bản trong Python, mỗi hàm thực hiện một nhiệm vụ (task)) và trả về một kết quả (result)

Có ba dạng function trong Python:

- Built-in functions, such as help() to ask for help, min() to get the minimum value, print() to print an object to the terminal,… You can find an overview with more of these functions here.
- User-Defined Functions (UDFs), là các hàm mà người dùng tạo ra bằng từ khoá tiêu chuẩn `def`
- Anonymous functions, hay còn được gọi là lambda functions vì chúng không được khai báo với từ khóa def tiêu chuẩn.

Trong Python, chúng ta sử dụng từ khoá `def` để định nghĩa (define) một function.

```text
def hello():
print("Hello World!")

hello()
```

Tránh sử dụng tên của các hàm Built-in làm function name cho các hàm UDF.

```text
def print():
print("Hello, world!") # Error!
```

Nếu một hàm không có tham số (parameter), thì thi gọi hàm đó chúng ta không thể thêm những đối số (arguments). Nhưng nếu khi định nghĩa hàm có parameter, thì phải đưa nhập vào arguments cho nó.

```text
def say_hello(name):
print(f"Hello, {name}!")


say_hello("Bob")
say_hello() # Error, needs an argument
```

Để một hàm dễ đọc hơn, chúng ta thường sẽ thêm **keyword arguments** cho function đó.

```text
def say_hello(name):
print(f"Hello, {name}!")

say_hello(name="Bob")
```

Nếu chúng ta muốn một hàm trả về một giá trị thì phải gọi từ khoá `return`. Tất cả các hàm đều sẽ return _một giá trị nào đó_. Và mặc định là None.

```text
def add(x, y):
return x + y

add(1, 2) # Nothing printed out anymore.
result = add(2, 3)
print(result) # 5
```

## If-Else

Phát biểu if–else biểu diễn quyết định. Lệnh if được sử dụng để kiểm tra một điều kiện, nếu điều kiện là true thì lệnh của khối if sẽ được thực thi. Còn lệnh else được thực thi nếu biểu thức điều kiện trong lệnh if được ước lượng là 0 hoặc một giá trị false.

```text
if condition:
expression
else:
expression
```

```text
z = 5
if z % 2 == 0:
print("z is even")
else:
print("z is odd")
```

## List

Trong Python list là một dạng dữ liệu cho phép lưu trữ nhiều kiểu dữ liệu khác nhau và được phân tách nhau bởi dấu phẩy (`,`), list được đặt trong cặp dấu ngoặc vuông (`[]`).

```text
l = ["Bob", "Rolf", "Anne"]
```

Để truy xuất các phần tử bên trong list, chúng ta dùng vị trí (index)

```text
print(l[0])
```

Đồng thời chúng ta cũng có thể thay đổi từng phần tử bên trong list thông qua index

```text
l[0] = "Smith"
print(l) # ['Smith', 'Rolf', 'Anne']
```

Để thêm một phần tử vào list thì chúng ta dùng từ khoá `.append`

```text
l.append("Jen")
print(l) # ['Smith', 'Rolf', 'Anne', 'Jen']
```

## Loops: For-in

Vòng lặp for được sử dụng kết hợp với một đối tượng có thể lặp lại, như `list` hoặc `range`. `for` lặp lại cho từng phần tử của một chuỗi theo thứ tự.

```text
grades = [35, 67, 98, 100, 100]
total = 0
amount = len(grades)

for grade in grades:
total += grade

print(total / amount)
```

## Dictionaries

Một kiểu dữ liệu hữu ích khác trong Python là `dictionary`. Khác với `list`, `dictionary` là một tập hợp các cặp `key: value` với yêu cầu các khoá `key` là duy nhất .

```text
friend_ages = {"Rolf": 24, "Adam": 30, "Anne": 27}

friend_ages["Bob"] = 20

print(friend_ages) # {'Rolf': 24, 'Adam': 30, 'Anne': 27, 'Bob': 20}

friends = [
{"name": "Rolf Smith", "age": 24},
{"name": "Adam Wool", "age": 30},
{"name": "Anne Pun", "age": 27},
] ## List of dictionaries

```

Khi dùng vòng lặp đối với `dictionary`, `key` và `value` tương ứng có thể được truy xuất cùng lúc bằng method `items()`.

```text
student_attendance = {"Rolf": 96, "Bob": 80, "Anne": 100}

for student, attendance in student_attendance.items():
print(f"{student}: {attendance}")

# Rolf: 96
# Bob: 80
# Anne: 100
```

## Practice - Hackerrank

Expand Down Expand Up @@ -112,4 +278,7 @@ if name == 'main': n = int(raw_input().strip())
* Python Basic Tutorials: [Python Keywords, Identifiers and Variables for Beginners](https://www.techbeamers.com/python-keywords-identifiers-variables/)
* Python Tutorials: [Python Tutorial](https://www.w3schools.com/python/default.asp)
* Python Snippets: [Python Snippets - 30 seconds of code](https://www.30secondsofcode.org/python/p/1)
* Python import: Advanced Techniques and Tips: [Python import: Advanced Techniques and Tips](https://realpython.com/python-import/)
* Github - python-refresher: [python-refresher](https://github.com/tecladocode/python-refresher/tree/master)
* Python Functions Tutorial: [Python Functions Tutorial](https://www.datacamp.com/tutorial/functions-python-tutorial)

Loading