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

revise the code example #1640

Merged
merged 2 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -21,7 +21,7 @@ and `inputCol`="a"
and `splits`="-inf,0.0,1.0,inf";

register Discretizer.`/tmp/model` as convert;
select convert(array(double(7),double(8))) as features as output;
select convert(array(double(7))) as features as output;

select name,value from model_result where name="status" as result;
-- make sure status of all models are success.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ and `outputCol`="a_v"
and `numBuckets`="3";

register Discretizer.`/tmp/discretizer` as convert;
select convert(array(double(7),double(8))) as features as output;
select convert(array(double(7))) as features as output;

select name,value from model_result where name="status" as result;
-- make sure status of all models are success.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,17 @@ class SQLDiscretizer(override val uid: String) extends SQLAlg with Functions wit
return metas
}

def checkWithoutGroupParams(params: Map[String, String]): Unit = {
val group = params.map(p => {
val key = p._1
key.contains(DiscretizerParamsConstrant.PARAMS_PREFIX + ".")
}).filter(_ == true)
require(group.size == 0, "The multi-group params are not available for the Discretizer Et!")
}

def trainWithoutGroup(df: DataFrame, params: Map[String, String], _method: String, metaPath: String): DataFrame = {
val dfWithId = df.withColumn("id", monotonically_increasing_id)
checkWithoutGroupParams(params)
var transformedDF = dfWithId
// we need save metadatas with index, because we need index
val metas: Array[(Int, DiscretizerTrainData)] = {
Expand Down Expand Up @@ -220,10 +229,21 @@ class SQLDiscretizer(override val uid: String) extends SQLAlg with Functions wit
|
|train data1 as Discretizer.`/tmp/model`
|where method="bucketizer"
|and `fitParam.0.inputCol`="a"
|and `fitParam.0.splitArray`="-inf,0.0,1.0,inf"
|and `fitParam.1.inputCol`="b"
|and `fitParam.1.splitArray`="-inf,0.0,1.0,inf";
|and `inputCol`="a"
|and `splits`="-inf,0.0,1.0,inf";
|
|register Discretizer.`/tmp/model` as convert;
|select convert(array(double(7))) as features as output;
|
|
|train data1 as Discretizer.`/tmp/model`
|where method="bucketizer"
|and `inputCol`="a"
|and `splits`="-inf,0.0,1.0,inf";
|
|register Discretizer.`/tmp/model` as convert1;
|select convert1(array(double(7))) as features as output;
|
|;
""".stripMargin)
chncaesar marked this conversation as resolved.
Show resolved Hide resolved

Expand Down