Huy Che Quang
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    <center><h1>Logistic Regression</h1></center> ## Giới thiệu mô hình Logistic Regression: Logistic regression là mô hình được áp dụng trong bài toán phân loại nhị phân (Binary classification) tức ta sẽ có hai loại output là 0 hoặc 1. Logistic regrssion có rất nhiều ứng dụng trong cuộc sống như: * Spam detection: Dự đoán mail gửi đến hòm thư của bạn có phải spam hay không. * Credit card fraud: Dự đoán giao dịch ngân hàng có phải gian lận không. * Health: Dự đoán 1 u là u lành hay u ác tính. * Banking: Dự đoán khoản vay có trả được hay không. * Investment: Dự đoán khoản đầu tư vào start-up có sinh lợi hay không ![](https://i.imgur.com/N1gHPtZ.png) Thuật toán trên dùng hàm sigmoid logistic để đưa ra đánh giá theo xác suất. Ví dụ: Khối u này 80% là lành tính, giao dịch này 90% là gian lận, ...Nhưng thay vì dự đoán trực tiếp giá trị 0 hoặc 1 thì mô hình Logistic có thể dự đoán xác suất sau khi giá trị đầu ra đi qua hàm Sigmoid. Ta dễ dàng thấy được xác xuất quan trọng hơn là chỉ 0 hay 1, ví dụ trước mỗi ca mổ khó, bác sĩ không thể chắc chắn là sẽ thất bại hay thành công mà chỉ có thể nói xác xuất thành công là bao nhiêu (ví dụ 80%). Từ đồ thị hàm Sigmoid bên dưới ta có thể đưa ra nhận xét rằng: * Hàm số liên tục, nhận giá trị thực trong khoảng (0,1). * Hàm có đạo hàm tại mọi điểm (để áp dụng gradient descent) <p align="center"> <img src="https://i.imgur.com/nwyNC2q.png" /> </p> ## So sánh Linear regression và Logistic regression Linear Regression và Logistic Regression là hai mô hình máy học nổi tiếng thuộc kỹ thuật học có giám sát (Supervised Learning). Vì cả hai mô hình đều có bản chất là học giám sát nên các thuật toán này sử dụng tập dữ liệu được gắn nhãn để đưa ra các dự đoán. Nhưng sự khác biệt chính giữa hai mô hình là cách chúng được sử dụng. Linear Regression được sử dụng để giải các bài toán hồi quy trong khi Logistic Regression được sử dụng để giải các bài toán phân loại. <p align="center"> <img src="https://i.imgur.com/0VdTsJh.png" /> </p> | Linear Regression | Logistic Regression | |---|---| | Linear Regression được sử dụng để giải quyết vấn đề hồi quy. | Logistic Regression được sử dụng để giải quyết các vấn đề về phân loại. | | Linear regression dự đoán giá trị của các biến liên tục. | Logistic Regression dự đoán giá trị của các biến phân loại. | | Với Linear Regression ta cần tìm ra phương trình đường thẳng phù hợp nhất mà từ đó ta có thể dự đoán đầu ra. | Với Logistic Regression ta cần tìm ra đường thẳng có thể chia cắt hai tập dữ liệu. | | Sử dụng hàm độ lỗi là Mean Square Error (MSE). | Sử dụng hàm độ lỗi Cross Entropy. | | Đầu ra cho Linear Regression phải là một giá trị liên tục, chẳng hạn như giá, tuổi,... | Đầu ra của Logistic Regression phải là giá trị phân loại chẳng hạn như 0 hoặc 1, Có hoặc Không,... | ||Logistic Regression sử dụng hàm Sigmoid cho giá trị đầu ra| ## Hàm độ lỗi (Loss Function) Logistic Regression sử dụng Cross Entropy làm hàm độ lỗi. Vậy tại sao ta cần lại cần hàm độ lỗi Cross Entropy cho Logistic Regression? Vì mô hình Logictics Regression có hai đầu ra là 0 hoặc 1 nên có thể được mô hình hóa bằng phân phối Bernoulli: $$ \mathrm{P}_x = \begin{cases} p & \text{if } y = 1 \\ 1-p & \text{if } y = 0 \end{cases} $$ Để đánh giá mức độ hiệu quả của mô hình thì dựa trên likelihood function. Với m mẫu dữ liệu, likelihood function này được định nghĩa là: $$ \mathrm{L}_w = \prod_{i = 1}^{m} \hat{P}(\mathrm{y}_i|\mathrm{x}_i,w) $$ Nhưng do việc tìm các trọng số w để cực đại hóa các likelihood function phức tạp. Nên likelihood function được biến đổi thành negative log likelihood có phương trình như sau: $$ \mathrm{NNL}_w = \sum_{i = 1}^{m} \log(\hat{P}(\mathrm{y}_i|\mathrm{x}_i,w)) $$ Ta có: $$ \hat{P}(0|x,w)=1-\hat{P}(1|x,w) $$ Ta có thể viết lại như sau: $$ \hat{P}(\mathrm{y}_i|\mathrm{x}_i,w)=\hat{P}(0|x,w)^{y}.\hat{P}(1|x,w)^{1-y} $$ Thế biểu thức trên vào NLL_w và chuẩn hóa theo số lượng mẫu dữ liệu ta được hàm binary cross-entropy: $$ J(w)=-\frac{1}{m}\sum_{i = 1}^{m}\mathrm{y}_i\log(\hat{P}(1|x,w))+(1-\mathrm{y}_i)\log(1-\hat{P}(0|x,w)) $$ $$ =-\frac{1}{m}\sum_{i = 1}^{m}\mathrm{y}_i\log(\sigma(w^{t}\mathrm{x}_i))+(1-\mathrm{y}_i)\log(1-\sigma(w^{t}\mathrm{x}_i)) $$ Với $\sigma(w^{t}\mathrm{x}_i)$ là hàm sigmoid Việc tìm kiếm trọng số để cự tiểu $J(w)$ cũng như việc cực đại likelihood function, vậy ta có thể dùng hàm $J(w)$ như hàm mất mát của mô hình Logictics Regression. ## Tối ưu hàm mất mát với Gradient Descent Ta có hàm Sigmoid: $$ \sigma(w^{t}x)=\frac{1}{1+e^{-w^{t}x}} $$ Ta có hàm mất mát với một điểm dữ liệu là : $$ J(w)=-\mathrm{y}_i\log(\sigma(w^{t}\mathrm{x}_i))+(1-\mathrm{y}_i)\log(1-\sigma(w^{t}\mathrm{x}_i)) $$ Ta tính đạo hàm hàm mất mát theo w để cập nhật trọng số: $$ \displaystyle \frac{\partial J(w)}{\partial w}=\displaystyle \frac{\partial J(w)}{\partial \sigma(w^{t}\mathrm{x}_i)}\displaystyle \frac{\partial \sigma(w^{t}\mathrm{x}_i)}{\partial w}= -(\frac{\mathrm{y}_i}{\sigma(w^{t}\mathrm{x}_i)}-\frac{\mathrm{y}_i}{\sigma(w^{t}\mathrm{x}_i)})\frac{\partial \sigma(w^{t}\mathrm{x}_i)}{\partial w} $$ $$ =\frac{\sigma(w^{t}\mathrm{x}_i)-\mathrm{y}_i}{\sigma(w^{t}\mathrm{x}_i)(1-\sigma(w^{t}\mathrm{x}_i))}\displaystyle \frac{\partial \sigma(w^{t}\mathrm{x}_i)}{\partial w} $$ Ta có: $$ \displaystyle \frac{\partial\sigma(w^{t}\mathrm{x}_i)}{\partial\mathrm{w}_0}=\sigma(w^{t}\mathrm{x}_i)(1-\sigma(w^{t}\mathrm{x}_i)) $$ $$ \displaystyle \frac{\partial\sigma(w^{t}\mathrm{x}_i)}{\partial\mathrm{w}_1}=\mathrm{x}_i^1\sigma(w^{t}\mathrm{x}_i)(1-\sigma(w^{t}\mathrm{x}_i)) $$ $$ \displaystyle \frac{\partial\sigma(w^{t}\mathrm{x}_i)}{\partial\mathrm{w}_2}=\mathrm{x}_i^2\sigma(w^{t}\mathrm{x}_i)(1-\sigma(w^{t}\mathrm{x}_i)) $$ Do đó: $$ \displaystyle \frac{\partial\sigma(w^{t}\mathrm{x}_i)}{\partial\mathrm{w}_n}=\mathrm{x}_i^n(\sigma(w^{t}\mathrm{x}_i)-\mathrm{y}_i) $$ với $\mathrm{x}_i^0$=1 vì $\mathrm{w}_0$ là hệ số tự do Đối với toàn bộ dự liệu (với m là tổng số điểm dữ liệu): $$ \displaystyle \frac{\partial J(w)}{\partial\mathrm{w}_n}=-\frac{1}{m}\sum_{i =1}^{m}\mathrm{x}_i^n(\sigma(w^{t}\mathrm{x}_i)-\mathrm{y}_i) $$ Với η là hệ số học (learning rate) ta có công thức cập nhật trọng số cho Logistic Regression như sau: $$ \mathrm{w}_n=\mathrm{w}_n-η\displaystyle \frac{\partial J(w)}{\partial\mathrm{w}_n} $$ ### Ví dụ về bài toán binary classification. Xét một ví dụ đơn giản, xét kết quả của nhóm sinh viên Trường Đại học Công Nghệ Thông Tin đậu hay rớt môn CS331 dựa vào kết quả thi giữa kỳ và thời gian học một ngày của các sinh viên. Ta sẽ thu được hình ảnh minh họa dưới đây: ![](https://i.imgur.com/tmz8CS4.png) Dễ dàng nhìn thấy đối với những sinh viên điểm giữa kỳ và thời gian học hằng ngày càng ít thì tỷ lệ rớt môn càng cao và ngược lại. Với đường thẳng màu xanh là đường thẳng chia cắt các sinh viên rớt môn và qua môn. Về mặt logic khi có được phương trình đường thẳng màu xanh dựa vào dữ liệu của các năm trước ta có thể dự đoán được kết quả đậu hay rớt môn của các sinh viên của năm hiện tại. Ví dụ năm nay có một sinh viên có điểm giữa kỳ là 9 và thời gian học một ngày là 8 tiếng thì sinh viên đó sẽ có tỷ lệ đậu cao. Giả sử bạn lấy mốc ở chính giữa là 50% tức là với một thông tin sinh viên mới cần dự đoán là có qua môn CS331 không dựa trên điểm giữa kỳ và thời gian học mô hình Logistic Regression dự đoán được $\sigma(w^{t}\mathrm{x}_i)$≥50% thì qua môn ngược lại thì rớt. Ta có: $$\sigma(w^{t}\mathrm{x}_i)≥0.5 <=> \frac{1}{1+e^{-z}} ≥ 0.5 <=> 2 ≥ 1+e^{-z} <=> 1 ≥ e^{-z} <=> e^{0} ≥ e^{-z} <=> z ≥ 0 $$ Với $\mathrm{x}_1$ là điểm giữa kỳ, $\mathrm{x}_2$ là thời gian học hằng ngày kết hợp cùng phương trình trên ta có: $$ \sigma(w^{t}\mathrm{x}_i)≥0.5 <=> \mathrm{w}_2\mathrm{x}_2+\mathrm{w}_1\mathrm{x}_1+\mathrm{w}_0≥0 $$ Tương tự: $\sigma(w^{t}\mathrm{x}_i)<0.5<=>\mathrm{w}_2\mathrm{x}_2+\mathrm{w}_1\mathrm{x}_1+\mathrm{w}_0<0$ => đường thẳng $\mathrm{w}_2\mathrm{x}_2+\mathrm{w}_1\mathrm{x}_1+\mathrm{w}_0=0$ chính là đường phân cách giữa các sinh viên qua môn và rớt môn. ## Cài đặt chương trình Để hiểu rõ hơn về mô hình Losgistic Regression. Chúng ta sẽ tiến hành viết mã để có thể hiểu cách triển khai nó. Ngôn ngữ được sử dụng ở đây là python. Đầu tiên chúng ta sẽ thêm các thư viện cần thiết. ```python from sklearn import datasets import pandas as pd import numpy as np from sklearn.model_selection import train_test_split from sklearn.decomposition import PCA import matplotlib.pyplot as plt from sklearn.metrics import confusion_matrix import itertools ``` Tiến hành xây dựng model logistic regression ```python class LogisticRegression: # Định nghĩa hàm khởi tạo def __init__(self, lr=0.001, n_iters = 1000): self.lr = lr # Learning rate cho thuật toán gradient descent self.n_iters = n_iters # Số lần lặp thuật toán gradient descent self.weights = None # Weight self.bias = None # Bias # Định nghĩa hàm huấn luyện cho mô hình def fit(self, X, y): # Khởi tạo tham số n_samples, n_features = X.shape # Lấy ra lần lượt số sample và feature của dữ liệu self.weights = np.zeros(n_features) # Khởi tạo mảng weight có số lượng bằng số features self.bias = 0 # Thuật toán gradient descent for _ in range(self.n_iters): hypothesis = np.dot(X, self.weights) + self.bias # Mô hình tuyến tính y_predicted = self.sigmoid(hypothesis) # Áp dụng hàm sigmoid để phục vụ việc dự đoán output cost = (-y * np.log(y_predicted) - (1 - y) * np.log(1 - y_predicted)).sum() / len(y) # Hàm loss accuracy = np.sum(y == self.predict(X)) / len(y) # Tính toán accuracy trên tập huấn luyện # In kết quả huấn luyện sau mỗi 50 iter if _ % 50 == 0 and _ != 0: print('Iter :' + str(_) + " Cost: " + str(cost) + " Accuracy : " + str(accuracy)) # Tính toán đạo hàm dw = (1 / n_samples) * np.dot(X.T, (y_predicted - y)) # dw = 1/N * Σx_i(y_hat - y_i) db = (1 / n_samples) * np.sum(y_predicted - y) # dw = 1/N * Σ(y_hat - y_i) # Cập nhật weight và bias self.weights -= self.lr * dw self.bias -= self.lr * db # Định nghĩa hàm dự đoán def predict(self, X): hypothesis = np.dot(X, self.weights) + self.bias # Mô hình tuyến tính y_predicted = self.sigmoid(hypothesis) # Áp dụng hàm sigmoid để phục vụ việc dự đoán output # Đặt ngưỡng lớn hơn 0.5 cho positive class (class 1), ngược lại là negative class (class 0) y_predicted_cls = [1 if i > 0.5 else 0 for i in y_predicted] return y_predicted_cls # Định nghĩa hàm sigmoid def sigmoid(self, X): p = 1 / (1 + np.exp(-X)) # 0 < p < 1 p = np.minimum(p, 0.9999) p = np.maximum(p, 0.0001) return p ``` Định nghĩa các hàm đánh giá ```python # Hàm tính toán accuracy def accuracy(y_true, y_pred): accuracy = np.sum(y_true == y_pred) / len(y_true) return accuracy ``` ```python # Hàm visualize confusion matrix (Source: Machine Learning cơ bản) def plot_confusion_matrix(cm, classes, normalize=False, title='Confusion matrix', cmap=plt.cm.Blues): if normalize: cm = cm.astype('float') / cm.sum(axis=1, keepdims = True) plt.imshow(cm, interpolation='nearest', cmap=cmap) plt.title(title) plt.colorbar() tick_marks = np.arange(len(classes)) plt.xticks(tick_marks, classes, rotation=45) plt.yticks(tick_marks, classes) fmt = '.2f' if normalize else 'd' thresh = cm.max() / 2. for i, j in itertools.product(range(cm.shape[0]), range(cm.shape[1])): plt.text(j, i, format(cm[i, j], fmt), horizontalalignment="center", color="white" if cm[i, j] > thresh else "black") plt.tight_layout() plt.ylabel('True label') plt.xlabel('Predicted label') plt.show() ``` Dùng sklearn load dữ liệu breast cancer ```python= bc = datasets.load_breast_cancer() df = pd.DataFrame(data=bc.data, columns=bc.feature_names) ``` ```python= df.head() ``` ![](https://i.imgur.com/2YvvgIL.png) ```python= df.describe() ``` ![](https://i.imgur.com/JoY5mXy.png) Phân chia dữ liệu và dự đoán trên hai trường hợp ```python= # Trường hợp 1: Huấn luyện mô hình trên toàn bộ chiều dữ liệu # Chia dữ liệu train và test X,y = bc.data, bc.target X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 126) #Khởi tạo model và training model = LogisticRegression(lr=0.00001, n_iters = 1000) model.fit(X_train, y_train) # In Accuracy trên tập test prediction = model.predict(X_test) print("Accuracy: ", accuracy(prediction, y_test)) # Plot confusion matrix cnf_matrix = confusion_matrix(y_test, prediction) plot_confusion_matrix(cnf_matrix, classes=class_names, title='Confusion matrix') ``` ![](https://i.imgur.com/bbQvOAW.png) ![](https://i.imgur.com/eDZiIK0.png) ```python= # Trường hợp 2: Huấn luyện mô hình đã áp dụng PCA (Principal component analysis) giảm chiều dữ liệu # Chia dữ liệu train và test X,y = bc.data, bc.target pca = PCA(n_components=4) # Dùng PCA giảm chiều dữ liệu từ 30 xuống chỉ còn 4 X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 126) X_train = pca.fit_transform(X_train) X_test = pca.transform(X_test) #Khởi tạo model và training model = LogisticRegression(lr=0.00001, n_iters = 1000) model.fit(X_train, y_train) # In Accuracy trên tập test prediction = model.predict(X_test) print("Accuracy: ", accuracy(prediction, y_test)) # Plot confusion matrix cnf_matrix = confusion_matrix(y_test, prediction) plot_confusion_matrix(cnf_matrix, classes=class_names, title='Confusion matrix') ``` ![](https://i.imgur.com/YkdDUTu.png) ![](https://i.imgur.com/wqclVYB.png) Sau khi thực hiện giảm chiều dữ liệu, độ chính xác tăng nhẹ, thời gian huấn luyện và dự đoán giảm => Toàn bộ code chi tiết : [code](https://colab.research.google.com/drive/1HySx8nBUCw6hq6Iqdrcf5PKdS65Gep7Y?authuser=1#scrollTo=aIcz8L3VT2wn) ## Tổng kết: Mô hình Logistic Regression là mô hình phân loại nhị phân. Mô hình sử dụng hàm sigmoid để đưa ra xác suất ví dụ như: 60% thí sinh này thi trượt, 90% hôm nay có mưa,… Mô hình Logistic Regression có nhiều ưu điểm như: * Mô hình dễ thực hiện và nghiên cứu cho người mới bắt đầu tiếp cận Máy học. * Có thể mở rộng cho nhiều lớp đầu ra. * Mô hình có nhiều ứng dụng thực tiễn. * Độ chính xác tốt cho nhiều tập dữ liệu đơn giản và nó hoạt động tốt khi bộ dữ liệu có thể tách rời theo tuyến tính. * Độ chính xác tốt cho nhiều tập dữ liệu đơn giản và nó hoạt động tốt khi bộ dữ liệu có thể tách rời theo tuyến tính. Bên cạnh các ưu điểm nó còn có một số nhược điểm: * Mô hình cần xây dựng các ranh giới tuyến tính. * Nếu số lượng quan sát ít hơn số lượng tính năng, Logistic Regression không nên được sử dụng, nếu không, nó có thể dẫn đến overfitting. * Các vấn đề phi tuyến tính không thể được giải quyết bằng logistic regression vì nó có bề mặt quyết định tuyến tính. ## Thành viên trong nhóm | STT | MSSV | Họ và Tên | |---|---|---| | 1 | 18520819| Chế Quang Huy | | 2 | 19521901 | Trần Gia Nghĩa |

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully