h2o Steam Prediction Servlet not accepting character values from python script - h2o

I am using Steam to attempt to build a prediction service using a python preprocessing script. When python passes the cleaned data to the prediction service in the
variable:value var2:value2 var3:value3
format (as seen in the Spam Detection Example) I get a
ERROR PredictPythonServlet - Failed to parse
error from the service. When I look at the PredictPythonServlet.java file it seems to only use the strMapToRowData function which assumes every value in the input string is a number:
for (String p : pairs) {
String[] a = p.split(":");
String term = a[0];
double value = Float.parseFloat(a[1]);
row.put(term, value);
}
Are character values not allowed to be sent in this format? If so is there a way to get the PredictPythonServlet file to use the csvToRowData function that is defined but never used? I'd like to not have to use One-Hot encoding for my models so being able to pass the actual character string representation would be ideal.
Additionally, I passed the numeric representation found in the model pojo file for the categorical variables and received the error:
hex.genmodel.easy.exception.PredictUnknownTypeException: Unexpected object type java.lang.Double for categorical column home_team
So it looks like the service expects a character string but I can't figure out how to pass it along to the actual model. Any help would be greatly appreciated!

The prediction service is using EasyPredictModelWrapper and it can only use what the underlying model uses. Here it's not clear what model you use, but most use numerical float values. In the for loop code snippet you can see that the number has to be float.

Related

Assign Signal names dynamically from a String in CAPL

I have a string that stores a signal name extracted from an excel file.
I want to dynamically assign the name of the signal using the string, if I have many such signals.
For example, if I have a signal called 'speed' in my dbc file, and I have a string that stores 'speed', I need to set the value of signal 'speed' as 100.
variable
{
message BCM BCM;
char signal[100]= "speed";
}
on message *
{
$signal= 100;
}
The error I get is:
Error: Identifier 'signal' does not have a signal type.
Is there a workaround to this problem, such that I can convert the string into a signal name by some means?
You are mixing the variable formats like this. The only object on which you can use $ is dbSignal type. What you would need is a function like getSignal(dbSignal name);, but with char[] parameter.
Sadly, Vector did not implement such workaround, leaving you the only option to pass your signal strings by testcase parameters (if you are using XML Test nodes).
Since, I presume you have too many, I suggest you write a script in another scripting language constructing the text of the .can file itself, filling the place of dbsignals with the strings from the excel, then use the .can file for testing/simulation.

Difference between `normalize` and `parse` callbacks in redux-form

The current redux-form documentation (version 6.5.0 at the time of this writing) mentions 2 callbacks for the Field object: normalize and parse.
Both descriptions sound pretty similar: They take the value entered by the user in an input field and transform it to a value stored in redux.
What's the difference between these 2 callbacks?
Essentially the two functions do exactly the same thing, i.e. take the value a user has input to the Field and transform it before it's stored in the redux store.
The differences lie in the flavor of these functions and the order in which they are called:
parse parses the string input value should convert it to the type you want to be stored the redux store, for example you parse a date string from a datepicker into a Date object
normalize is meant enforce certain formatting of input values in the redux store, for example ensuring that phone numbers are stored in a cohesive format
When it comes to the order in which these methods are called in the redux-form value lifecycle: parse is called before normalize, which means normalize is called with the parsed input value.
So in short, use parse to convert user input (usually in string form) to a type that suits your needs. Use normalize to enforce a specific input format on the user.
This is what the Value Lifecycle Hooks page tries to explain.

MATLAB ConnectedComponentLabeler does not work in for loop

I am trying to get a set of binary images' eccentricity and solidity values using the regionprops function. I obtain the label matrix using the vision.ConnectedComponentLabeler function.
This is the code I have so far:
files = getFiles('images');
ecc = zeros(length(files)); %eccentricity values
sol = zeros(length(files)); %solidity values
ccl = vision.ConnectedComponentLabeler;
for i=1:length(files)
I = imread(files{i});
[L NUM] = step(ccl, I);
for j=1:NUM
L = changem(L==j, 1, j); %*
end
stats = regionprops(L, 'all');
ecc(i) = stats.Eccentricity;
sol(i) = stats.Solidity;
end
However, when I run this, I get an error says indicating the line marked with *:
Error using ConnectedComponentLabeler/step
Variable-size input signals are not supported when the OutputDataType property is set to 'Automatic'.'
I do not understand what MATLAB is talking about and I do not have any idea about how to get rid of it.
Edit
I have returned back to bwlabel function and have no problems now.
The error is a bit hard to understand, but I can explain what exactly it means. When you use the CVST Connected Components Labeller, it assumes that all of your images that you're going to use with the function are all the same size. That error happens because it looks like the images aren't... hence the notion about "Variable-size input signals".
The "Automatic" property means that the output data type of the images are automatic, meaning that you don't have to worry about whether the data type of the output is uint8, uint16, etc. If you want to remove this error, you need to manually set the output data type of the images produced by this labeller, or the OutputDataType property to be static. Hopefully, the images in the directory you're reading are all the same data type, so override this field to be a data type that this function accepts. The available types are uint8, uint16 and uint32. Therefore, assuming your images were uint8 for example, do this before you run your loop:
ccl = vision.ConnectedComponentLabeler;
ccl.OutputDataType = 'uint8';
Now run your code, and it should work. Bear in mind that the input needs to be logical for this to have any meaningful output.
Minor comment
Why are you using the CVST Connected Component Labeller when the Image Processing Toolbox bwlabel function works exactly the same way? As you are using regionprops, you have access to the Image Processing Toolbox, so this should be available to you. It's much simpler to use and requires no setup: http://www.mathworks.com/help/images/ref/bwlabel.html

What kind of encoding does posFlag requires?

How can I encode the position of the form /pathto/file.go:40:32 which is returned by token.Position.String() to a posFlag param required by ParseQueryPos which looks like /pathto/file.go:#550.
Why?
I'm using the Oracle tool to do some static analysis. I need to run Oracle.Query which requires a param of type *QueryPos. The only way to get *QueryPos is using ParseQueryPos.
The source to tools/pos.go called by ParseQueryPos says
// parsePosFlag parses a string of the form "file:pos" or
// file:start,end" where pos, start, end match #%d and represent byte
// offsets, and returns its components.
If you really had to convert from line:column strings, you'd look at the file contents and count up bytes (including newlines) leading to that line:column. But since you're working with a token.Position, it looks like you can get what you need from token.Position.Offset.

Whether it is possible in Microsoft. Office. Interop. Outlook.userproperties to add an array

Whether it is possible in Microsoft.Office.Interop.Outlook.UserProperties to add an array/list of integer numbers and how? Usage of type OlUserPropertyType.olEnumeration leads to an exception at a stage of adding of the parameter.
There is no array support in the MAPI-supported user properties. You would have to serialize the array to a string - OlUserPropertyType.OlText (PT_STRING8) using some serialized array format (XML, CSV, JSON, etc.).

Resources