harbor run -t openthoughts/tasktrove-exp-rpt-issue-issue-2562harbor download openthoughts/tasktrove-exp-rpt-issue-issue-2562Problem description
What to implement
Files to modify (2 target files)
Before state (code snippets) Note: The snippets below show the "before" state from the patch (i.e., how the code looked prior to the fix). You should implement the corresponding changes so that the new behavior is available.
class SparseCoder(BaseEstimator, SparseCodingMixin):
...
def __init__(self, dictionary, transform_algorithm='omp',
transform_n_nonzero_coefs=None, transform_alpha=None,
split_sign=False, n_jobs=None, positive_code=False):
self._set_sparse_coding_params(dictionary.shape[0],
transform_algorithm,
transform_n_nonzero_coefs,
transform_alpha, split_sign, n_jobs,
positive_code)
self.components_ = dictionary
def _set_sparse_coding_params(self, n_components,
transform_algorithm, transform_n_nonzero_coefs,
transform_alpha, split_sign, n_jobs,
positive_code):
self.n_components = n_components
self.transform_algorithm = transform_algorithm
self.transform_n_nonzero_coefs = transform_n_nonzero_coefs
self.transform_alpha = transform_alpha
self.split_sign = split_sign
self.n_jobs = n_jobs
self.positive_code = positive_code
code = sparse_encode(
X, self.components_, algorithm=self.transform_algorithm,
n_nonzero_coefs=self.transform_n_nonzero_coefs,
alpha=self.transform_alpha, n_jobs=self.n_jobs,
positive=self.positive_code)
lasso_lars = LassoLars(alpha=alpha, fit_intercept=False,
verbose=verbose, normalize=False,
precompute=gram, fit_path=False,
positive=positive)
lasso_lars.fit(dictionary.T, X.T, Xy=cov)
new_code = lasso_lars.coef_
max_iter : int, 1000 by default
Maximum number of iterations to perform if `algorithm='lasso_cd'`.
code = sparse_encode(X, dictionary, algorithm=method, alpha=alpha,
init=code, n_jobs=n_jobs, positive=positive_code)
def dict_learning(X, n_components, alpha, max_iter=100, tol=1e-8,
transform_algorithm='omp', transform_n_nonzero_coefs=None,
transform_alpha=None, n_jobs=None, dict_init=None,
code_init=None, verbose=False, random_state=None,
return_n_iter=False, positive_dict=False,
positive_code=False):
What you will implement (the expected behavior)
Acceptance criteria
How to implement (high level steps)
Notes
Files to create/modify in /app/
Provide the modified code implementing the changes in those two files, ensuring the before-state blocks above are preserved in the task description (as shown) and the new behavior is implemented in the /app/ copy.