Palo Alto library checkouts and linear regression

# Palo Alto library checkout statistics # http://data.cityofpaloalto.org/dataviews/75948/palo-alto-city-library-checkout-statistics/ import numpy as np library_checkout_statistics_palo_alto = np.array([ (2016, 1400926), (2015, 1499406), (2014, 1364872), (2013, 1512975), (2012, 1559932), (2011, 1476648), (2010, 1624785), (2009, 1633955), (2008, 1542116), (2007, 1414509), (2006, 1280547), (2005, 1282888), (2004, 1314790), (2003, 1240099), (2002, 1117795), (2001, 975665), (2000, 926128), (1999, 962646), (1998, 1023439), (1997, 1024140), (1996, 1022427), (1995, 1002334), (1994, 982452), (1993, 939375), (1992, 1064437), (1991, 1041312), (1990, 1007963), (1989, 964334), (1988, 989024), (1987, 898730), (1986, 796468), (1985, 721567), (1984, 680427), (1983, 684467), (1982, 616596) ]) X = library_checkout_statistics_palo_alto[:,0].reshape(-1,1) y = library_checkout_statistics_palo_alto[:,1] from sklearn.linear_model import LinearRegression lr = LinearRegression() lr.fit(X, y) print('Expected Palo Alto library checkouts for 2017: %d' % (int(lr.predict(2017)[0]))) # Expected Palo Alto library checkouts for 2017: 1596727
The number of checkouts in the Palo Alto library over time