GaussianProductOp.ProductAverageConditional - has quality band Experimental which is less than the recommended quality band (Preview) - infer.net

I have a quite simple rule and I get already the quality band issue. Can someone explain why this is happening? I have read the docs about Quality bands but I don't understand it.
This is the code I wrote that produces the warning:
Gaussian BornYoungPerLitterDist = new Gaussian(5.5, 0);
Gaussian BirthRateDist = new Gaussian(0.004102103451, 0.00000144);
Variable<double> BornYoungPerLitter = Variable.Random<double, Gaussian>(BornYoungPerLitterDist);
Variable<double> Birthrate = Variable.Random<double, Gaussian>(BirthRateDist);
InferenceEngine engine = new InferenceEngine();
Gaussian Born = engine.Infer<Gaussian>(BornYoungPerLitter * Birthrate);
Console.WriteLine(
"Born Mean: {0:f10}, Standard Deviation: {1:f10}",
Born.GetMean(),
Math.Sqrt(Born.GetVariance())
);
the warning is:
Compiling model...compilation had 1 warning(s).
[1] GaussianProductOp.ProductAverageConditional(vdouble2_use_B, vGaussian0, vGaussian1) has quality band Experimental which is less than the recommended quality band (Preview)

This question was answered on the Github repository from Infer.Net.
On date January 2019 the feature is still in development and for that always throws the warning.
This happens because the code that implements a product of Gaussian variables (GaussianProductOp) is in an early stage of development. If you want to disable the model compiler errors and/or the warnings, set the options on engine.Compiler.
https://github.com/dotnet/infer/issues/104

Related

What meta learners are used by h2o.automl() to build the ensembles?

I am wondering what meta learners are used by h2o.automl() to build the ensembles. So far all the ensembles I've seen were GLMs. Is it because h2o.automl() uses only glm as the meta learner or due to the limited number of base models (25 -50 with my setting), glm is always the best choice?
Thank you.
H2OAutoML uses GLM as a default metalearner algo, and we're not currently trying multiple metalearners to find the best one (this may change in future releases).
For now, you can train a different ensemble using the autoML models as base models:
aml = H2OAutoML(project_name="my_aml",
...,
keep_cross_validation_predictions=True) # important if you want to stack the models later
aml.train(...)
# train another ensemble using GBM as algo metalearner
lb = aml.leaderboard
base_models = [m for m in [lb[i,0] for i in range(lb.nrows)]
if 'StackedEnsemble' not in m]
se = h2o.estimators.H2OStackedEnsembleEstimator(
base_models=base_models,
metalearner_algorithm='gbm',
...
)

Parameters for dlib::find_min_bobyqa

I'm working on the C++ version of Matt Zucker's Page dewarping. So far everything works fine, but I have a problem with optimization. In line 748 of Github repo Matt uses optimize function from Scipy. My C++ equivalent is find_min_bobyqa from dlib.net. The code is:
auto f = [&](const column_vector& ppts) { return objective( dstpoints, ppts, keypoint_index); };
dlib::find_min_bobyqa(f,
params,
2 * params.nr() + 1, // npt - number of interpolation points: x.size() + 2 <= npt && npt <= (x.size()+1)*(x.size()+2)/2
dlib::uniform_matrix<double>(params.nr(), 1, -2), // lower bound constraint
dlib::uniform_matrix<double>(params.nr(), 1, 2), // upper bound constraint
1, // initial trust region radius
1e-5, // stopping trust region radius
4000 // max number of objective function evaluations
);
In my concrete example params is a dlib::column_vector with double values and length = 189. Every element of params is less than 2.0 and greater than -2.0. Function objective() returns double value and "alone" it works properly because I get the same value as in the Python version. But after running fin_min_bobyqa function I usually get the message:
Terminate called after throwing an instance of 'dlib:bobyqa_failure', return from BOBYQA because the objective function has been called max_f_evals times.
I set max_f_evals to quite big value to see if it optimizes at all, but it doesn't. I did some tweaking with parameters but without good results. How should I set the parameters of find_min_bobyqa to get the right solution?
I am very interested in this issue as well. Zucker's work, with very minor tweaks, is ideal for straightening sheet music images, and I was looking for ways to implement it in a mobile platform when I came across your question.
My research so far suggests that BOBYQA is not the equivalent of Powell's method in scipy. BOBYQA is constrained, and the one in scipy is not.
See these links for more information, and a possible way to compile the right supporting library - I would try UOBYQA or NEWUOA.
https://github.com/jacobwilliams/PowellOpt
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html#rdd2e1855725e-3
(See the Notes section)
EDIT: see C version here:
https://github.com/emmt/Algorithms/tree/master/newuoa
I wanted to post this as a comment, but I don't have enough points for that.
I am very interested in your progress. If you're willing, please keep me posted.
I finally solved this problem. I used PRAXIS library, because it doesn't need derivative information and is fast.
I modified the code a little to my needs and now it is faster around few seconds than original version written in Python.

xgboost implementation in h2o offset

I have been accustomed to use the base margin parameter in standard xgboost to allow for offset, starting (transformed) prediction (see this SO question SO xgboost exposure question. I wonder if it were possible to perform the same in the h2o implementation of xgboost. In particular I see an offset parameter, but I wonder wether it has been really truly implemented.
Good question -- this is not documented in the parameter description (we use a common definition of offset_column among all algos and there's no note about how its not working in XGBoost). It is not functional and you should get an error if you try to supply it.
R example:
library(h2o)
h2o.init()
fit <- h2o.xgboost(x = 1:3, y = "Species", offset_column = "Petal.Width",
training_frame = as.h2o(iris))
Gives error:
Error: water.exceptions.H2OModelBuilderIllegalArgumentException: Illegal argument(s) for XGBoost model: XGBoost_model_R_1520909592004_2. Details: ERRR on field: _offset_column: Offset is not supported for XGBoost.

Save a figure to file with specific resolution

In an old version of my code, I used to do a hardcopy() with a given resolution, ie:
frame = hardcopy(figHandle, ['-d' renderer], ['-r' num2str(round(pixelsperinch))]);
For reference, hardcopy saves a figure window to file.
Then I would typically perform:
ZZ = rgb2gray(frame) < 255/2;
se = strel('disk',diskSize);
ZZ2 = imdilate(ZZ,se); %perform dilation.
Surface = bwarea(ZZ2); %get estimated surface (in pixels)
This worked until I switched to Matlab 2017, in which the hardcopy() function is deprecated and we are left with the print() function instead.
I am unable to extract the data from figure handler at a specific resolution using print. I've tried many things, including:
frame = print(figHandle, '-opengl', strcat('-r',num2str(round(pixelsperinch))));
But it doesn't work. How can I overcome this?
EDIT
I don't want to 'save' nor create a figure file, my aim is to extract the data from the figure in order to mesure a surface after a dilation process. I just want to keep this information and since 'im processing a LOT of different trajectories (total is approx. 1e7 trajectories), i don't want to save each file to disk (this is costly, time execution speaking). I'm running this code on a remote server (without a graphic card).
The issue I'm struggling with is: "One or more output arguments not assigned during call to "varargout"."
getframe() does not allow for setting a specific resolution (it uses current resolution instead as far as I know)
EDIT2
Ok, figured out how to do, you need to pass the '-RGBImage' argument like this:
frame = print(figHandle, ['-' renderer], ['-r' num2str(round(pixelsperinch))], '-RGBImage');
it also accept custom resolution and renderer as specified in the documentation.
I think you must specify formattype too (-dtiff in my case). I've tried this in Matlab 2016b with no problem:
print(figHandle,'-dtiff', '-opengl', '-r600', 'nameofmyfig');
EDIT:
If you need the CData just find the handle of the corresponding axes and get its CData
f = findobj('Tag','mytag')
Then depending on your matlab version use:
mycdata = get(f,'CData');
or directly
mycdta = f.CData;
EDIT 2:
You can set the tag of your image programatically and then do what I said previously:
a = imshow('peppers.png');
set(a,'Tag','mytag');

surface feature detection on image processing

An example of detectSURFFeatures in comparison of 2 image is in below. I couldn't make detectSURFFeatures function work in my MATLAB. no help or doc detectSURFFeatures gives any clue. the error says " > UncalibratedSterio
Undefined function 'detectSURFFeatures' for input arguments of type 'uint8'." but the function itself can cover uint8 as i know. what should i do?
%Rectified Sterio Image Uncalibrated
% There is no calibration of cameras
I1 = rgb2gray(imread('right_me.jpg'));
I2 = rgb2gray(imread('left_me.jpg'));
Value = 2000.0;
blobs1 = detectSURFFeatures(I1, 'MetricThreshold', Value);
blobs2 = detectSURFFeatures(I2, 'MetricThreshold', Value);
figure;
imshow(I1);
hold on;
plot(selectStrongest(blobs1, 30));
title('Thirty strongest SURF features in I1');
figure;
imshow(I2);
hold on;
plot(selectStrongest(blobs2, 30));
title('Thirty strongest SURF features in I2');
You are getting that error because detectSURFFeatures does not exist in your MATLAB distribution. You must have at least R2011b, as that was when detectSURFFeatures was available: http://www.mathworks.com/help/vision/release-notes.html#R2011b
I suspect you have an older version of MATLAB than R2011b and so if you want to make it easy on yourself, you need to upgrade your version of MATLAB. However, if I may make a suggestion, I suggest the mexopencv project by Kota Yamaguchi: http://kyamagu.github.io/mexopencv/
He wrote OpenCV wrappers that can directly interface with MATLAB and so you can actually call OpenCV's SURF feature detection and matching methods from MATLAB but you will need to install OpenCV to do that. It will be a bit of work to get it working, but this is one solution I can provide if you don't want to upgrade your version of MATLAB.
Good luck!

Resources