Created
October 5, 2015 11:50
-
-
Save akx/c346b9651b7fb1e82947 to your computer and use it in GitHub Desktop.
Python 4.0 prediction
This file contains hidden or 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
| from dateparser import parse | |
| import numpy as np | |
| import datetime | |
| data_points = [] | |
| for l in """ | |
| 1.4 25 October 1996 | |
| 1.5 17 February 1998 | |
| 2.0 16 October 2000 | |
| 2.5 19 September 2006 | |
| 2.7 4 July 2010 | |
| 3.4 16 March 2014 | |
| """.strip().splitlines(): | |
| v, d = l.strip().split("\t") | |
| data_points.append((float(v), parse(d).date().toordinal())) | |
| data = np.array(data_points) | |
| fit = np.polyfit(data[:,0], data[:,1], 1) | |
| new_ordinal = np.poly1d(fit)([4.0]) | |
| print datetime.date.fromordinal(new_ordinal) | |
| # >>> 2020-06-01 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment