autora.experimentalist.model_disagreement
sample(conditions, models, num_samples=1)
A experimentalist that returns selected samples for independent variables for which the models disagree the most in terms of their predictions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
conditions |
Union[DataFrame, ndarray]
|
pool of IV conditions to evaluate in terms of model disagreement |
required |
models |
List
|
List of Scikit-learn (regression or classification) models to compare |
required |
num_samples |
int
|
number of samples to select |
1
|
Returns: Sampled pool
Source code in temp_dir/disagreement/src/autora/experimentalist/model_disagreement/__init__.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
score_sample(conditions, models, num_samples=None)
A experimentalist that returns selected samples for independent variables for which the models disagree the most in terms of their predictions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
conditions |
Union[DataFrame, ndarray]
|
pool of IV conditions to evaluate in terms of model disagreement |
required |
models |
List
|
List of Scikit-learn (regression or classification) models to compare |
required |
num_samples |
Optional[int]
|
number of samples to select |
None
|
Returns: Sampled pool
Examples:
If a model is undefined at a certain condition, the disagreement on that point is set to 0:
>>> class ModelUndefined:
... def predict(self, X):
... return np.log(X)
>>> class ModelDefinined:
... def predict(self, X):
... return X
>>> modelUndefined = ModelUndefined()
>>> modelDefined = ModelDefinined()
>>> conditions_defined = np.array([1, 2, 3])
>>> score_sample(conditions_defined, [modelUndefined, modelDefined], 3)
0 score
2 3 1.364948
1 2 -0.362023
0 1 -1.002924
>>> conditions_undefined = np.array([-1, 0, 1, 2, 3])
>>> score_sample(conditions_undefined, [modelUndefined, modelDefined], 5)
0 score
4 3 1.752985
3 2 0.330542
2 1 -0.197345
0 -1 -0.943091
1 0 -0.943091
Source code in temp_dir/disagreement/src/autora/experimentalist/model_disagreement/__init__.py
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 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 |
|