Created
April 19, 2012 15:26
-
-
Save beaucronin/2421682 to your computer and use it in GitHub Desktop.
Veritable uncertainty quantification examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pr = analysis.predict({'petal_length': 1.5, 'petal_width': None}) | |
interval = pr.credible_values('petal_width') | |
# => (0.06619570898596525, 0.45519138428493605) | |
interval[1] - interval[0] | |
# => 0.38899567529897083 | |
pr = analysis.predict({'petal_length': 5.0, 'petal_width': None}) | |
interval = pr.credible_values('petal_width') | |
# => (1.3341578189754613, 2.4761532421771784) | |
interval[1] - interval[0] | |
# => 1.141995423201717 | |
# Answer: different petal lengths lead to different degrees of uncertainty about petal width. | |
# Veritable is able to model this kind of "heteroskedastic" relationship because the model it | |
# learns can include various kinds of nonlinearities. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query1 = { | |
'petal_length': 1.5, | |
'sepal_length': None, | |
'sepal_width': None } | |
pr1 = analysis.predict(query1) | |
pr1.credible_values('sepal_length') | |
# => (4.334787896697201, 5.639183256498405) | |
pr1.credible_values('sepal_width') | |
# => (2.7258301944595824, 4.1180270245192565) | |
query2 = { | |
'petal_length': 1.5, | |
'petal_width': 0.2, | |
'sepal_length': None, | |
'sepal_width': None } | |
pr2 = analysis.predict(query2) | |
pr2.credible_values('sepal_length') | |
# => (4.468544865668935, 5.67907462278871) | |
pr2.credible_values('sepal_width') | |
# => (2.7279822552513515, 4.113270938023062) | |
# At least for these particular petal dimensions, petal width does not seem to add much in | |
# the way of uncertainty reduction. That is, once you know that it's a short petal, also | |
# knowing that it's skinny doesn't provide much more. Of course, measuring both variables | |
# might be important in other cases --- and if so, Veritable will identify these relationships | |
# too. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
query = { | |
'class': 'Iris-setosa', | |
'petal_length': None, | |
'petal_width': None, | |
'sepal_length': None, | |
'sepal_width': None } | |
pr = analysis.predict(query) | |
pr.credible_values('petal_length') | |
# => (1.0413860198602414, 1.8600456565417642) | |
pr.credible_values('petal_width') | |
# => (0.11534704664999318, 0.49745028429888877) | |
pr.credible_values('sepal_length') | |
# => (4.430450802336802, 5.885512229758362) | |
pr.credible_values('sepal_width') | |
# => (2.6854970916482346, 3.9249199743156242) | |
# These represent the credible range of dimensions for a synthetic population of setosa flowers. | |
# Veritable's predictions can be used in a number of ways to generate and learn from synthetic | |
# populations; we'll say more about this in future posts. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment