Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2010-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
   * 
   * Licensed under the Apache License, Version 2.0 (the "License").
   * You may not use this file except in compliance with the License.
   * A copy of the License is located at
   * 
   *  http://aws.amazon.com/apache2.0
   * 
  * or in the "license" file accompanying this file. This file 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 com.amazonaws.services.machinelearning.model;
 

The output from a Predict operation:

  • Details - Contains the following attributes: DetailsAttributes.PREDICTIVE_MODEL_TYPE - REGRESSION | BINARY | MULTICLASS DetailsAttributes.ALGORITHM - SGD

  • PredictedLabel - Present for either a BINARY or MULTICLASS MLModel request.

  • PredictedScores - Contains the raw classification score corresponding to each label.

  • PredictedValue - Present for a REGRESSION MLModel request.

 
 public class Prediction implements SerializableCloneable {

    
The prediction label for either a BINARY or MULTICLASS MLModel.

Constraints:
Length: 1 -

 
     private String predictedLabel;

    
The prediction value for REGRESSION MLModel.
 
     private Float predictedValue;

    
Provides the raw classification score corresponding to each label.
 
     private java.util.Map<String,FloatpredictedScores;

    
Provides any additional details regarding the prediction.
 
     private java.util.Map<String,Stringdetails;

    
The prediction label for either a BINARY or MULTICLASS MLModel.

Constraints:
Length: 1 -

Returns:
The prediction label for either a BINARY or MULTICLASS MLModel.
 
     public String getPredictedLabel() {
         return ;
     }
    
    
The prediction label for either a BINARY or MULTICLASS MLModel.

Constraints:
Length: 1 -

Parameters:
predictedLabel The prediction label for either a BINARY or MULTICLASS MLModel.
 
     public void setPredictedLabel(String predictedLabel) {
        this. = predictedLabel;
    }
    
    
The prediction label for either a BINARY or MULTICLASS MLModel.

Returns a reference to this object so that method calls can be chained together.

Constraints:
Length: 1 -

Parameters:
predictedLabel The prediction label for either a BINARY or MULTICLASS MLModel.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Prediction withPredictedLabel(String predictedLabel) {
        this. = predictedLabel;
        return this;
    }

    
The prediction value for REGRESSION MLModel.

Returns:
The prediction value for REGRESSION MLModel.
    public Float getPredictedValue() {
        return ;
    }
    
    
The prediction value for REGRESSION MLModel.

Parameters:
predictedValue The prediction value for REGRESSION MLModel.
    public void setPredictedValue(Float predictedValue) {
        this. = predictedValue;
    }
    
    
The prediction value for REGRESSION MLModel.

Returns a reference to this object so that method calls can be chained together.

Parameters:
predictedValue The prediction value for REGRESSION MLModel.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Prediction withPredictedValue(Float predictedValue) {
        this. = predictedValue;
        return this;
    }

    
Provides the raw classification score corresponding to each label.

Returns:
Provides the raw classification score corresponding to each label.
        
        if ( == null) {
             = new java.util.HashMap<String,Float>();
        }
        return ;
    }
    
    
Provides the raw classification score corresponding to each label.

Parameters:
predictedScores Provides the raw classification score corresponding to each label.
    public void setPredictedScores(java.util.Map<String,FloatpredictedScores) {
        this. = predictedScores;
    }
    
    
Provides the raw classification score corresponding to each label.

Returns a reference to this object so that method calls can be chained together.

Parameters:
predictedScores Provides the raw classification score corresponding to each label.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Prediction withPredictedScores(java.util.Map<String,FloatpredictedScores) {
        setPredictedScores(predictedScores);
        return this;
    }

    
Provides the raw classification score corresponding to each label.

The method adds a new key-value pair into PredictedScores parameter, and returns a reference to this object so that method calls can be chained together.

Parameters:
key The key of the entry to be added into PredictedScores.
value The corresponding value of the entry to be added into PredictedScores.
  public Prediction addPredictedScoresEntry(String keyFloat value) {
    if (null == this.) {
      this. = new java.util.HashMap<String,Float>();
    }
    if (this..containsKey(key))
      throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
    this..put(keyvalue);
    return this;
  }

  
Removes all the entries added into PredictedScores.

Returns a reference to this object so that method calls can be chained together.

    this. = null;
    return this;
  }
  
    
Provides any additional details regarding the prediction.

Returns:
Provides any additional details regarding the prediction.
    public java.util.Map<String,StringgetDetails() {
        
        if ( == null) {
             = new java.util.HashMap<String,String>();
        }
        return ;
    }
    
    
Provides any additional details regarding the prediction.

Parameters:
details Provides any additional details regarding the prediction.
    public void setDetails(java.util.Map<String,Stringdetails) {
        this. = details;
    }
    
    
Provides any additional details regarding the prediction.

Returns a reference to this object so that method calls can be chained together.

Parameters:
details Provides any additional details regarding the prediction.
Returns:
A reference to this updated object so that method calls can be chained together.
    public Prediction withDetails(java.util.Map<String,Stringdetails) {
        setDetails(details);
        return this;
    }

    
Provides any additional details regarding the prediction.

The method adds a new key-value pair into Details parameter, and returns a reference to this object so that method calls can be chained together.

Parameters:
key The key of the entry to be added into Details.
value The corresponding value of the entry to be added into Details.
  public Prediction addDetailsEntry(String keyString value) {
    if (null == this.) {
      this. = new java.util.HashMap<String,String>();
    }
    if (this..containsKey(key))
      throw new IllegalArgumentException("Duplicated keys (" + key.toString() + ") are provided.");
    this..put(keyvalue);
    return this;
  }

  
Removes all the entries added into Details.

Returns a reference to this object so that method calls can be chained together.

    this. = null;
    return this;
  }
  
    
Returns a string representation of this object; useful for testing and debugging.

Returns:
A string representation of this object.
See also:
java.lang.Object.toString()
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getPredictedLabel() != nullsb.append("PredictedLabel: " + getPredictedLabel() + ",");
        if (getPredictedValue() != nullsb.append("PredictedValue: " + getPredictedValue() + ",");
        if (getPredictedScores() != nullsb.append("PredictedScores: " + getPredictedScores() + ",");
        if (getDetails() != nullsb.append("Details: " + getDetails() );
        sb.append("}");
        return sb.toString();
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;
        
        hashCode = prime * hashCode + ((getPredictedLabel() == null) ? 0 : getPredictedLabel().hashCode()); 
        hashCode = prime * hashCode + ((getPredictedValue() == null) ? 0 : getPredictedValue().hashCode()); 
        hashCode = prime * hashCode + ((getPredictedScores() == null) ? 0 : getPredictedScores().hashCode()); 
        hashCode = prime * hashCode + ((getDetails() == null) ? 0 : getDetails().hashCode()); 
        return hashCode;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == objreturn true;
        if (obj == nullreturn false;
        if (obj instanceof Prediction == falsereturn false;
        Prediction other = (Prediction)obj;
        
        if (other.getPredictedLabel() == null ^ this.getPredictedLabel() == nullreturn false;
        if (other.getPredictedLabel() != null && other.getPredictedLabel().equals(this.getPredictedLabel()) == falsereturn false
        if (other.getPredictedValue() == null ^ this.getPredictedValue() == nullreturn false;
        if (other.getPredictedValue() != null && other.getPredictedValue().equals(this.getPredictedValue()) == falsereturn false
        if (other.getPredictedScores() == null ^ this.getPredictedScores() == nullreturn false;
        if (other.getPredictedScores() != null && other.getPredictedScores().equals(this.getPredictedScores()) == falsereturn false
        if (other.getDetails() == null ^ this.getDetails() == nullreturn false;
        if (other.getDetails() != null && other.getDetails().equals(this.getDetails()) == falsereturn false
        return true;
    }
    
    @Override
    public Prediction clone() {
        try {
            return (Predictionsuper.clone();
        
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException(
                    "Got a CloneNotSupportedException from Object.clone() "
                    + "even though we're Cloneable!",
                    e);
        }
        
    }
}
    
New to GrepCode? Check out our FAQ X