當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleRegression.predict方法代碼示例

本文整理匯總了Java中org.apache.commons.math3.stat.regression.SimpleRegression.predict方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleRegression.predict方法的具體用法?Java SimpleRegression.predict怎麽用?Java SimpleRegression.predict使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.math3.stat.regression.SimpleRegression的用法示例。


在下文中一共展示了SimpleRegression.predict方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: makePrediction

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
private void makePrediction(List<GlucoseData> trendList) {
    if (trendList.size() == 0) {
        return;
    }
    regression = new SimpleRegression();
    for (int i = 0; i < trendList.size(); i++) {
        regression.addData(i, (trendList.get(i)).getGlucoseLevelRaw());
    }
    int glucoseLevelRaw =
            (int) regression.predict(regression.getN() - 1 + PREDICTION_TIME);
    glucoseSlopeRaw = regression.getSlope();
    confidenceInterval = regression.getSlopeConfidenceInterval();
    int ageInSensorMinutes =
            trendList.get(trendList.size() - 1).getAgeInSensorMinutes() + PREDICTION_TIME;
    glucoseData = new GlucoseData(trendList.get(0).getSensor(), ageInSensorMinutes, trendList.get(0).getTimezoneOffsetInMinutes(), glucoseLevelRaw, true);
}
 
開發者ID:DorianScholz,項目名稱:OpenLibre,代碼行數:17,代碼來源:PredictionData.java

示例2: getRobustLoessParameterEstimates

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
/**
 * Gets the robust loess parameter estimates.
 * 
 * @param y the y
 * @return the robust loess parameter estimates
 */
public static double[] getRobustLoessParameterEstimates(final double[] y) {
	int n = y.length;
	double[] x = new double[n];
	for (int i = 0; i < n; i++) {
		x[i] = i + 1;
	}
	SimpleRegression tricubeRegression = createWeigthedLinearRegression(x,
			y, getTricubeWeigts(n));
	double[] residuals = new double[n];
	for (int i = 0; i < n; i++) {
		residuals[i] = y[i] - tricubeRegression.predict(x[i]);
	}
	SimpleRegression tricubeBySquareRegression = createWeigthedLinearRegression(
			x, y, getTricubeBisquareWeigts(residuals));

	double[] estimates = tricubeBySquareRegression.regress()
			.getParameterEstimates();
	if (estimates[0] == Double.NaN || estimates[1] == Double.NaN) {
		return tricubeRegression.regress().getParameterEstimates();
	}
	return estimates;
}
 
開發者ID:gmartinezramirez,項目名稱:Fog-Computing-Mobile-Architecture,代碼行數:29,代碼來源:MathUtil.java

示例3: getPredictionData

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
@NonNull
private static PredictionData getPredictionData(int attempt, String tagId, ArrayList<GlucoseData> trendList) {
    PredictionData predictedGlucose = new PredictionData();
    SimpleRegression regression = new SimpleRegression();
    for (int i = 0; i < trendList.size(); i++) {
        regression.addData(trendList.size() - i, (trendList.get(i)).glucoseLevel);
    }
    predictedGlucose.glucoseLevel = (int)regression.predict(15 + PREDICTION_TIME);
    predictedGlucose.trend = regression.getSlope();
    predictedGlucose.confidence = regression.getSlopeConfidenceInterval();
    predictedGlucose.errorCode = PredictionData.Result.OK;
    predictedGlucose.realDate = trendList.get(0).realDate;
    predictedGlucose.sensorId = tagId;
    predictedGlucose.attempt = attempt;
    predictedGlucose.sensorTime = trendList.get(0).sensorTime;
    return predictedGlucose;
}
 
開發者ID:pimpimmi,項目名稱:LibreAlarm,代碼行數:18,代碼來源:AlgorithmUtil.java

示例4: doAnalysis

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
@Override
protected double doAnalysis(final ThroughputHistory history) {
	final SimpleRegression regression = new SimpleRegression();

	for (int i = 1; i <= this.window; i++) {
		final double xaxis = history.getTimestampOfEntry(i);
		final double yaxis = history.getThroughputOfEntry(i);

		regression.addData(xaxis, yaxis);
	}

	final double currentTime = history.getTimestampOfEntry(0);
	double prediction = regression.predict(currentTime);

	if (Double.isNaN(prediction)
			|| prediction < 0
			|| Double.isInfinite(prediction)) {
		prediction = 0;
	}

	return prediction;
}
 
開發者ID:teetime-framework,項目名稱:TeeTime,代碼行數:23,代碼來源:RegressionAlgorithm.java

示例5: getRobustLoessParameterEstimates

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
/**
 * Gets the robust loess parameter estimates.
 *
 * @param y the y array
 * @return the robust loess parameter estimates
 */
public static double[] getRobustLoessParameterEstimates(final double... y) {
    final int n = y.length;
    final double[] x = new double[n];
    for (int i = 0; i < n; i++) {
        x[i] = i + 1;
    }
    final SimpleRegression tricubeRegression = createWeigthedLinearRegression(x,
        y, getTricubeWeights(n));
    final double[] residuals = new double[n];
    for (int i = 0; i < n; i++) {
        residuals[i] = y[i] - tricubeRegression.predict(x[i]);
    }
    final SimpleRegression tricubeBySqrRegression = createWeigthedLinearRegression(
        x, y, getTricubeBisquareWeights(residuals));

    final double[] estimates = tricubeBySqrRegression.regress()
        .getParameterEstimates();
    if (Double.isNaN(estimates[0]) || Double.isNaN(estimates[1])) {
        return tricubeRegression.regress().getParameterEstimates();
    }
    return estimates;
}
 
開發者ID:manoelcampos,項目名稱:cloudsim-plus,代碼行數:29,代碼來源:MathUtil.java

示例6: createChart

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
private void createChart(SpotterResult result, String operation, NumericPairList<Long, Double> responseTimeSeries,
			SimpleRegression regression) {
		NumericPairList<Long, Double> linRegressionPoints = new NumericPairList<>();
		NumericPairList<Long, Double> thresholdPoints = new NumericPairList<>();
		long minTimestamp = responseTimeSeries.getKeyMin();
		long maxTimestamp = responseTimeSeries.getKeyMax();
		double intercept = regression.predict(minTimestamp);
		linRegressionPoints.add(minTimestamp, intercept);
		linRegressionPoints.add(maxTimestamp, regression.predict(maxTimestamp));
		thresholdPoints.add(minTimestamp, intercept);
		thresholdPoints.add(maxTimestamp, slopeThreshold * (double) (maxTimestamp - minTimestamp) + intercept);

		AnalysisChartBuilder chartBuilder = AnalysisChartBuilder.getChartBuilder();
		chartBuilder.startChart(operation, "Experiment Time [ms]", "Response Time [ms]");
//		chartBuilder.addTimeSeries(responseTimeSeries, "Response Times");
		chartBuilder.addTimeSeriesWithLine(thresholdPoints, "Threshold Slope");
		chartBuilder.addTimeSeriesWithLine(linRegressionPoints, "Regression Slope");
		mainDetectionController.getResultManager().storeImageChartResource(chartBuilder,
				"Ramp Detection (Lin)", result);
	}
 
開發者ID:sopeco,項目名稱:DynamicSpotter-Extensions,代碼行數:21,代碼來源:LinearRegressionStrategy.java

示例7: drawNameRotated

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
/**
 * Draws the given name at the centroid of the given plateCenters. The angle the name is
 * drawn at is the least squares line through the plate centers. This does not break text
 * into multiple lines.
 * 
 * Side effect: This adds a new MapText to mapTexts.
 * 
 * @param riseOffset The text will be raised (positive y) by this much distance above the centroid when
 *  drawn. The rotation will be applied to this location. If there is already a name drawn above the object,
 *  I try negating the riseOffset to draw the name below it. Positive y is down.
 */
public void drawNameRotated(BufferedImage map, Graphics2D g, String name, Set<Point> locations,
		double riseOffset, boolean enableBoundsChecking, TextType type)
{
	if (name.length() == 0)
		return;
	
			
	Point centroid = findCentroid(locations);
	
	SimpleRegression regression = new SimpleRegression();
	for (Point p : locations)
	{
		regression.addObservation(new double[]{p.x}, p.y);
	}
	double angle;
	try
	{
		regression.regress();
		
		// Find the angle to rotate the text to.
		double y0 = regression.predict(0);
		double y1 = regression.predict(1);
		// Move the intercept to the origin.
		y1 -= y0;
		y0 = 0;
		angle = Math.atan(y1/1.0);
	}
	catch(NoDataException e)
	{
		// This happens if the regression had only 2 or fewer points.
		angle = 0;
	}
			
	MapText text = createMapText(name, centroid, angle, type);
	if (drawNameRotated(map, g, riseOffset, enableBoundsChecking, text))
	{
		mapTexts.add(text);
	}
}
 
開發者ID:jeheydorn,項目名稱:nortantis,代碼行數:51,代碼來源:TextDrawer.java

示例8: addRegressionColumn

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
@Override
public Grid addRegressionColumn( int columnIndex, boolean addHeader )
{
    verifyGridState();

    SimpleRegression regression = new SimpleRegression();

    List<Object> column = getColumn( columnIndex );

    int index = 0;

    for ( Object value : column )
    {
        // 0 omitted from regression

        if ( value != null && !MathUtils.isEqual( Double.parseDouble( String.valueOf( value ) ), 0d ) )
        {
            regression.addData( index++, Double.parseDouble( String.valueOf( value ) ) );
        }
    }

    List<Object> regressionColumn = new ArrayList<>();

    for ( int i = 0; i < column.size(); i++ )
    {
        final double predicted = regression.predict( i );

        // Enough values must exist for regression

        if ( !Double.isNaN( predicted ) )
        {
            regressionColumn.add( Precision.round( predicted, 1 ) );
        }
        else
        {
            regressionColumn.add( null );
        }
    }

    addColumn( regressionColumn );

    if ( addHeader && columnIndex < headers.size() )
    {
        GridHeader header = headers.get( columnIndex );

        if ( header != null )
        {
            GridHeader regressionHeader = new GridHeader( header.getName() + REGRESSION_SUFFIX,
                header.getColumn() + REGRESSION_SUFFIX, header.getValueType(), header.getType(), header.isHidden(), header.isMeta() );

            addHeader( regressionHeader );
        }
    }

    return this;
}
 
開發者ID:dhis2,項目名稱:dhis2-core,代碼行數:57,代碼來源:ListGrid.java

示例9: addRegressionColumn

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
@Override
public Grid addRegressionColumn( int columnIndex, boolean addHeader )
{
    verifyGridState();

    SimpleRegression regression = new SimpleRegression();

    List<Object> column = getColumn( columnIndex );

    int index = 0;

    for ( Object value : column )
    {
        // 0 omitted from regression

        if ( value != null && !MathUtils.isEqual( Double.parseDouble( String.valueOf( value ) ), 0d ) )
        {
            regression.addData( index++, Double.parseDouble( String.valueOf( value ) ) );
        }
    }

    List<Object> regressionColumn = new ArrayList<>();

    for ( int i = 0; i < column.size(); i++ )
    {
        final double predicted = regression.predict( i );

        // Enough values must exist for regression

        if ( !Double.isNaN( predicted ) )
        {
            regressionColumn.add( getRounded( predicted, 1 ) );
        }
        else
        {
            regressionColumn.add( null );
        }
    }

    addColumn( regressionColumn );

    if ( addHeader && columnIndex < headers.size() )
    {
        GridHeader header = headers.get( columnIndex );

        if ( header != null )
        {
            GridHeader regressionHeader = new GridHeader( header.getName() + REGRESSION_SUFFIX,
                header.getColumn() + REGRESSION_SUFFIX, header.getType(), header.isHidden(), header.isMeta() );

            addHeader( regressionHeader );
        }
    }

    return this;
}
 
開發者ID:ehatle,項目名稱:AgileAlligators,代碼行數:57,代碼來源:ListGrid.java

示例10: calcCalibratedCo2

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
/**
 * <p>Calibrate a CO<sub>2</sub> measurement to the gas standards.</p>
 * 
 * <p>The calibration is performed by retrieving the gas standard runs immediately before
 * and after the measurement, which implicitly include the adjustment of the measured CO<sub>2</sub>
 * in the gas standard run to the true value of the standard
 * (see {@link GasStandardRuns#getStandardsRegression(DataSource, long, Calendar)}).
 * If only one standard is available (e.g. at the beginning or end of a data file), the single
 * available standard is used.
 * 
 * The CO<sub>2</sub> value measured for the current record is adjusted to the linear progression between
 * the two gas standard runs.
 * 
 * @param driedCo2 The CO<sub>2</sub> value after drying
 * @param time The time that the measurement was taken
 * @param standardRuns The set of gas standard runs for the data file
 * @param instrument The instrument from which the measurement was taken
 * @return The calibrated CO<sub>2</sub> value
 * @throws MissingParamException If any parameters are missing
 * @throws DatabaseException If a database error occurs
 * @throws RecordNotFoundException If any required database records are missing
 * @see GasStandardRuns
 */
private double calcCalibratedCo2(double driedCo2, Calendar time, GasStandardRuns standardRuns, Instrument instrument) throws MissingParamException, DatabaseException, RecordNotFoundException {
	SimpleRegression regression = standardRuns.getStandardsRegression(dataSource, instrument.getDatabaseId(), time);
	return regression.predict(driedCo2);
}
 
開發者ID:BjerknesClimateDataCentre,項目名稱:QuinCe,代碼行數:28,代碼來源:DataReductionJob.java


注:本文中的org.apache.commons.math3.stat.regression.SimpleRegression.predict方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。