DSC_WebService: A DSC Interface for a DSC Running as a Web Service

View source: R/DSC_WebService.R

DSC_WebServiceR Documentation

A DSC Interface for a DSC Running as a Web Service

Description

Provides a DSC front-end for a clusterer running as a web service. The methods nclusters(), get_center(), get_weights() are supported. The request is retried with httr::RETRY() if it fails the first time.

Usage

DSC_WebService(url, verbose = FALSE, ...)

Arguments

url

endpoint URI address in the format ⁠http://host:port/<optional_path>⁠.

verbose

logical; display connection information.

...

further arguments are passed on to httr::RETRY(). Pass httr::verbose() as parameter config to get detailed connection info.

Value

A stream::DSC object.

See Also

Other WebService: DSD_ReadWebService(), publish_DSC_via_WebService(), publish_DSD_via_WebService()

Other dsc: publish_DSC_via_WebService()

Examples

# find a free port
port <- httpuv::randomPort()
port

# deploy a clustering process listening for data on the port
rp1 <- publish_DSC_via_WebService("DSC_DBSTREAM(r = .05)", port = port)
rp1

# get a local DSC interface
dsc <- DSC_WebService(paste0("http://localhost", ":", port), 
  verbose = TRUE, config = httr::verbose(info = TRUE))
dsc

# cluster
dsd <- DSD_Gaussians(k = 3, d = 2, noise = 0.05)

update(dsc, dsd, 500)

get_centers(dsc)
get_weights(dsc)

plot(dsc)

# kill the background clustering process.
rp1$kill()
rp1


streamConnect documentation built on June 22, 2024, 9:55 a.m.