Reference for coalescent approach in multitask learning
bmm_multitask_learning.coalescent
coalescent_inference
CoalescentTree
Source code in bmm_multitask_learning/coalescent/coalescent_inference.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |
iterate_over()
iterates over all elements in tree
Source code in bmm_multitask_learning/coalescent/coalescent_inference.py
68 69 70 71 72 73 74 | |
select_candidates(x, cov, t_m1, n, dim)
staticmethod
Realise greedy selection of candidates to coalesce. For this consider all pairs of items and select minimal delta for coalesce
More details in [2]
Source code in bmm_multitask_learning/coalescent/coalescent_inference.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
Item
dataclass
class to handle the items of coalescent_tree
Source code in bmm_multitask_learning/coalescent/coalescent_inference.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
coalesce(first, other, t)
staticmethod
This method coalesces two Item objects. Works for brownian diffusion. For more see [2]
[2] Y.W. Teh, H. Dauḿe III, and D. Roy. Bayesian agglomerative clustering with coalescents. NIPS, 2007.
Source code in bmm_multitask_learning/coalescent/coalescent_inference.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
optimal_t(first, other, cov, i, t_m1, n, dim)
staticmethod
computes optimal delta to coalesce for proposed pair of items
Source code in bmm_multitask_learning/coalescent/coalescent_inference.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | |
coalescent_learner
MultitaskProblem
bayessian optimizer for Multitask Learning based on Coalescent [1]
To use initialize with list of TaskData and call run. Then trained weights will be available by method get_weights()
[1] @article{daume2009bayesian, title={Bayesian multitask learning with latent hierarchies}, author={Daum{'e} III, Hal}, journal={arXiv preprint arXiv:0907.0783}, year={2009} }
Source code in bmm_multitask_learning/coalescent/coalescent_learner.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | |
__init__(tasks, dim, rho=0.05, cov_sigma=0.1, s_init=None)
:param tasks: list of TaskData, which will be learned :param dim: dimention of problems :param rho: parameter that scales noise level in labels :param cov_sigma: covariance matrix scaler for Coalescent evolution variation :param s_init: initial values for S_i: variance scales of data
Source code in bmm_multitask_learning/coalescent/coalescent_learner.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | |
S_handler
class to incapsulate the methods for updating covariance scalers S
Source code in bmm_multitask_learning/coalescent/coalescent_learner.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
log_prob_S(s, R_inv, L_inv, P, W)
returns the log probability of proposed parameters for S
Source code in bmm_multitask_learning/coalescent/coalescent_learner.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
inverse_wishart
InverseWishart
class to handle methods of InverseWishart distribution
Source code in bmm_multitask_learning/coalescent/inverse_wishart.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
__init__(d, degrees_of_freedom, init_cov=None, corr_mat=False)
:param d: dimension of the covariance matrix :param degrees_of_freedom: degrees of freedom of the inverse Wishart distribution :param init_cov: initial covariance matrix :param corr_mat: if True, the covariance matrix is a correlation matrix (i.e., it has ones on the diagonal)
Source code in bmm_multitask_learning/coalescent/inverse_wishart.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
cov2corr(cov)
staticmethod
Conver covariance matrox to correlation matrix
Source code in bmm_multitask_learning/coalescent/inverse_wishart.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
get_most_prob()
returns the mode of the inverse Wishart distribution
Source code in bmm_multitask_learning/coalescent/inverse_wishart.py
59 60 61 62 63 64 65 66 67 68 | |
update_posterior(samples)
:param samples: shape=(n x d)
Source code in bmm_multitask_learning/coalescent/inverse_wishart.py
47 48 49 50 51 52 53 54 55 56 57 | |
parameters_cov
optimal_cov(coalesce_tree, dim)
retunrns samples from covariance matrix for InverseWishart distribution parameters update
Source code in bmm_multitask_learning/coalescent/parameters_cov.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
plot_coalescent
task_classes
TaskData
dataclass
Source code in bmm_multitask_learning/coalescent/task_classes.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
most_prob_w(sigma, rho)
:param sigma: cov matrix of prior of w :param rho: scaling coefficient for data
Source code in bmm_multitask_learning/coalescent/task_classes.py
11 12 13 14 15 16 17 18 19 20 21 22 | |