Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML-185]Select label and features columns and cache data #196

Merged
merged 2 commits into from
Apr 1, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@ class NaiveBayes @Since("1.5.0") (

val sc = spark.sparkContext

val executor_num = Utils.sparkExecutorNum(sc)
val executor_cores = Utils.sparkExecutorCores()
// select label and features columns and cache data.
val naiveBayesData = dataset.select($(labelCol), $(featuresCol)).cache()
naiveBayesData.count()

val executorNum = Utils.sparkExecutorNum(sc)
val executorCores = Utils.sparkExecutorCores()

logInfo(s"NaiveBayesDAL fit using $executor_num Executors")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logInfo(s"NaiveBayesDAL fit using $executor_num Executors")
logInfo(s"NaiveBayesDAL fit using $executorNum Executors")


Expand All @@ -146,17 +150,17 @@ class NaiveBayes @Since("1.5.0") (
// numClasses should be explicitly included in the parquet metadata
// This can be done by applying StringIndexer to the label column
val numClasses = confClasses match {
case -1 => getNumClasses(dataset)
case -1 => getNumClasses(naiveBayesData)
case _ => confClasses
}

instr.logNumClasses(numClasses)

val labeledPointsDS = dataset
val labeledPointsDS = naiveBayesData
.select(col(getLabelCol), DatasetUtils.columnToVector(dataset, getFeaturesCol))

val dalModel = new NaiveBayesDALImpl(uid, numClasses,
executor_num, executor_cores).train(labeledPointsDS, ${labelCol}, ${featuresCol})
executorNum, executorCores).train(labeledPointsDS, ${labelCol}, ${featuresCol})

val model = copyValues(new NaiveBayesModel(
dalModel.uid, dalModel.pi, dalModel.theta, dalModel.sigma))
Expand Down