3
3
4
4
5
5
def weighted_matrix (
6
- point : np .array , training_data_x : np .array , bandwidth : float
7
- ) -> np .array :
6
+ point : np .ndarray , training_data_x : np .ndarray , bandwidth : float
7
+ ) -> np .ndarray :
8
8
"""
9
9
Calculate the weight for every point in the data set.
10
10
point --> the x value at which we want to make predictions
@@ -28,11 +28,11 @@ def weighted_matrix(
28
28
29
29
30
30
def local_weight (
31
- point : np .array ,
32
- training_data_x : np .array ,
33
- training_data_y : np .array ,
31
+ point : np .ndarray ,
32
+ training_data_x : np .ndarray ,
33
+ training_data_y : np .ndarray ,
34
34
bandwidth : float ,
35
- ) -> np .array :
35
+ ) -> np .ndarray :
36
36
"""
37
37
Calculate the local weights using the weight_matrix function on training data.
38
38
Return the weighted matrix.
@@ -54,8 +54,8 @@ def local_weight(
54
54
55
55
56
56
def local_weight_regression (
57
- training_data_x : np .array , training_data_y : np .array , bandwidth : float
58
- ) -> np .array :
57
+ training_data_x : np .ndarray , training_data_y : np .ndarray , bandwidth : float
58
+ ) -> np .ndarray :
59
59
"""
60
60
Calculate predictions for each data point on axis
61
61
>>> local_weight_regression(
@@ -78,7 +78,7 @@ def local_weight_regression(
78
78
79
79
def load_data (
80
80
dataset_name : str , cola_name : str , colb_name : str
81
- ) -> tuple [np .array , np .array , np .array , np .array ]:
81
+ ) -> tuple [np .ndarray , np .ndarray , np .ndarray , np .ndarray ]:
82
82
"""
83
83
Load data from seaborn and split it into x and y points
84
84
"""
@@ -99,7 +99,9 @@ def load_data(
99
99
return training_data_x , mcol_b , col_a , col_b
100
100
101
101
102
- def get_preds (training_data_x : np .array , mcol_b : np .array , tau : float ) -> np .array :
102
+ def get_preds (
103
+ training_data_x : np .ndarray , mcol_b : np .ndarray , tau : float
104
+ ) -> np .ndarray :
103
105
"""
104
106
Get predictions with minimum error for each training data
105
107
>>> get_preds(
@@ -114,10 +116,10 @@ def get_preds(training_data_x: np.array, mcol_b: np.array, tau: float) -> np.arr
114
116
115
117
116
118
def plot_preds (
117
- training_data_x : np .array ,
118
- predictions : np .array ,
119
- col_x : np .array ,
120
- col_y : np .array ,
119
+ training_data_x : np .ndarray ,
120
+ predictions : np .ndarray ,
121
+ col_x : np .ndarray ,
122
+ col_y : np .ndarray ,
121
123
cola_name : str ,
122
124
colb_name : str ,
123
125
) -> plt .plot :
0 commit comments