|
||||
0001 /* 0002 * Licensed to the Apache Software Foundation (ASF) under one or more 0003 * contributor license agreements. See the NOTICE file distributed with 0004 * this work for additional information regarding copyright ownership. 0005 * The ASF licenses this file to You under the Apache License, Version 2.0 0006 * (the "License"); you may not use this file except in compliance with 0007 * the License. You may obtain a copy of the License at 0008 * 0009 * http://www.apache.org/licenses/LICENSE-2.0 0010 * 0011 * Unless required by applicable law or agreed to in writing, software 0012 * distributed under the License is distributed on an "AS IS" BASIS, 0013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0014 * See the License for the specific language governing permissions and 0015 * limitations under the License. 0016 */ 0017 package org.apache.spark.examples.ml; 0018 0019 // $example on$ 0020 0021 import org.apache.spark.ml.regression.IsotonicRegression; 0022 import org.apache.spark.ml.regression.IsotonicRegressionModel; 0023 import org.apache.spark.sql.Dataset; 0024 import org.apache.spark.sql.Row; 0025 // $example off$ 0026 import org.apache.spark.sql.SparkSession; 0027 0028 /** 0029 * An example demonstrating IsotonicRegression. 0030 * Run with 0031 * <pre> 0032 * bin/run-example ml.JavaIsotonicRegressionExample 0033 * </pre> 0034 */ 0035 public class JavaIsotonicRegressionExample { 0036 0037 public static void main(String[] args) { 0038 // Create a SparkSession. 0039 SparkSession spark = SparkSession 0040 .builder() 0041 .appName("JavaIsotonicRegressionExample") 0042 .getOrCreate(); 0043 0044 // $example on$ 0045 // Loads data. 0046 Dataset<Row> dataset = spark.read().format("libsvm") 0047 .load("data/mllib/sample_isotonic_regression_libsvm_data.txt"); 0048 0049 // Trains an isotonic regression model. 0050 IsotonicRegression ir = new IsotonicRegression(); 0051 IsotonicRegressionModel model = ir.fit(dataset); 0052 0053 System.out.println("Boundaries in increasing order: " + model.boundaries() + "\n"); 0054 System.out.println("Predictions associated with the boundaries: " + model.predictions() + "\n"); 0055 0056 // Makes predictions. 0057 model.transform(dataset).show(); 0058 // $example off$ 0059 0060 spark.stop(); 0061 } 0062 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |