Skip to content

Instantly share code, notes, and snippets.

@ergo70
Last active January 28, 2016 06:46
Show Gist options
  • Save ergo70/4ebc74eb8be2bb817d02 to your computer and use it in GitHub Desktop.
Save ergo70/4ebc74eb8be2bb817d02 to your computer and use it in GitHub Desktop.
predict2
CREATE OR REPLACE FUNCTION r_predict2(inp integer)
RETURNS text AS
$BODY$
if (pg.state.firstpass)
{
library(e1071)
data <- seq(1,10)
classes <- c('b','b','b','b','a','a','a','a','b','b')
mysvm = svm (data, classes, type='C', kernel='radial', gamma=0.1, cost=10)
assign("pg.state.firstpass", FALSE, env=.GlobalEnv)
}
result <- predict(mysvm, inp)
return(as.character(result[1:1]))
$BODY$
LANGUAGE plr IMMUTABLE STRICT
COST 100;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment