Skip to content

Commit 335ed0a

Browse files
committed
update file header.
1 parent 00c3e1c commit 335ed0a

13 files changed

+71
-45
lines changed

src/adaboost.py

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
2-
# @Date : 2020/5/27
3-
# @Author: Luokun
4-
# @Email : olooook@outlook.com
3+
# @File : adaboost.py
4+
# @Data : 2020/5/27
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
57

68
import numpy as np
79
from matplotlib import pyplot as plt
810

911

1012
class AdaBoost:
1113

12-
def __init__(self, n_estimators: int, lr=1e-2, eps=1e-5):
14+
def __init__(self, n_estimators: int, lr: float = 1e-2, eps: float = 1e-5):
1315
"""
1416
Args:
1517
n_estimators (int): 弱分类器个数.
@@ -53,17 +55,19 @@ def __call__(self, X: np.ndarray) -> np.ndarray:
5355

5456
class WeakEstimator: # 弱分类器, 一阶决策树
5557

56-
def __init__(self, lr: float):
57-
self.lr, self.feature, self.threshold, self.sign = lr, None, None, None # 划分特征、划分阈值,符号{-1,1}
58+
def __init__(self, lr: float = 1e-3):
59+
# 学习率、符号{-1,1}、划分特征、划分阈值
60+
self.lr, self.sign, self.feature, self.threshold, = lr, 1, None, None
5861

5962
def fit(self, X: np.ndarray, y: np.ndarray, weights: np.ndarray):
60-
min_error = float("inf") # 最小带权误差
63+
min_error = np.inf # 最小带权误差
6164
for feature, x in enumerate(X.T):
6265
for threshold in np.arange(np.min(x) - self.lr, np.max(x) + self.lr, self.lr):
6366
# 取分类错误的样本权重求和
6467
pos_error = np.sum(weights[np.where(x > threshold, 1, -1) != y])
6568
if pos_error < min_error:
6669
min_error, self.feature, self.threshold, self.sign = pos_error, feature, threshold, 1
70+
6771
neg_error = 1 - pos_error
6872
if neg_error < min_error:
6973
min_error, self.feature, self.threshold, self.sign = neg_error, feature, threshold, -1

src/decision_tree.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
2-
# @Date : 2020/5/23
3-
# @Author: Luokun
4-
# @Email : olooook@outlook.com
3+
# @File : decision_tree.py
4+
# @Data : 2020/5/23
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
57

68
import numpy as np
79

src/em.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
2-
# @Date : 2020/5/27
3-
# @Author: Luokun
4-
# @Email : olooook@outlook.com
3+
# @File : em.py
4+
# @Data : 2020/5/27
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
57

68
import numpy as np
79

src/gmm.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
2-
# @Date : 2020/5/31
3-
# @Author: Luokun
4-
# @Email : olooook@outlook.com
3+
# @File : gmm.py
4+
# @Data : 2020/5/31
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
57

68
import random
79

src/kmeans.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
2-
# @Date : 2020/5/21
3-
# @Author: Luokun
4-
# @Email : olooook@outlook.com
3+
# @File : kmeans.py
4+
# @Data : 2020/5/21
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
57

68
import random
79

src/knn.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
2-
# @Date : 2020/5/20
3-
# @Author: Luokun
4-
# @Email : olooook@outlook.com
3+
# @File : knn.py
4+
# @Data : 2020/5/20
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
57

68
import numpy as np
79
from matplotlib import pyplot as plt

src/lda.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
2-
# @Date : 2020/5/31
3-
# @Author: Luokun
4-
# @Email : olooook@outlook.com
3+
# @File : lda.py
4+
# @Data : 2020/5/31
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
57

68
import numpy as np
79
from matplotlib import pyplot as plt

src/logistic_regression.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
2-
# @Date : 2020/5/21
3-
# @Author: Luokun
4-
# @Email : olooook@outlook.com
3+
# @File : logistic_regression.py
4+
# @Data : 2020/5/21
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
57

68
import numpy as np
79
from matplotlib import pyplot as plt

src/naive_bayes.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
2-
# @Date : 2020/5/22
3-
# @Author: Luokun
4-
# @Email : olooook@outlook.com
3+
# @File : naive_bayes.py
4+
# @Data : 2020/5/22
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
57

68
import numpy as np
79

src/pca.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
2-
# @Date : 2020/5/20
3-
# @Author: Luokun
4-
# @Email : olooook@outlook.com
3+
# @File : pca.py
4+
# @Data : 2020/5/20
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
57

68
import numpy as np
79
from matplotlib import pyplot as plt

src/perceptron.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
2-
# @Date : 2020/5/20
3-
# @Author: Luokun
4-
# @Email : olooook@outlook.com
3+
# @File : perceptron.py
4+
# @Data : 2020/5/20
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
57

68
import numpy as np
79
from matplotlib import pyplot as plt

src/svm.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
#!/usr/bin/env python3
12
# -*- coding: utf-8 -*-
2-
# @Date : 2020/5/23
3-
# @Author: Luokun
4-
# @Email : olooook@outlook.com
3+
# @File : svm.py
4+
# @Data : 2020/5/23
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
57

68
import numpy as np
79
from matplotlib import pyplot as plt

src/utils.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/usr/bin/python3
1+
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
3-
# @File : utils.py
4-
# @Time : 2022/05/18 15:11:16
5-
# @Author: Kun Luo
6-
# @Email : olooook@outlook.com
3+
# @File : utils.py
4+
# @Data : 2022/05/18
5+
# @Author : Luo Kun
6+
# @Contact: luokun485@gmail.com
77

88
from typing import List, Optional
99

0 commit comments

Comments
 (0)