Skip to content
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

Merged
merged 17 commits into from
Jun 10, 2018
Merged

include example dataset #63

merged 17 commits into from
Jun 10, 2018

Conversation

erikbern
Copy link
Contributor

@erikbern erikbern commented Jun 8, 2018

Fitting it with a generalized gamma distribution and it works pretty well

image

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')

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)

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': '--'})

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)

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)

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)

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)

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)


print('converting to arrays')
_, groups, (G, B, T) = convoys.utils.get_arrays(
df, groups='race', created='born', converted='married', group_min_size=100)

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)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 92.532% when pulling e8f9010 on marriage-example into ec3b0d3 on master.

@coveralls
Copy link

coveralls commented Jun 8, 2018

Coverage Status

Coverage increased (+1.09%) to 93.548% when pulling ed6f802 on marriage-example into ec3b0d3 on master.

Erik Bernhardsson and others added 2 commits June 8, 2018 17:25
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)

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)

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': '--'})

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)

df, groups='sex', created='born', converted='married')

pyplot.figure(figsize=(6, 6))
convoys.plotting.plot_cohorts(G, B, T, model='generalized-gamma', groups=groups)

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)

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)

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)

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)

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)

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',

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)

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))

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)

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)

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)

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',

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)

@erikbern erikbern merged commit 46fbfc8 into master Jun 10, 2018
@erikbern erikbern deleted the marriage-example branch June 10, 2018 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants