-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
include example dataset #63
Conversation
examples/marriage.py
Outdated
print('loading data') | ||
df = pickle.load(f) | ||
print('converting to arrays') | ||
_, (G, B, T) = convoys.utils.get_arrays(df, groups='state', created='born', converted='married') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (96 > 79 characters)
examples/marriage.py
Outdated
convoys.plotting.plot_cohorts(G, B, T, model='generalized-gamma', groups=groups) | ||
pyplot.legend() | ||
print('overlaying kaplan-meier nonparametric') | ||
convoys.plotting.plot_cohorts(G, B, T, model='kaplan-meier', groups=groups, plot_args={'linestyle': '--'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (110 > 79 characters)
examples/marriage.py
Outdated
df, groups='decade', created='born', converted='married') | ||
print('plotting generalized-gamma') | ||
pyplot.clf() | ||
convoys.plotting.plot_cohorts(G, B, T, model='generalized-gamma', groups=groups) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (84 > 79 characters)
examples/marriage.py
Outdated
for model in ['kaplan-meier', 'generalized-gamma']: | ||
print('plotting', model) | ||
pyplot.clf() | ||
convoys.plotting.plot_cohorts(G, B, T, model=model, ci=0.95, groups=groups) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
examples/marriage.py
Outdated
|
||
print('converting to arrays') | ||
_, groups, (G, B, T) = convoys.utils.get_arrays( | ||
df, groups='race', created='born', converted='married', group_min_size=100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (83 > 79 characters)
examples/dob_violations.py
Outdated
for model in ['kaplan-meier', 'weibull']: | ||
print('plotting', model) | ||
pyplot.clf() | ||
convoys.plotting.plot_cohorts(G, B, T, model=model, ci=0.95, groups=groups, t_max=30) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (93 > 79 characters)
examples/marriage.py
Outdated
convoys.plotting.plot_cohorts(G, B, T, model='generalized-gamma', groups=groups) | ||
pyplot.legend() | ||
pyplot.xlabel('Age of marriage') | ||
convoys.plotting.plot_cohorts(G, B, T, model='kaplan-meier', groups=groups, plot_args={'linestyle': '--'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (110 > 79 characters)
examples/marriage.py
Outdated
df, groups='sex', created='born', converted='married') | ||
|
||
pyplot.figure(figsize=(6, 6)) | ||
convoys.plotting.plot_cohorts(G, B, T, model='generalized-gamma', groups=groups) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (84 > 79 characters)
examples/dob_violations.py
Outdated
df, groups='bucket', created='issue_date', converted='disposition_date', | ||
unit='Years', group_min_size=500) | ||
convoys.plotting.plot_cohorts(G, B, T, model='kaplan-meier', groups=groups, t_max=30) | ||
convoys.plotting.plot_cohorts(G, B, T, model='weibull', groups=groups, t_max=30, plot_args={'linestyle': '--'}, ci=0.95) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (124 > 79 characters)
examples/dob_violations.py
Outdated
unit, groups, (G, B, T) = convoys.utils.get_arrays( | ||
df, groups='bucket', created='issue_date', converted='disposition_date', | ||
unit='Years', group_min_size=500) | ||
convoys.plotting.plot_cohorts(G, B, T, model='kaplan-meier', groups=groups, t_max=30) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (89 > 79 characters)
examples/dob_violations.py
Outdated
pyplot.figure(figsize=(9, 6)) | ||
df['bucket'] = df['issue_date'].apply(lambda d: '%d-%d' % (5*(d.year//5), 5*(d.year//5)+4)) | ||
unit, groups, (G, B, T) = convoys.utils.get_arrays( | ||
df, groups='bucket', created='issue_date', converted='disposition_date', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (80 > 79 characters)
examples/dob_violations.py
Outdated
pyplot.savefig('dob-violations-%s.png' % model) | ||
|
||
pyplot.figure(figsize=(9, 6)) | ||
df['bucket'] = df['issue_date'].apply(lambda d: '%d-%d' % (5*(d.year//5), 5*(d.year//5)+4)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (95 > 79 characters)
examples/dob_violations.py
Outdated
for model in ['kaplan-meier', 'weibull']: | ||
print('plotting', model) | ||
pyplot.figure(figsize=(9, 6)) | ||
convoys.plotting.plot_cohorts(G, B, T, model=model, ci=0.95, groups=groups, t_max=30) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (93 > 79 characters)
examples/dob_violations.py
Outdated
lambda d: '%d-%d' % (5*(d.year//5), 5*(d.year//5)+4) | ||
) | ||
unit, groups, (G, B, T) = convoys.utils.get_arrays( | ||
df, groups='bucket', created='issue_date', converted='disposition_date', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line too long (80 > 79 characters)
18f8fd2
to
6c065fe
Compare
Fitting it with a generalized gamma distribution and it works pretty well