from sklearn.ensemble import RandomForestClassifier from sklearn import tree X = [[ 1, 2, 3], # 2 samples, 3 features [11, 12, 13]] y = [0, 1] # classes of each sample clf = RandomForestClassifier(random_state=0) clf.fit(X, y) # X is training data without ctarget attribute # make some predictions clf.predict(X) # array([0, 1]) clf.predict([[4, 5, 6], [14, 15, 16]]) # array([0, 1]) clf.predict([[4, 5, 6], [14, 15, 16], [ 0,1,2],[20,22,24],[0,10,20]]) # array([0, 1, 0, 1, 1]) # Use same data, but use string names for the class attribute. This works. y = ["little", "big"] clf.fit(X, y) clf.predict([[4, 5, 6], [14, 15, 16], [ 0,1,2],[20,22,24],[0,10,20]]) # array(['little', 'big', 'little', 'big', 'big'], dtype='