-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-15608][ML][EXAMPLES][DOC] add examples and documents of ml.iso…
…tonic regression ## What changes were proposed in this pull request? add ml doc for ml isotonic regression add scala example for ml isotonic regression add java example for ml isotonic regression add python example for ml isotonic regression modify scala example for mllib isotonic regression modify java example for mllib isotonic regression modify python example for mllib isotonic regression add data/mllib/sample_isotonic_regression_libsvm_data.txt delete data/mllib/sample_isotonic_regression_data.txt ## How was this patch tested? N/A Author: WeichenXu <[email protected]> Closes #13381 from WeichenXu123/add_isotonic_regression_doc. (cherry picked from commit 9040d83) Signed-off-by: Yanbo Liang <[email protected]>
- Loading branch information
1 parent
b3678eb
commit 68e7a25
Showing
9 changed files
with
373 additions
and
114 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
0.24579296 1:0.01 | ||
0.28505864 1:0.02 | ||
0.31208567 1:0.03 | ||
0.35900051 1:0.04 | ||
0.35747068 1:0.05 | ||
0.16675166 1:0.06 | ||
0.17491076 1:0.07 | ||
0.04181540 1:0.08 | ||
0.04793473 1:0.09 | ||
0.03926568 1:0.10 | ||
0.12952575 1:0.11 | ||
0.00000000 1:0.12 | ||
0.01376849 1:0.13 | ||
0.13105558 1:0.14 | ||
0.08873024 1:0.15 | ||
0.12595614 1:0.16 | ||
0.15247323 1:0.17 | ||
0.25956145 1:0.18 | ||
0.20040796 1:0.19 | ||
0.19581846 1:0.20 | ||
0.15757267 1:0.21 | ||
0.13717491 1:0.22 | ||
0.19020908 1:0.23 | ||
0.19581846 1:0.24 | ||
0.20091790 1:0.25 | ||
0.16879143 1:0.26 | ||
0.18510964 1:0.27 | ||
0.20040796 1:0.28 | ||
0.29576747 1:0.29 | ||
0.43396226 1:0.30 | ||
0.53391127 1:0.31 | ||
0.52116267 1:0.32 | ||
0.48546660 1:0.33 | ||
0.49209587 1:0.34 | ||
0.54156043 1:0.35 | ||
0.59765426 1:0.36 | ||
0.56144824 1:0.37 | ||
0.58592555 1:0.38 | ||
0.52983172 1:0.39 | ||
0.50178480 1:0.40 | ||
0.52626211 1:0.41 | ||
0.58286588 1:0.42 | ||
0.64660887 1:0.43 | ||
0.68077511 1:0.44 | ||
0.74298827 1:0.45 | ||
0.64864865 1:0.46 | ||
0.67261601 1:0.47 | ||
0.65782764 1:0.48 | ||
0.69811321 1:0.49 | ||
0.63029067 1:0.50 | ||
0.61601224 1:0.51 | ||
0.63233044 1:0.52 | ||
0.65323814 1:0.53 | ||
0.65323814 1:0.54 | ||
0.67363590 1:0.55 | ||
0.67006629 1:0.56 | ||
0.51555329 1:0.57 | ||
0.50892402 1:0.58 | ||
0.33299337 1:0.59 | ||
0.36206017 1:0.60 | ||
0.43090260 1:0.61 | ||
0.45996940 1:0.62 | ||
0.56348802 1:0.63 | ||
0.54920959 1:0.64 | ||
0.48393677 1:0.65 | ||
0.48495665 1:0.66 | ||
0.46965834 1:0.67 | ||
0.45181030 1:0.68 | ||
0.45843957 1:0.69 | ||
0.47118817 1:0.70 | ||
0.51555329 1:0.71 | ||
0.58031617 1:0.72 | ||
0.55481897 1:0.73 | ||
0.56297807 1:0.74 | ||
0.56603774 1:0.75 | ||
0.57929628 1:0.76 | ||
0.64762876 1:0.77 | ||
0.66241713 1:0.78 | ||
0.69301377 1:0.79 | ||
0.65119837 1:0.80 | ||
0.68332483 1:0.81 | ||
0.66598674 1:0.82 | ||
0.73890872 1:0.83 | ||
0.73992861 1:0.84 | ||
0.84242733 1:0.85 | ||
0.91330954 1:0.86 | ||
0.88016318 1:0.87 | ||
0.90719021 1:0.88 | ||
0.93115757 1:0.89 | ||
0.93115757 1:0.90 | ||
0.91942886 1:0.91 | ||
0.92911780 1:0.92 | ||
0.95665477 1:0.93 | ||
0.95002550 1:0.94 | ||
0.96940337 1:0.95 | ||
1.00000000 1:0.96 | ||
0.89801122 1:0.97 | ||
0.90311066 1:0.98 | ||
0.90362060 1:0.99 | ||
0.83477817 1:1.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
examples/src/main/java/org/apache/spark/examples/ml/JavaIsotonicRegressionExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.spark.examples.ml; | ||
|
||
// $example on$ | ||
|
||
import org.apache.spark.ml.regression.IsotonicRegression; | ||
import org.apache.spark.ml.regression.IsotonicRegressionModel; | ||
import org.apache.spark.sql.Dataset; | ||
import org.apache.spark.sql.Row; | ||
// $example off$ | ||
import org.apache.spark.sql.SparkSession; | ||
|
||
/** | ||
* An example demonstrating IsotonicRegression. | ||
* Run with | ||
* <pre> | ||
* bin/run-example ml.JavaIsotonicRegressionExample | ||
* </pre> | ||
*/ | ||
public class JavaIsotonicRegressionExample { | ||
|
||
public static void main(String[] args) { | ||
// Create a SparkSession. | ||
SparkSession spark = SparkSession | ||
.builder() | ||
.appName("JavaIsotonicRegressionExample") | ||
.getOrCreate(); | ||
|
||
// $example on$ | ||
// Loads data. | ||
Dataset<Row> dataset = spark.read().format("libsvm") | ||
.load("data/mllib/sample_isotonic_regression_libsvm_data.txt"); | ||
|
||
// Trains an isotonic regression model. | ||
IsotonicRegression ir = new IsotonicRegression(); | ||
IsotonicRegressionModel model = ir.fit(dataset); | ||
|
||
System.out.println("Boundaries in increasing order: " + model.boundaries()); | ||
System.out.println("Predictions associated with the boundaries: " + model.predictions()); | ||
|
||
// Makes predictions. | ||
model.transform(dataset).show(); | ||
// $example off$ | ||
|
||
spark.stop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.