shogun icon indicating copy to clipboard operation
shogun copied to clipboard

Expose LeastAngleRegression::get_w_for_var() to interfaces

Open gf712 opened this issue 5 years ago • 3 comments

The functionality from LeastAngleRegression::get_w_for_var(int32_t) is currently hidden from the user. This class function must be wrapped with a watch_method call somehow that allows a user to .get("w_for_var", idx). That should be doable with the current framework @karlnapf?

gf712 avatar Mar 29 '20 13:03 gf712

currently, this is only supported without function arguments

watch_method("w_for_var", &LeastAngleRegression::get_w_for_var);

will not work out of the box. We could add this for functions with an index argument in theory. But I fear that if we keep on adding special cases, this makes the interfaces more and more cluttered. What is wrong with getting all weights at once? and then selecting the appropriate one?

karlnapf avatar Mar 29 '20 13:03 karlnapf

@karlnapf the problem is that it isn't that straightforward because it does some processing

SGVector<float64_t> get_w_for_var(int32_t num_var)
{
	SGVector<float64_t> w = get_w();
	return SGVector<float64_t>(
		m_beta_path[m_beta_idx[num_var]].vector, w.vlen, false);
}

I guess this does some sort of sorting? We could just do this for all coefficients [0, ..., N] and return that matrix?

gf712 avatar Mar 29 '20 16:03 gf712

ah but the dimensionality will be different or? If not, then the matrix should be fine. If so .... then we could add watch_method for methods with a single index argument ...

karlnapf avatar Mar 29 '20 17:03 karlnapf