Skip to content

Data and model does not match #1

Description

@Dadle88

When adding this node to SPSS Modeler 18 and running against the Watson Machine Learning service on Bluemix I am not able to get any results returned from the service. Regardless of running against the scoring stream from the exmple in this repository or my own model.

Two things look suspect to me:

  1. the context variable when setting up the node does not seem to change in the console log when dialog option is changed.
  2. X21 variable is hard coded. Should this be dynamic?

The issue from the log below seems to be in the results of the data.
results<-append(results,content_list[[1]]$data[[1]][[21]])
Error in content_list[[1]]$data :
$ operator is invalid for atomic vectors

Console output:
R Scripts***********
modelerDataModel <- ibmspsscfdatamodel.GetDataModel()
modelerData <- ibmspsscfdata.GetDataFromTemp(missingValue=NA,rDate="POSIXct",logicalFields=FALSE)

TODO: Add comment

Author: baaron

###############################################################################
#modelerData contains the original input data
#modelerDataModel contains new data

Install function for packages

packages <- function(x){
x <- as.character(match.call()[[2]])
if (!require(x,character.only=TRUE)){
install.packages(pkgs=x,repos="http://cran.r-project.org")
require(x,character.only=TRUE)
}
}
packages(jsonlite)
packages(httr)
packages(xml2)
#modelerData contains the original input data
#modelerDataModel contains new data
#url <- "https://ibm-watson-ml.mybluemix.net/pm/v1/score/mensSLAMS?accesskey=yRKLh9tacKkYJIQW9jGHcf3TD6sG2zypuz++AkRJZ8XE7rXhgI/90u33DG57oQBmHxGxQ3pIogjgEOjN0TGDTcL0h32gVzPkwMbmHXNpi+FQYUqQmv73SQJrb1WXWeZv"
#assemble the content from the original data
base <-"https://palblyp.pmservice.ibmcloud.com/pm/v1/score/"
context<-"testStream"
token<-"iGII4hMmzqA2S1r4EhQfKZohS37Gp+Mg0M5mgtaTZXbxtBkuVEaJWZ+7UAsRBycGpvelDBj2EWArRQzCnErs5G6xF7OPG2R5H0oB0w5syog= "
url <- paste(base,context ,'?accesskey=',token,sep='')
#print(url)
df <- modelerData
header <- c()
data <- c()
results <- c()
for(i in 1:nrow(df)){
row<-df[i,]
for(i in names(df)){
header<-append(header,i)
data<-append(data,toString(row[[i]]))
}
body = sprintf('{"tablename":"scoreInput","header":%s,"data":[%s]}',toJSON(header),toJSON(data))
r <- POST(url, body = body, encode="json",accept("application/json"),content_type("application/json"))
content_list <- content(r)
header <- c()
data <- c()
results<-append(results,content_list[[1]]$data[[1]][[21]])
}
results<-data.frame(cbind(results))
modelerData<-cbind(modelerData,results)
#print(modelerData)
X21<-c(fieldName="GAME_STYLE_ID",fieldLabel="",fieldStorage="string",fieldFormat="",fieldMeasure="",fieldRole="none")
modelerDataModel<-data.frame(modelerDataModel,X21)
ibmspsscfdatamodel.SetDataModel(modelerDataModel)
ibmspsscfdata.SetDataToTemp(modelerData)


Loading required package: jsonlite
Loading required package: httr
Loading required package: xml2
Error in content_list[[1]]$data :
$ operator is invalid for atomic vectors
Error in data.frame(..., check.names = FALSE) :
arguments imply differing number of rows: 1650, 0
Error: IBM SPSS CF error: The error code is '1012' With message 'Data and data model does not match.'

watsonml spss stream

watsonml node setup spss stream

watsonml service models

Tmp credentials for the setup:
{
"url": "https://palblyp.pmservice.ibmcloud.com/pm/v1",
"access_key": "iGII4hMmzqA2S1r4EhQfKZohS37Gp+Mg0M5mgtaTZXbxtBkuVEaJWZ+7UAsRBycGpvelDBj2EWArRQzCnErs5G6xF7OPG2R5H0oB0w5syog=",
"username": "4b4f5da2-ed7a-470a-b7a2-6caab793dd66",
"password": "db88162f-d898-41fc-8dc4-35cb8fa69bd6"
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions