slise.initialisation
This script contains functions for initialising alpha and beta in SLISE.
fast_lstsq(x, y, weight=None, max_iterations=300)
A fast version of least squares that falls back to optimisation if the input size is too large.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
ndarray
|
Data matrix. |
required |
y |
ndarray
|
Response vector. |
required |
weight |
Optional[ndarray]
|
Weight vector for the data items. Defaults to None. |
None
|
max_iterations |
int
|
The number of iterations to use in case of optimisation. Defaults to 300. |
300
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: vector of coefficients |
Source code in slise/initialisation.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
|
initialise_lasso(X, Y, epsilon=0.0, weight=None, max_iterations=300, **kwargs)
Initialise alpha
and beta
to be equivalent to LASSO.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
ndarray
|
Data matrix. |
required |
Y |
ndarray
|
Response vector. |
required |
epsilon |
float
|
The error tolerance. Defaults to 0. |
0.0
|
weight |
Optional[ndarray]
|
Weight vector for the data items. Defaults to None. |
None
|
max_iterations |
int
|
The number of iterations to use in case of optimisation. Defaults to 300. |
300
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, float]
|
Tuple[np.ndarray, float]: |
Source code in slise/initialisation.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
initialise_ols(X, Y, epsilon, weight=None, beta_max=20.0, max_approx=1.15, max_iterations=300, beta_max_init=2.5, min_beta_step=1e-08, **kwargs)
Initialise alpha
to OLS and beta
to slise.optimisation.next_beta.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
ndarray
|
Data matrix. |
required |
Y |
ndarray
|
Response vector. |
required |
epsilon |
float
|
The error tolerance. Defaults to 0. |
required |
weight |
Optional[ndarray]
|
Weight vector for the data items. Defaults to None. |
None
|
beta_max |
float
|
The stopping sigmoid steepness. Defaults to 20. |
20.0
|
max_approx |
float
|
Approximation ratio when selecting the next beta. Defaults to 1.15. |
1.15
|
max_iterations |
int
|
The number of iterations to use in case of optimisation. Defaults to 300. |
300
|
beta_max_init |
float
|
Maximum beta. Defaults to 2.5. |
2.5
|
min_beta_step |
float
|
Minimum beta. Defaults to 1e-8. |
1e-08
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, float]
|
Tuple[np.ndarray, float]: |
Source code in slise/initialisation.py
61 62 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 |
|
initialise_zeros(X, Y, epsilon, weight=None, beta_max=20.0, max_approx=1.15, beta_max_init=2.5, min_beta_step=1e-08, **kwargs)
Initialise alpha
to 0 and beta
to slise.optimisation.next_beta.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
ndarray
|
Data matrix. |
required |
Y |
ndarray
|
Response vector. |
required |
epsilon |
float
|
The error tolerance. Defaults to 0. |
required |
weight |
Optional[ndarray]
|
Weight vector for the data items. Defaults to None. |
None
|
beta_max |
float
|
The stopping sigmoid steepness. Defaults to 20. |
20.0
|
max_approx |
float
|
Approximation ratio when selecting the next beta. Defaults to 1.15. |
1.15
|
beta_max_init |
float
|
Maximum beta. Defaults to 2.5. |
2.5
|
min_beta_step |
float
|
Minimum beta. Defaults to 1e-8. |
1e-08
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, float]
|
Tuple[np.ndarray, float]: |
Source code in slise/initialisation.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 |
|
initialise_fixed(init, X, Y, epsilon, weight=None, beta_max=20.0, max_approx=1.15, beta_max_init=2.5, min_beta_step=1e-08)
Initialise alpha
and beta
to the given values (or slise.optimisation.next_beta if beta
is not given).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
init |
Union[ndarray, Tuple[ndarray, float]]
|
The fixed |
required |
X |
ndarray
|
Data matrix. |
required |
Y |
ndarray
|
Response vector. |
required |
epsilon |
float
|
The error tolerance. Defaults to 0. |
required |
weight |
Optional[ndarray]
|
Weight vector for the data items. Defaults to None. |
None
|
beta_max |
float
|
The stopping sigmoid steepness. Defaults to 20. |
20.0
|
max_approx |
float
|
Approximation ratio when selecting the next beta. Defaults to 1.15. |
1.15
|
beta_max_init |
float
|
Maximum beta. Defaults to 2.5. |
2.5
|
min_beta_step |
float
|
Minimum beta. Defaults to 1e-8. |
1e-08
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, float]
|
Tuple[np.ndarray, float]: |
Source code in slise/initialisation.py
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 |
|
initialise_candidates(X, Y, epsilon, weight=None, beta_max=20.0, max_approx=1.15, pca_treshold=10, num_init=None, max_iterations=300, beta_max_init=2.5, min_beta_step=1e-08, **kwargs)
Generate a number (num_init) of candidates, using PCA to shrink the random subsets.
Then select the best one to be alpha
and beta
to be the corresponding slise.optimisation.next_beta.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
ndarray
|
Data matrix. |
required |
Y |
ndarray
|
Response vector. |
required |
epsilon |
float
|
The error tolerance. Defaults to 0. |
required |
weight |
Optional[ndarray]
|
Weight vector for the data items. Defaults to None. |
None
|
beta_max |
float
|
The stopping sigmoid steepness. Defaults to 20. |
20.0
|
max_approx |
float
|
Approximation ratio when selecting the next beta. Defaults to 1.15. |
1.15
|
pca_treshold |
int
|
Treshold number of dimension to use PCA. Defaults to 10. |
10
|
num_init |
int
|
Number of candidates to generate. Defaults to 500. |
None
|
max_iterations |
int
|
The number of iterations to use in case of optimisation. Defaults to 300. |
300
|
beta_max_init |
float
|
Maximum beta. Defaults to 2.5. |
2.5
|
min_beta_step |
float
|
Minimum beta. Defaults to 1e-8. |
1e-08
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, float]
|
Tuple[np.ndarray, float]: |
Source code in slise/initialisation.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
|
initialise_candidates2(X, Y, epsilon, weight=None, beta_max=20.0, max_approx=1.15, num_init=None, max_iterations=300, beta_max_init=2.5, min_beta_step=1e-08, **kwargs)
Generate a number (num_init) of candidates, using LASSO to shrink the random subsets.
Then select the best one to be alpha
and beta
to be the corresponding slise.optimisation.next_beta.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X |
ndarray
|
Data matrix. |
required |
Y |
ndarray
|
Response vector. |
required |
epsilon |
float
|
The error tolerance. Defaults to 0. |
required |
weight |
Optional[ndarray]
|
Weight vector for the data items. Defaults to None. |
None
|
beta_max |
float
|
The stopping sigmoid steepness. Defaults to 20. |
20.0
|
max_approx |
float
|
Approximation ratio when selecting the next beta. Defaults to 1.15. |
1.15
|
num_init |
int
|
Number of candidates to generate. Defaults to 500. |
None
|
max_iterations |
int
|
The number of iterations to use in case of optimisation. Defaults to 300. |
300
|
beta_max_init |
float
|
Maximum beta. Defaults to 2.5. |
2.5
|
min_beta_step |
float
|
Minimum beta. Defaults to 1e-8. |
1e-08
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, float]
|
Tuple[np.ndarray, float]: |
Source code in slise/initialisation.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
|