What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-06 03:21:12
random forest from scratch python github
import numpy as np from collections import Counter #implement decision tree def entropy(d): c = np.bincount(d) c = c[c != 0] prop = c/len(d) E = - prop*np.log2(prop) return np.sum(E) class Node: def __init__(self, beast_split_fea... Add solution -
Python 2021-11-03 16:35:15
collections counter
>>> 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 -
Other 2021-11-03 02:35:11
Python - Odd Occurences in Array
# you can write to stdout for debugging purposes, e.g. # print("this is a debug message") from collections import Counter #Given a number, return true if its even or false if its odd def evenOdd(N): if((N % 2) == 0): return True ... Add solution -
Python 2021-10-27 21:51:13
how to find palingrams python
""" Program: Python program to find anagrams in a list of strings """ from collections import Counter def get_anagrams(input_string_list, test_string): print("*******************") print("input_str... Add solution -
Python 2021-10-22 17:53:09
python Sorted Word frequency count
>>> # Tally occurrences of words in a list >>> from collections import Counter >>> cnt = Counter() >>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']: ... cnt[word] += 1 >>> cnt Counter({'blue'... Add solution -
Python 2021-10-22 13:54:04
how to get the most common number in python
from collections import Counter a = [1936, 2401, 2916, 4761, 9216, 9216, 9604, 9801] c = Counter(a) print(c.most_common(1)) # the one most common element... 2 would mean the 2 most common [(9216, 2)] # a set containing the element, and it's count in 'a' Add solution -
Python 2021-10-04 02:21:04
most frequent word in a list python
words = [ 'red', 'green', 'black', 'pink', 'black', 'white', 'black', 'eyes', 'white', 'black', 'orange', 'pink', 'pink', 'red', 'red', 'white', 'orange', 'white', "black", 'pink', 'green', 'green', 'pink', 'green', 'pink', 'white', ... Add solution