Public/Get-NexosisSessionResult.ps1

Function Get-NexosisSessionResult {
<#
 .Synopsis
  Gets the forecast or impact results of a particular session

 .Description
  In addition to the response body indicating information about the session, the response to this endpoint adds a nexosis-session-status HTTP response header indicating the completion status of the session.

    Forecast session results consist of the predictions for the dates specified when the session was created.

    Impact session results consist of the predictions of what would have happened over the specified date range, had the impactful event not occurred. Impact session results also include metrics that describe the overall impact of the event on the dataset. These metrics are:
       * pValue: Statistical value used to determine the significance of the impact. A small p-value indicates strong evidence of impact, whereas a p-value approaching 0.5 indicates weak evidence of impact.
       * absoluteEffect: Total absolute effect of the event on the dataset. Answers the question, "How much did this event affect my dataset?"
       * relativeEffect: Percentage effect of the event on the dataset. Answers the question, "By what percentage did this event affect my dataset?"

    Model Sessions
        Model session results consist of the test set predictions generated by the model. These results can be used to
        determine the accuracy of the generated model. Use the model endpoint to generate new predictions using the model.
        
 .Parameter SessionId
  A Session identifier (UUID) of the session results to retrieve.

 .Parameter predictionInterval
  The results returned will be from the given prediction interval.

 .Parameter page
  Zero-based page number of session results to retrieve.

 .Parameter pageSize
  Count of session results to retrieve in each page (max 1000).

 .Example
  # Retrieve session data for sesion with the given session ID
  Get-NexosisSessionResult -sessionId 015df24f-7f43-4efe-b8ba-1e28d67eb3fa

 .Example
  # Return just the session result data for the given session ID.
  (Get-NexosisSessionResult -SessionId 015df24f-7f43-4efe-b8ba-1e28d67eb3fa).data

#>
[CmdletBinding()]
    Param(
        [Parameter(Mandatory=$true, ValueFromPipeline=$True)]
        [GUID]$SessionId,
        [Parameter(Mandatory=$false)]
        [int]$page=0,
        [Parameter(Mandatory=$false)]
        [int]$pageSize=$script:PSNexosisVars.DefaultPageSize,
        [Parameter(Mandatory=$false, ValueFromPipeline=$True)]
        $predictionInterval
    )
    process {
        $params = [System.Web.HttpUtility]::ParseQueryString([String]::Empty)
        
        if (($null -ne $page) -and ($page -ne 0)) {
            $params['page'] = $page
        }

        if ($null -ne $pageSize) { 
            if ($pageSize -ne ($script:PSNexosisVars.DefaultPageSize)) {
                $params['pageSize'] = $pageSize
            } elseif ($script:PSNexosisVars.DefaultPageSize -ne $script:ServerDefaultPageSize) {
                $params['pageSize'] = $script:PSNexosisVars.DefaultPageSize
            }
        }

        if ($predictionInterval -ne $null) {
            $params['predictionInterval'] = $predictionInterval
        }

        Invoke-Http -method Get -path "sessions/$SessionId/results" -params $params
    }
}