- Machine Learning with Scala Quick Start Guide
- Md. Rezaul Karim
- 108字
- 2021-06-24 14:32:03
Preparing training data and training a classifier
Next, we separate the training set and test sets. Let's say that 80% of the training set will be used for the training and the other 20% will be used to evaluate the trained model:
val splits = numericDF.randomSplit(Array(0.8, 0.2))
val trainDF = splits(0)
val testDF = splits(1)
Instantiate a decision tree classifier by specifying impurity, max bins, and the max depth of the trees. Additionally, we set the label and feature columns:
val dt = new DecisionTreeClassifier()
.setImpurity("gini")
.setMaxBins(10)
.setMaxDepth(30)
.setLabelCol("label")
.setFeaturesCol("features")
Now that the data and the classifier are ready, we can perform the training:
val dtModel = dt.fit(trainDF)
推薦閱讀
- Mastering Mesos
- AutoCAD繪圖實(shí)用速查通典
- Ansible Quick Start Guide
- Expert AWS Development
- VMware Performance and Capacity Management(Second Edition)
- 基于ARM 32位高速嵌入式微控制器
- Spark大數(shù)據(jù)技術(shù)與應(yīng)用
- 網(wǎng)絡(luò)安全管理實(shí)踐
- Mastering ServiceNow Scripting
- 氣動(dòng)系統(tǒng)裝調(diào)與PLC控制
- 啊哈C!思考快你一步
- 網(wǎng)絡(luò)存儲(chǔ)·數(shù)據(jù)備份與還原
- 貫通開(kāi)源Web圖形與報(bào)表技術(shù)全集
- 深度學(xué)習(xí)原理與 TensorFlow實(shí)踐
- C#編程兵書(shū)