depd-v3 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Loan_Repay_Dataset.csv +201 -0
- package/astar.py +93 -0
- package/bfs.py +26 -0
- package/decisiontree.py +22 -0
- package/dfs.py +20 -0
- package/knn.py +28 -0
- package/lab.ipynb +43 -2
- package/package.json +1 -1
- package/pandas_lab.py +26 -0
- package/waterjug.py +26 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Age,Income,LoanAmount,CreditScore,ExistingLoans,Result
|
|
2
|
+
28,23278,438786,581,1,0
|
|
3
|
+
27,108696,438323,389,4,0
|
|
4
|
+
22,32280,164629,538,4,0
|
|
5
|
+
56,46062,425400,729,1,0
|
|
6
|
+
38,20851,447833,463,5,0
|
|
7
|
+
38,40379,162886,644,0,0
|
|
8
|
+
27,67052,494331,652,4,0
|
|
9
|
+
23,115647,290870,849,0,1
|
|
10
|
+
45,30328,339428,600,5,0
|
|
11
|
+
44,95674,150814,371,0,1
|
|
12
|
+
39,30458,498432,538,0,0
|
|
13
|
+
50,103320,487314,673,1,1
|
|
14
|
+
34,107841,189973,373,4,0
|
|
15
|
+
55,115568,178351,467,3,0
|
|
16
|
+
56,48785,408935,632,0,0
|
|
17
|
+
23,61347,260325,574,0,0
|
|
18
|
+
57,114098,214981,517,5,0
|
|
19
|
+
50,38726,188873,442,1,0
|
|
20
|
+
55,54438,441650,738,4,0
|
|
21
|
+
35,38131,317138,805,0,0
|
|
22
|
+
28,40033,378962,463,5,0
|
|
23
|
+
25,70432,250078,779,4,1
|
|
24
|
+
56,21504,406664,417,5,0
|
|
25
|
+
38,104012,228349,414,2,1
|
|
26
|
+
50,20425,428584,569,4,0
|
|
27
|
+
53,33947,377837,605,5,0
|
|
28
|
+
33,40032,246038,465,4,0
|
|
29
|
+
54,20074,364019,631,3,1
|
|
30
|
+
44,60306,175541,359,1,1
|
|
31
|
+
26,31226,433730,797,0,0
|
|
32
|
+
55,36483,117314,786,4,0
|
|
33
|
+
54,99507,271846,516,4,0
|
|
34
|
+
33,113447,213429,708,5,1
|
|
35
|
+
49,87839,286708,423,1,1
|
|
36
|
+
42,22757,358443,535,4,0
|
|
37
|
+
25,112778,380879,360,1,0
|
|
38
|
+
23,63309,87149,826,1,1
|
|
39
|
+
52,48080,332713,435,5,0
|
|
40
|
+
57,95525,297815,548,3,0
|
|
41
|
+
33,32363,100819,741,2,1
|
|
42
|
+
50,115561,78401,400,0,1
|
|
43
|
+
42,34322,180367,496,1,0
|
|
44
|
+
29,75296,146200,585,3,0
|
|
45
|
+
25,78082,473636,400,0,0
|
|
46
|
+
55,21934,98896,542,1,0
|
|
47
|
+
51,48016,260260,360,1,0
|
|
48
|
+
45,54760,461078,765,2,1
|
|
49
|
+
56,106752,426652,798,1,1
|
|
50
|
+
34,27665,353657,362,5,0
|
|
51
|
+
24,96569,299974,814,4,1
|
|
52
|
+
53,30500,496348,490,0,0
|
|
53
|
+
36,72923,112855,552,4,0
|
|
54
|
+
60,30745,269794,835,2,0
|
|
55
|
+
34,107782,425490,621,1,1
|
|
56
|
+
29,108039,388428,607,3,0
|
|
57
|
+
25,21220,290273,402,0,0
|
|
58
|
+
53,54760,119445,657,0,1
|
|
59
|
+
44,57353,132704,748,4,1
|
|
60
|
+
60,105717,327317,308,5,0
|
|
61
|
+
40,106951,104309,437,2,1
|
|
62
|
+
27,117310,340048,459,2,1
|
|
63
|
+
34,114058,229768,508,5,0
|
|
64
|
+
37,86244,306131,557,0,1
|
|
65
|
+
48,56265,73114,303,2,1
|
|
66
|
+
37,41178,438618,752,4,0
|
|
67
|
+
56,21267,108654,377,5,0
|
|
68
|
+
55,24722,487568,678,4,0
|
|
69
|
+
48,36704,71930,615,2,0
|
|
70
|
+
23,66898,160140,555,5,0
|
|
71
|
+
56,73264,375405,458,1,0
|
|
72
|
+
32,74040,62995,483,5,0
|
|
73
|
+
47,107806,435381,554,2,0
|
|
74
|
+
27,70140,70302,781,1,1
|
|
75
|
+
50,65830,210007,533,1,0
|
|
76
|
+
33,72227,222103,585,0,1
|
|
77
|
+
38,66025,386321,821,3,0
|
|
78
|
+
55,63404,64470,418,2,1
|
|
79
|
+
37,25014,106834,744,2,0
|
|
80
|
+
41,77199,367828,823,0,1
|
|
81
|
+
57,44914,183547,345,5,0
|
|
82
|
+
54,90575,410110,501,2,0
|
|
83
|
+
42,101678,214582,427,5,0
|
|
84
|
+
53,60538,399643,718,2,1
|
|
85
|
+
39,92667,116735,496,3,0
|
|
86
|
+
45,108777,442237,478,4,0
|
|
87
|
+
46,91819,487112,300,2,0
|
|
88
|
+
48,96019,368065,629,3,0
|
|
89
|
+
34,87000,298085,473,5,0
|
|
90
|
+
53,107012,381843,643,0,1
|
|
91
|
+
36,108184,212749,530,1,1
|
|
92
|
+
23,52092,299108,374,3,0
|
|
93
|
+
57,45485,426620,693,3,0
|
|
94
|
+
30,105990,410512,305,0,1
|
|
95
|
+
35,43053,471585,830,3,1
|
|
96
|
+
36,35906,289317,436,3,0
|
|
97
|
+
56,98047,216355,753,4,1
|
|
98
|
+
53,75933,485457,756,1,1
|
|
99
|
+
51,78991,185891,553,5,0
|
|
100
|
+
54,83517,378596,544,2,0
|
|
101
|
+
39,50735,192456,643,2,1
|
|
102
|
+
26,38136,129078,536,3,0
|
|
103
|
+
34,28418,267510,717,2,0
|
|
104
|
+
47,28161,158440,730,3,0
|
|
105
|
+
58,111163,60240,689,3,0
|
|
106
|
+
43,59139,445037,699,3,0
|
|
107
|
+
55,99069,165625,799,1,1
|
|
108
|
+
52,23804,253873,644,5,0
|
|
109
|
+
46,114919,136530,778,1,1
|
|
110
|
+
55,23534,256580,327,0,0
|
|
111
|
+
29,80515,145278,351,2,1
|
|
112
|
+
34,79598,221361,645,3,0
|
|
113
|
+
47,53065,487733,383,3,1
|
|
114
|
+
55,26826,233480,529,5,1
|
|
115
|
+
23,118858,66268,553,1,1
|
|
116
|
+
60,39973,175066,429,3,0
|
|
117
|
+
57,48569,293811,562,2,0
|
|
118
|
+
59,118032,426626,417,1,1
|
|
119
|
+
27,95849,63462,619,4,0
|
|
120
|
+
45,71990,424873,503,0,0
|
|
121
|
+
36,33356,415529,608,5,0
|
|
122
|
+
28,94177,460326,342,2,0
|
|
123
|
+
44,29038,315269,649,0,0
|
|
124
|
+
52,33833,277291,670,5,0
|
|
125
|
+
50,112708,130211,745,1,1
|
|
126
|
+
38,100728,473729,795,3,0
|
|
127
|
+
58,55179,218980,551,0,1
|
|
128
|
+
49,51963,443465,775,4,0
|
|
129
|
+
45,64092,65047,806,2,1
|
|
130
|
+
34,66507,468293,564,2,0
|
|
131
|
+
59,111905,194844,310,4,0
|
|
132
|
+
26,51635,427526,716,3,0
|
|
133
|
+
36,110519,299609,802,3,1
|
|
134
|
+
26,58566,166180,714,5,1
|
|
135
|
+
58,68368,298124,843,2,1
|
|
136
|
+
56,63357,234450,764,2,1
|
|
137
|
+
35,35814,428160,497,2,0
|
|
138
|
+
55,119901,411844,489,1,1
|
|
139
|
+
51,56241,429891,837,4,0
|
|
140
|
+
27,45443,205318,532,2,0
|
|
141
|
+
21,112801,330040,429,2,0
|
|
142
|
+
24,92529,203163,429,5,0
|
|
143
|
+
52,33446,56430,591,3,0
|
|
144
|
+
42,44164,76936,558,3,0
|
|
145
|
+
25,72521,307816,375,4,0
|
|
146
|
+
24,39887,128222,611,0,0
|
|
147
|
+
28,93147,450788,726,4,0
|
|
148
|
+
60,49581,456686,835,3,0
|
|
149
|
+
49,58974,358556,739,2,1
|
|
150
|
+
24,99905,438019,401,1,0
|
|
151
|
+
37,106563,92565,460,1,1
|
|
152
|
+
25,40517,51402,718,3,0
|
|
153
|
+
51,58175,67112,537,2,1
|
|
154
|
+
50,29329,410387,539,2,0
|
|
155
|
+
58,106662,471478,502,3,0
|
|
156
|
+
35,104886,128113,572,1,0
|
|
157
|
+
31,60319,361974,595,3,0
|
|
158
|
+
40,111715,261030,578,4,0
|
|
159
|
+
49,30543,363543,340,3,0
|
|
160
|
+
59,52816,63560,393,1,1
|
|
161
|
+
57,96955,60876,575,4,1
|
|
162
|
+
32,81669,322086,752,2,1
|
|
163
|
+
58,77132,382810,803,0,1
|
|
164
|
+
47,63687,218326,407,1,1
|
|
165
|
+
52,57777,397384,710,4,1
|
|
166
|
+
26,61224,182329,631,0,1
|
|
167
|
+
46,87449,482499,301,5,0
|
|
168
|
+
50,74165,78418,492,4,0
|
|
169
|
+
52,101973,281756,352,1,1
|
|
170
|
+
29,57752,279699,796,0,0
|
|
171
|
+
59,51365,422130,462,2,0
|
|
172
|
+
56,73476,98868,530,0,1
|
|
173
|
+
28,104896,486282,457,3,0
|
|
174
|
+
39,86698,419838,579,3,0
|
|
175
|
+
51,51946,289487,448,3,0
|
|
176
|
+
59,86616,441272,439,0,0
|
|
177
|
+
47,64548,462990,819,2,1
|
|
178
|
+
39,115164,206529,801,1,1
|
|
179
|
+
51,65236,224294,686,3,1
|
|
180
|
+
33,111422,175202,692,1,1
|
|
181
|
+
47,25720,216816,784,5,0
|
|
182
|
+
45,70604,397964,455,3,0
|
|
183
|
+
29,85836,359424,639,0,0
|
|
184
|
+
49,33069,325749,767,0,0
|
|
185
|
+
47,105823,130929,376,3,0
|
|
186
|
+
37,64375,376767,707,5,0
|
|
187
|
+
42,108389,329771,689,2,1
|
|
188
|
+
52,90912,68821,370,1,1
|
|
189
|
+
39,49817,441520,392,3,0
|
|
190
|
+
27,78153,137223,606,0,0
|
|
191
|
+
24,58452,237938,683,3,0
|
|
192
|
+
54,74008,346709,484,1,0
|
|
193
|
+
60,70140,374906,546,3,0
|
|
194
|
+
30,50433,291775,560,3,0
|
|
195
|
+
21,80981,200801,461,0,1
|
|
196
|
+
43,97014,206842,734,5,1
|
|
197
|
+
40,46111,251690,794,0,0
|
|
198
|
+
57,67049,351366,602,5,0
|
|
199
|
+
46,55976,54245,350,4,0
|
|
200
|
+
39,50162,368276,660,1,1
|
|
201
|
+
60,52850,405343,440,5,0
|
package/astar.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
def aStarAlgo(start_node, stop_node):
|
|
2
|
+
open_set = set(start_node)
|
|
3
|
+
closed_set = set()
|
|
4
|
+
g = {}
|
|
5
|
+
parents = {}
|
|
6
|
+
g[start_node] = 0
|
|
7
|
+
|
|
8
|
+
parents[start_node] = start_node
|
|
9
|
+
|
|
10
|
+
while len(open_set) > 0:
|
|
11
|
+
n = None
|
|
12
|
+
|
|
13
|
+
for v in open_set:
|
|
14
|
+
if n == None or g[v] + heuristic(v) < g[n] + heuristic(n):
|
|
15
|
+
n = v
|
|
16
|
+
|
|
17
|
+
if n == stop_node or Graph_nodes[n] == None:
|
|
18
|
+
pass
|
|
19
|
+
else:
|
|
20
|
+
for (m, weight) in get_neighbors(n):
|
|
21
|
+
if m not in open_set and m not in closed_set:
|
|
22
|
+
open_set.add(m)
|
|
23
|
+
parents[m] = n
|
|
24
|
+
g[m] = g[n] + weight
|
|
25
|
+
|
|
26
|
+
else:
|
|
27
|
+
if g[m] > g[n] + weight:
|
|
28
|
+
g[m] = g[n] + weight
|
|
29
|
+
|
|
30
|
+
parents[m] = n
|
|
31
|
+
|
|
32
|
+
if m in closed_set:
|
|
33
|
+
closed_set.remove(m)
|
|
34
|
+
open_set.add(m)
|
|
35
|
+
|
|
36
|
+
if n == None:
|
|
37
|
+
print('Path does not exist!')
|
|
38
|
+
return None
|
|
39
|
+
|
|
40
|
+
if n == stop_node:
|
|
41
|
+
path = []
|
|
42
|
+
|
|
43
|
+
while parents[n] != n:
|
|
44
|
+
path.append(n)
|
|
45
|
+
n = parents[n]
|
|
46
|
+
|
|
47
|
+
path.append(start_node)
|
|
48
|
+
path.reverse()
|
|
49
|
+
|
|
50
|
+
print('Path found: {}'.format(path))
|
|
51
|
+
return path
|
|
52
|
+
|
|
53
|
+
open_set.remove(n)
|
|
54
|
+
closed_set.add(n)
|
|
55
|
+
|
|
56
|
+
print('Path does not exist!')
|
|
57
|
+
return None
|
|
58
|
+
|
|
59
|
+
def get_neighbors(v):
|
|
60
|
+
if v in Graph_nodes:
|
|
61
|
+
return Graph_nodes[v]
|
|
62
|
+
else:
|
|
63
|
+
return None
|
|
64
|
+
|
|
65
|
+
def heuristic(n):
|
|
66
|
+
H_dist = {
|
|
67
|
+
'A': 11,
|
|
68
|
+
'B': 6,
|
|
69
|
+
'C': 5,
|
|
70
|
+
'D': 7,
|
|
71
|
+
'E': 3,
|
|
72
|
+
'F': 6,
|
|
73
|
+
'G': 5,
|
|
74
|
+
'H': 3,
|
|
75
|
+
'I': 1,
|
|
76
|
+
'J': 0
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return H_dist[n]
|
|
80
|
+
|
|
81
|
+
Graph_nodes = {
|
|
82
|
+
'A': [('B', 6), ('F', 3)],
|
|
83
|
+
'B': [('A', 6), ('C', 3), ('D', 2)],
|
|
84
|
+
'C': [('B', 3), ('D', 1), ('E', 5)],
|
|
85
|
+
'D': [('B', 2), ('C', 1), ('E', 8)],
|
|
86
|
+
'E': [('C', 5), ('D', 8), ('I', 5), ('J', 5)],
|
|
87
|
+
'F': [('A', 3), ('G', 1), ('H', 7)],
|
|
88
|
+
'G': [('F', 1), ('I', 3)],
|
|
89
|
+
'H': [('F', 7), ('I', 2)],
|
|
90
|
+
'I': [('E', 5), ('G', 3), ('H', 2), ('J', 3)],
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
aStarAlgo('A', 'J')
|
package/bfs.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
graph = {
|
|
2
|
+
'A': ['B', 'C'],
|
|
3
|
+
'B': ['D', 'E'],
|
|
4
|
+
'C': ['F'],
|
|
5
|
+
'D': [],
|
|
6
|
+
'E': ['F'],
|
|
7
|
+
'F': []
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
visited = []
|
|
11
|
+
queue = []
|
|
12
|
+
|
|
13
|
+
def bfs(graph, node):
|
|
14
|
+
visited.append(node)
|
|
15
|
+
queue.append(node)
|
|
16
|
+
|
|
17
|
+
while queue:
|
|
18
|
+
s = queue.pop(0)
|
|
19
|
+
print(s, end=" ")
|
|
20
|
+
|
|
21
|
+
for neighbour in graph[s]:
|
|
22
|
+
if neighbour not in visited:
|
|
23
|
+
visited.append(neighbour)
|
|
24
|
+
queue.append(neighbour)
|
|
25
|
+
|
|
26
|
+
bfs(graph, 'A')
|
package/decisiontree.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
from sklearn.model_selection import train_test_split
|
|
2
|
+
from sklearn.tree import DecisionTreeClassifier
|
|
3
|
+
from sklearn.metrics import accuracy_score
|
|
4
|
+
|
|
5
|
+
import pandas as pd
|
|
6
|
+
|
|
7
|
+
sample_dataframe_df = pd.read_csv('Loan_Repay_Dataset.csv')
|
|
8
|
+
|
|
9
|
+
x = sample_dataframe_df.drop(['Result'], axis=1)
|
|
10
|
+
y = sample_dataframe_df['Result']
|
|
11
|
+
|
|
12
|
+
train_x, test_x, train_y, test_y = train_test_split(
|
|
13
|
+
x, y, test_size=0.2, random_state=100
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
estimated = DecisionTreeClassifier().fit(train_x, train_y)
|
|
17
|
+
|
|
18
|
+
predict_y = estimated.predict(test_x)
|
|
19
|
+
|
|
20
|
+
print(predict_y)
|
|
21
|
+
|
|
22
|
+
print(accuracy_score(test_y, predict_y))
|
package/dfs.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
graph = {
|
|
2
|
+
'A': ['B', 'C'],
|
|
3
|
+
'B': ['D', 'E'],
|
|
4
|
+
'C': ['F'],
|
|
5
|
+
'D': [],
|
|
6
|
+
'E': ['F'],
|
|
7
|
+
'F': []
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
visited = set()
|
|
11
|
+
|
|
12
|
+
def dfs(node):
|
|
13
|
+
if node not in visited:
|
|
14
|
+
print(node, end=" ")
|
|
15
|
+
visited.add(node)
|
|
16
|
+
|
|
17
|
+
for neighbour in graph[node]:
|
|
18
|
+
dfs(neighbour)
|
|
19
|
+
|
|
20
|
+
dfs('A')
|
package/knn.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#k nearest
|
|
2
|
+
from sklearn.neighbors import KNeighborsClassifier
|
|
3
|
+
from sklearn.model_selection import train_test_split
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
6
|
+
sample_dataframe_df = pd.read_csv('Iris.csv')
|
|
7
|
+
|
|
8
|
+
sample_dataframe_df.head(5)
|
|
9
|
+
sample_dataframe_df['Species'].value_counts()
|
|
10
|
+
|
|
11
|
+
x = sample_dataframe_df.drop(['Id', 'Species'], axis=1)
|
|
12
|
+
y = sample_dataframe_df['Species']
|
|
13
|
+
|
|
14
|
+
x.head(5)
|
|
15
|
+
y.head(5)
|
|
16
|
+
|
|
17
|
+
train_x, test_x, train_y, test_y = train_test_split(
|
|
18
|
+
x,
|
|
19
|
+
y,
|
|
20
|
+
train_size=0.8,
|
|
21
|
+
random_state=80
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
knn = KNeighborsClassifier(n_neighbors=5)
|
|
25
|
+
|
|
26
|
+
knn.fit(train_x, train_y)
|
|
27
|
+
|
|
28
|
+
knn.score(test_x, test_y)
|
package/lab.ipynb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"cells": [
|
|
3
3
|
{
|
|
4
4
|
"cell_type": "code",
|
|
5
|
-
"execution_count":
|
|
5
|
+
"execution_count": null,
|
|
6
6
|
"id": "56190fb8",
|
|
7
7
|
"metadata": {},
|
|
8
8
|
"outputs": [
|
|
@@ -349,6 +349,47 @@
|
|
|
349
349
|
"knn.score(test_x, test_y)"
|
|
350
350
|
]
|
|
351
351
|
},
|
|
352
|
+
{
|
|
353
|
+
"cell_type": "code",
|
|
354
|
+
"execution_count": 9,
|
|
355
|
+
"id": "9a277da3",
|
|
356
|
+
"metadata": {},
|
|
357
|
+
"outputs": [
|
|
358
|
+
{
|
|
359
|
+
"name": "stdout",
|
|
360
|
+
"output_type": "stream",
|
|
361
|
+
"text": [
|
|
362
|
+
"[0 0 1 0 0 1 1 1 0 0 0 1 0 1 1 0 1 0 0 0 1 1 0 0 0 0 1 1 1 1 0 0 1 1 1 1 1\n",
|
|
363
|
+
" 0 0 0]\n",
|
|
364
|
+
"0.75\n"
|
|
365
|
+
]
|
|
366
|
+
}
|
|
367
|
+
],
|
|
368
|
+
"source": [
|
|
369
|
+
"from sklearn.model_selection import train_test_split\n",
|
|
370
|
+
"from sklearn.tree import DecisionTreeClassifier\n",
|
|
371
|
+
"from sklearn.metrics import accuracy_score\n",
|
|
372
|
+
"\n",
|
|
373
|
+
"import pandas as pd\n",
|
|
374
|
+
"\n",
|
|
375
|
+
"sample_dataframe_df = pd.read_csv('Loan_Repay_Dataset.csv')\n",
|
|
376
|
+
"\n",
|
|
377
|
+
"x = sample_dataframe_df.drop(['Result'], axis=1)\n",
|
|
378
|
+
"y = sample_dataframe_df['Result']\n",
|
|
379
|
+
"\n",
|
|
380
|
+
"train_x, test_x, train_y, test_y = train_test_split(\n",
|
|
381
|
+
" x, y, test_size=0.2, random_state=100\n",
|
|
382
|
+
")\n",
|
|
383
|
+
"\n",
|
|
384
|
+
"estimated = DecisionTreeClassifier().fit(train_x, train_y)\n",
|
|
385
|
+
"\n",
|
|
386
|
+
"predict_y = estimated.predict(test_x)\n",
|
|
387
|
+
"\n",
|
|
388
|
+
"print(predict_y)\n",
|
|
389
|
+
"\n",
|
|
390
|
+
"print(accuracy_score(test_y, predict_y))"
|
|
391
|
+
]
|
|
392
|
+
},
|
|
352
393
|
{
|
|
353
394
|
"cell_type": "code",
|
|
354
395
|
"execution_count": null,
|
|
@@ -545,7 +586,7 @@
|
|
|
545
586
|
"name": "python",
|
|
546
587
|
"nbconvert_exporter": "python",
|
|
547
588
|
"pygments_lexer": "ipython3",
|
|
548
|
-
"version": "3.14.
|
|
589
|
+
"version": "3.14.6"
|
|
549
590
|
}
|
|
550
591
|
},
|
|
551
592
|
"nbformat": 4,
|
package/package.json
CHANGED
package/pandas_lab.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
|
|
3
|
+
sample_dataframe_df = pd.read_csv('Iris.csv')
|
|
4
|
+
|
|
5
|
+
type(sample_dataframe_df)
|
|
6
|
+
|
|
7
|
+
sample_dataframe_df.head(5)
|
|
8
|
+
|
|
9
|
+
list(sample_dataframe_df.columns)
|
|
10
|
+
|
|
11
|
+
sample_dataframe_df.head(5).transpose()
|
|
12
|
+
|
|
13
|
+
sample_dataframe_df.shape
|
|
14
|
+
|
|
15
|
+
sample_dataframe_df[0:10]
|
|
16
|
+
|
|
17
|
+
sample_dataframe_df[-5:]
|
|
18
|
+
|
|
19
|
+
sample_dataframe_df['SepalLengthCm']
|
|
20
|
+
|
|
21
|
+
sample_dataframe_df.SepalLengthCm.value_count
|
|
22
|
+
|
|
23
|
+
sample_dataframe_df[sample_dataframe_df['PetalLengthCm']>6]
|
|
24
|
+
|
|
25
|
+
sample_dataframe_df.drop('Si.no', inplace=True, axis=1)
|
|
26
|
+
list(sample_dataframe_df.columns)
|
package/waterjug.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#water jug bfs - use pop() for dfs
|
|
2
|
+
from collections import deque
|
|
3
|
+
|
|
4
|
+
def bfs(a, b, target):
|
|
5
|
+
q = deque([(0, 0)])
|
|
6
|
+
visited = set()
|
|
7
|
+
|
|
8
|
+
while q:
|
|
9
|
+
x, y = q.popleft()
|
|
10
|
+
if (x, y) in visited:
|
|
11
|
+
continue
|
|
12
|
+
|
|
13
|
+
visited.add((x, y))
|
|
14
|
+
print(x, y)
|
|
15
|
+
|
|
16
|
+
if x == target or y == target:
|
|
17
|
+
print("target reached")
|
|
18
|
+
break
|
|
19
|
+
|
|
20
|
+
q.extend([
|
|
21
|
+
(a, y), (x, b), (0, y), (x, 0),
|
|
22
|
+
(x - min(x, b - y), y + min(x, b - y)),
|
|
23
|
+
(x + min(y, a - x), y - min(y, a - x))
|
|
24
|
+
])
|
|
25
|
+
|
|
26
|
+
bfs(4, 3, 2)
|