- Machine Learning with Swift
- Alexander Sosnovshchenko
- 189字
- 2021-06-24 18:54:57
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.
- 零點(diǎn)起飛學(xué)Xilinx FPG
- 龍芯應(yīng)用開(kāi)發(fā)標(biāo)準(zhǔn)教程
- Android NDK Game Development Cookbook
- Creating Dynamic UI with Android Fragments
- 電腦組裝與維修從入門(mén)到精通(第2版)
- 基于Proteus和Keil的C51程序設(shè)計(jì)項(xiàng)目教程(第2版):理論、仿真、實(shí)踐相融合
- 深入淺出SSD:固態(tài)存儲(chǔ)核心技術(shù)、原理與實(shí)戰(zhàn)
- 嵌入式技術(shù)基礎(chǔ)與實(shí)踐(第5版)
- 3ds Max Speed Modeling for 3D Artists
- Mastering Manga Studio 5
- 超大流量分布式系統(tǒng)架構(gòu)解決方案:人人都是架構(gòu)師2.0
- Neural Network Programming with Java(Second Edition)
- Instant Website Touch Integration
- 從企業(yè)級(jí)開(kāi)發(fā)到云原生微服務(wù):Spring Boot實(shí)戰(zhàn)
- Learning Microsoft Cognitive Services