- Artificial Intelligence for Big Data
- Anand Deshpande Manish Kumar
- 94字
- 2021-06-25 21:57:14
Logistic regression with Spark
We progress with logistic regression with Spark as follows:
import org.apache.spark.ml.classification.LogisticRegression // Load training data val training = spark.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt") val lr = new LogisticRegression() .setMaxIter(10) .setRegParam(0.3) .setElasticNetParam(0.8) // Fit the model val lrModel = lr.fit(training) // Print the coefficients and intercept for logistic regression println(s"Coefficients: ${lrModel.coefficients} Intercept: ${lrModel.intercept}") // We can also use the multinomial family for binary classification val mlr = new LogisticRegression() .setMaxIter(10) .setRegParam(0.3) .setElasticNetParam(0.8) .setFamily("multinomial") val mlrModel = mlr.fit(training) // Print the coefficients and intercepts for logistic regression with multinomial family println(s"Multinomial coefficients: ${mlrModel.coefficientMatrix}") println(s"Multinomial intercepts: ${mlrModel.interceptVector}")
推薦閱讀
- 數(shù)據(jù)分析實戰(zhàn):基于EXCEL和SPSS系列工具的實踐
- 云計算服務(wù)保障體系
- 醫(yī)療大數(shù)據(jù)挖掘與可視化
- Microsoft Power BI數(shù)據(jù)可視化與數(shù)據(jù)分析
- Python金融實戰(zhàn)
- 重復(fù)數(shù)據(jù)刪除技術(shù):面向大數(shù)據(jù)管理的縮減技術(shù)
- 云數(shù)據(jù)中心網(wǎng)絡(luò)與SDN:技術(shù)架構(gòu)與實現(xiàn)
- IPython Interactive Computing and Visualization Cookbook(Second Edition)
- Unreal Engine Virtual Reality Quick Start Guide
- 中文版Access 2007實例與操作
- 大數(shù)據(jù)技術(shù)原理與應(yīng)用:概念、存儲、處理、分析與應(yīng)用
- 智慧城市中的大數(shù)據(jù)分析技術(shù)
- Access數(shù)據(jù)庫開發(fā)從入門到精通
- 云計算寶典:技術(shù)與實踐
- 數(shù)據(jù)庫原理與設(shè)計實驗教程(MySQL版)