官术网_书友最值得收藏!

Making predictions

We use the predict function to get outcome labels for two samples. The first one is light-black, fluffy creature, 24 meters long. The second one is purple polka dot, non-fluffy, and 34 meters long. If you already don't remember the meaning of each feature, consult the feature_names variable:

In []: 
samples = [[24,1,0,1,0,0], [34,0,0,0,1,0]] 
tree_model.predict(samples) 
Out[]: 
array([u'platyhog', u'rabbosaurus'], dtype=object) 

Our model predicted platyhog for the first sample, and rabbosaurus for the second one. A decision tree can also provide probabilistic output (how sure it is about the prediction):

In []: 
tree_model.predict_proba(samples) 
Out[]: 
array([[ 1.,  0.], 
       [ 0.,  1.]]) 

The array contains two nested arrays, one for every prediction. Elements in the nested arrays are probabilities of the sample belonging to the corresponding class. This means that our model is 100% sure that the first sample belongs to the first class, and 100% sure that the second sample belongs to the second class.

But how sure can we be about these predictions? We have a whole set of different tools to evaluate the model's accuracy, and the simplest one is the built-in scoring functions.

主站蜘蛛池模板: 泽普县| 宽城| 承德市| 辽阳市| 阜新市| 余庆县| 惠州市| 盘山县| 宜阳县| 永昌县| 三明市| 敖汉旗| 荆州市| 星座| 民县| 榕江县| 饶河县| 驻马店市| 博客| 蛟河市| 台山市| 房山区| 大港区| 石楼县| 灌云县| 南城县| 呈贡县| 揭东县| 乌什县| 洛川县| 同仁县| 宜川县| 濉溪县| 曲沃县| 九龙城区| 庄浪县| 区。| 黄平县| 樟树市| 福海县| 南靖县|