What do you want to save?
Add Code snippet
New code examples
-
Python 2022-03-12 07:00:02
how to find the labels of the confusion matrix in python
""" In order to find the labels just use the Counter function to count the records from y_test and then check row-wise sum of the confusion matrix. Then apply the labels to the corresponding rows using the inbuilt seaborn plot as shown b... Add solution -
Python 2022-02-25 20:05:04
kitty's calculations on a tree hackerrank solution
from collections import Counter, defaultdict MOD = 10**9 + 7 def read_row(): return (int(x) for x in input().split()) def mul(x, y): return (x * y) % MOD def add(*args): return sum(args) % MOD def sub(x, y): return (x - y) % MOD n, q... Add solution -
Python 2022-01-26 04:37:01
dividing counter object in python
from collections import Counter mylist = ['red','green','blue','red','orange','red','green'] counts = Counter(mylist) for item, count in counts.items(): counts[item] /= 14 print(counts) # Counter({'red': 0.21428571428571427, 'green': 0.1428571428571... Add solution -
Python 2022-01-22 13:21:24
collections.counter in python
>>> from collections import Counter >>> >>> myList = [1,1,2,3,4,5,3,2,3,4,2,1,2,3] >>> print Counter(myList) Counter({2: 4, 3: 4, 1: 3, 4: 2, 5: 1}) >>> >>> print Counter(myList).items() [(1, 3), (2, ... Add solution -
Python 2022-01-22 00:15:19
Tips & Tricks in python
from collections import Counter def is_anagram(str1, str2): return Counter(str1) == Counter(str2) # or without having to import anything def is_anagram(str1, str2): return sort... Add solution -
Python 2021-11-12 11:54:24
my_mode() python
>>> from collections import Counter >>> def my_mode(sample): ... c = Counter(sample) ... return [k for k, v in c.items() if v == c.most_common(1)[0][1]] ... >>> my_mode(["male", "male", "female... Add solution
Best helpers
Cynthia
+5
Eve noonan
+5
Martinako
+5
Numeri
+5
John Weisz
+5
Rocky DeHart
+5
Tammy Lin
+5
SunnyHills
+5
Ishan Yadav
+5
Aown Ali
+5
Terry3497
+5
Xkcvk2511
+5
Jean Luis
+5