@@ -17,20 +17,26 @@ def collect_dataset():
17
17
The dataset contains ADR vs Rating of a Player
18
18
:return : dataset obtained from the link, as matrix
19
19
"""
20
- response = requests .get (
20
+ try : response = requests .get (
21
21
"https://raw.githubusercontent.com/yashLadha/The_Math_of_Intelligence/"
22
22
"master/Week1/ADRvsRating.csv" ,
23
23
timeout = 10 ,
24
- )
25
- lines = response .text .splitlines ()
26
- data = []
27
- for item in lines :
28
- item = item .split ("," )
29
- data .append (item )
30
- data .pop (0 ) # This is for removing the labels from the list
31
- dataset = np .matrix (data )
32
- return dataset
33
-
24
+ )
25
+ lines = response .text .splitlines ()
26
+ data = []
27
+ for item in lines :
28
+ item = item .split ("," )
29
+ data .append (item )
30
+ data .pop (0 ) # This is for removing the labels from the list
31
+ dataset = np .matrix (data )
32
+ return dataset
33
+
34
+ except requests .exceptions .RequestException as e :
35
+ print (f"Error fetching the dataset: { e } " )
36
+ return None
37
+ except Exception as e :
38
+ print (f"Unexpected error: { e } " )
39
+ return None
34
40
35
41
def run_steep_gradient_descent (data_x , data_y , len_data , alpha , theta ):
36
42
"""Run steep gradient descent and updates the Feature vector accordingly_
@@ -112,6 +118,10 @@ def main():
112
118
for i in range (len_result ):
113
119
print (f"{ theta [0 , i ]:.5f} " )
114
120
115
-
121
+ import doctest
116
122
if __name__ == "__main__" :
117
123
main ()
124
+ doctest .testmod ()
125
+
126
+
127
+
0 commit comments