What do you want to save?
Add Code snippet
New code examples
-
Python 2022-02-25 11:40:03
compute confusion matrix using python
import numpy as np currentDataClass = [1, 3, 3, 2, 5, 5, 3, 2, 1, 4, 3, 2, 1, 1, 2] predictedClass = [1, 2, 3, 4, 2, 3, 3, 2, 1, 2, 3, 1, 5, 1, 1] def comp_confmat(actual, predicted): classes = np.unique(actual) # extract the different classes ... Add solution -
Python 2021-11-07 13:47:15
sum axis in python
import numpy as np array1 = np.array( [[1, 2], [3, 4], [5, 6]]) total_0_axis = np.sum(array1, axis=0) print(f'Sum of elements at 0-axis is {total_0_axis}') total_1_axis = np.sum(array1, axis=1) print(f'Sum of elements at 1-axis is {total_... Add solution -
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 -
Other 2021-10-13 14:41:07
countvectorizer in nlp
from sklearn.datasets import fetch_20newsgroupsfrom sklearn.feature_extraction.text import CountVectorizerimport numpy as np# Create our vectorizervectorizer = CountVectorizer()# Let's fetch all the possible text datanewsgroups_data = fetch_20newsgroups()... Add solution -
Python 2021-10-03 02:43:03
sum of a numpy array
>>> np.sum([0.5, 1.5]) 2.0 >>> np.sum([0.5, 0.7, 0.2, 1.5], dtype=np.int32) 1 >>> np.sum([[0, 1], [0, 5]]) 6 >>> np.sum([[0, 1], [0, 5]], axis=0) array([0, 6]) >>> np.sum([[0, 1], [0, 5]], axis=1) array([1, 5])... Add solution
Best helpers
Cynthia
+5
Eric Thomsen
+5
Eve noonan
+5
Martinako
+5
Numeri
+5
Magd
+5
John Weisz
+5
Rocky DeHart
+5
Tammy Lin
+5
Flyeogh
+5
SunnyHills
+5
Ishan Yadav
+5
Aown Ali
+5
Terry3497
+5
Xkcvk2511
+5
Jean Luis
+5