Skip to content

Commit f6c4012

Browse files
committed
Pushing the docs to dev/ for branch: master, commit 2c55551d0b487705e7c4fd17205ad746df1b25d6
1 parent 7b5b95b commit f6c4012

File tree

953 files changed

+3136
-3063
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

953 files changed

+3136
-3063
lines changed

dev/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: caf8e3d0c856aa5dc00a8104a7bc5ddf
3+
config: 6c4edf2daed9c19d41ebfbca7ee68990
44
tags: 645f666f9bcd5a90fca523b33c5a78b7
871 Bytes
Binary file not shown.
834 Bytes
Binary file not shown.

dev/_downloads/plot_stock_market.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"print(__doc__)\n\n# Author: Gael Varoquaux [email protected]\n# License: BSD 3 clause\n\nimport datetime\n\nimport numpy as np\nimport matplotlib.pyplot as plt\ntry:\n from matplotlib.finance import quotes_historical_yahoo_ochl\nexcept ImportError:\n # quotes_historical_yahoo_ochl was named quotes_historical_yahoo before matplotlib 1.4\n from matplotlib.finance import quotes_historical_yahoo as quotes_historical_yahoo_ochl\nfrom matplotlib.collections import LineCollection\nfrom sklearn import cluster, covariance, manifold"
29+
"print(__doc__)\n\n# Author: Gael Varoquaux [email protected]\n# License: BSD 3 clause\n\nfrom datetime import datetime\n\nimport numpy as np\nfrom matplotlib import pyplot as plt\nfrom matplotlib.collections import LineCollection\nfrom six.moves.urllib.request import urlopen\nfrom six.moves.urllib.parse import urlencode\nfrom sklearn import cluster, covariance, manifold"
3030
]
3131
},
3232
{
@@ -44,7 +44,7 @@
4444
},
4545
"outputs": [],
4646
"source": [
47-
"# Choose a time period reasonably calm (not too long ago so that we get\n# high-tech firms, and before the 2008 crash)\nd1 = datetime.datetime(2003, 1, 1)\nd2 = datetime.datetime(2008, 1, 1)\n\n# kraft symbol has now changed from KFT to MDLZ in yahoo\nsymbol_dict = {\n 'TOT': 'Total',\n 'XOM': 'Exxon',\n 'CVX': 'Chevron',\n 'COP': 'ConocoPhillips',\n 'VLO': 'Valero Energy',\n 'MSFT': 'Microsoft',\n 'IBM': 'IBM',\n 'TWX': 'Time Warner',\n 'CMCSA': 'Comcast',\n 'CVC': 'Cablevision',\n 'YHOO': 'Yahoo',\n 'DELL': 'Dell',\n 'HPQ': 'HP',\n 'AMZN': 'Amazon',\n 'TM': 'Toyota',\n 'CAJ': 'Canon',\n 'MTU': 'Mitsubishi',\n 'SNE': 'Sony',\n 'F': 'Ford',\n 'HMC': 'Honda',\n 'NAV': 'Navistar',\n 'NOC': 'Northrop Grumman',\n 'BA': 'Boeing',\n 'KO': 'Coca Cola',\n 'MMM': '3M',\n 'MCD': 'Mc Donalds',\n 'PEP': 'Pepsi',\n 'MDLZ': 'Kraft Foods',\n 'K': 'Kellogg',\n 'UN': 'Unilever',\n 'MAR': 'Marriott',\n 'PG': 'Procter Gamble',\n 'CL': 'Colgate-Palmolive',\n 'GE': 'General Electrics',\n 'WFC': 'Wells Fargo',\n 'JPM': 'JPMorgan Chase',\n 'AIG': 'AIG',\n 'AXP': 'American express',\n 'BAC': 'Bank of America',\n 'GS': 'Goldman Sachs',\n 'AAPL': 'Apple',\n 'SAP': 'SAP',\n 'CSCO': 'Cisco',\n 'TXN': 'Texas instruments',\n 'XRX': 'Xerox',\n 'LMT': 'Lookheed Martin',\n 'WMT': 'Wal-Mart',\n 'WBA': 'Walgreen',\n 'HD': 'Home Depot',\n 'GSK': 'GlaxoSmithKline',\n 'PFE': 'Pfizer',\n 'SNY': 'Sanofi-Aventis',\n 'NVS': 'Novartis',\n 'KMB': 'Kimberly-Clark',\n 'R': 'Ryder',\n 'GD': 'General Dynamics',\n 'RTN': 'Raytheon',\n 'CVS': 'CVS',\n 'CAT': 'Caterpillar',\n 'DD': 'DuPont de Nemours'}\n\nsymbols, names = np.array(list(symbol_dict.items())).T\n\nquotes = [quotes_historical_yahoo_ochl(symbol, d1, d2, asobject=True)\n for symbol in symbols]\n\nopen = np.array([q.open for q in quotes]).astype(np.float)\nclose = np.array([q.close for q in quotes]).astype(np.float)\n\n# The daily variations of the quotes are what carry most information\nvariation = close - open"
47+
"def quotes_historical_google(symbol, date1, date2):\n \"\"\"Get the historical data from Google finance.\n\n Parameters\n ----------\n symbol : str\n Ticker symbol to query for, for example ``\"DELL\"``.\n date1 : datetime.datetime\n Start date.\n date2 : datetime.datetime\n End date.\n\n Returns\n -------\n X : array\n The columns are ``date`` -- datetime, ``open``, ``high``,\n ``low``, ``close`` and ``volume`` of type float.\n \"\"\"\n params = urlencode({\n 'q': symbol,\n 'startdate': date1.strftime('%b %d, %Y'),\n 'enddate': date2.strftime('%b %d, %Y'),\n 'output': 'csv'\n })\n url = 'http://www.google.com/finance/historical?' + params\n with urlopen(url) as response:\n dtype = {\n 'names': ['date', 'open', 'high', 'low', 'close', 'volume'],\n 'formats': ['object', 'f4', 'f4', 'f4', 'f4', 'f4']\n }\n converters = {0: lambda s: datetime.strptime(s.decode(), '%d-%b-%y')}\n return np.genfromtxt(response, delimiter=',', skip_header=1,\n dtype=dtype, converters=converters,\n missing_values='-', filling_values=-1)\n\n\n# Choose a time period reasonably calm (not too long ago so that we get\n# high-tech firms, and before the 2008 crash)\nd1 = datetime(2003, 1, 1)\nd2 = datetime(2008, 1, 1)\n\nsymbol_dict = {\n 'TOT': 'Total',\n 'XOM': 'Exxon',\n 'CVX': 'Chevron',\n 'COP': 'ConocoPhillips',\n 'VLO': 'Valero Energy',\n 'MSFT': 'Microsoft',\n 'IBM': 'IBM',\n 'TWX': 'Time Warner',\n 'CMCSA': 'Comcast',\n 'CVC': 'Cablevision',\n 'YHOO': 'Yahoo',\n 'DELL': 'Dell',\n 'HPQ': 'HP',\n 'AMZN': 'Amazon',\n 'TM': 'Toyota',\n 'CAJ': 'Canon',\n 'SNE': 'Sony',\n 'F': 'Ford',\n 'HMC': 'Honda',\n 'NAV': 'Navistar',\n 'NOC': 'Northrop Grumman',\n 'BA': 'Boeing',\n 'KO': 'Coca Cola',\n 'MMM': '3M',\n 'MCD': 'McDonald\\'s',\n 'PEP': 'Pepsi',\n 'K': 'Kellogg',\n 'UN': 'Unilever',\n 'MAR': 'Marriott',\n 'PG': 'Procter Gamble',\n 'CL': 'Colgate-Palmolive',\n 'GE': 'General Electrics',\n 'WFC': 'Wells Fargo',\n 'JPM': 'JPMorgan Chase',\n 'AIG': 'AIG',\n 'AXP': 'American express',\n 'BAC': 'Bank of America',\n 'GS': 'Goldman Sachs',\n 'AAPL': 'Apple',\n 'SAP': 'SAP',\n 'CSCO': 'Cisco',\n 'TXN': 'Texas Instruments',\n 'XRX': 'Xerox',\n 'WMT': 'Wal-Mart',\n 'HD': 'Home Depot',\n 'GSK': 'GlaxoSmithKline',\n 'PFE': 'Pfizer',\n 'SNY': 'Sanofi-Aventis',\n 'NVS': 'Novartis',\n 'KMB': 'Kimberly-Clark',\n 'R': 'Ryder',\n 'GD': 'General Dynamics',\n 'RTN': 'Raytheon',\n 'CVS': 'CVS',\n 'CAT': 'Caterpillar',\n 'DD': 'DuPont de Nemours'}\n\nsymbols, names = np.array(list(symbol_dict.items())).T\n\nquotes = [\n quotes_historical_google(symbol, d1, d2) for symbol in symbols\n]\n\nclose_prices = np.stack([q['close'] for q in quotes])\nopen_prices = np.stack([q['open'] for q in quotes])\n\n# The daily variations of the quotes are what carry most information\nvariation = close_prices - open_prices"
4848
]
4949
},
5050
{

dev/_downloads/plot_stock_market.py

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,27 +64,59 @@
6464
# Author: Gael Varoquaux [email protected]
6565
# License: BSD 3 clause
6666

67-
import datetime
67+
from datetime import datetime
6868

6969
import numpy as np
70-
import matplotlib.pyplot as plt
71-
try:
72-
from matplotlib.finance import quotes_historical_yahoo_ochl
73-
except ImportError:
74-
# quotes_historical_yahoo_ochl was named quotes_historical_yahoo before matplotlib 1.4
75-
from matplotlib.finance import quotes_historical_yahoo as quotes_historical_yahoo_ochl
70+
from matplotlib import pyplot as plt
7671
from matplotlib.collections import LineCollection
72+
from six.moves.urllib.request import urlopen
73+
from six.moves.urllib.parse import urlencode
7774
from sklearn import cluster, covariance, manifold
7875

7976
###############################################################################
8077
# Retrieve the data from Internet
8178

79+
def quotes_historical_google(symbol, date1, date2):
80+
"""Get the historical data from Google finance.
81+
82+
Parameters
83+
----------
84+
symbol : str
85+
Ticker symbol to query for, for example ``"DELL"``.
86+
date1 : datetime.datetime
87+
Start date.
88+
date2 : datetime.datetime
89+
End date.
90+
91+
Returns
92+
-------
93+
X : array
94+
The columns are ``date`` -- datetime, ``open``, ``high``,
95+
``low``, ``close`` and ``volume`` of type float.
96+
"""
97+
params = urlencode({
98+
'q': symbol,
99+
'startdate': date1.strftime('%b %d, %Y'),
100+
'enddate': date2.strftime('%b %d, %Y'),
101+
'output': 'csv'
102+
})
103+
url = 'http://www.google.com/finance/historical?' + params
104+
with urlopen(url) as response:
105+
dtype = {
106+
'names': ['date', 'open', 'high', 'low', 'close', 'volume'],
107+
'formats': ['object', 'f4', 'f4', 'f4', 'f4', 'f4']
108+
}
109+
converters = {0: lambda s: datetime.strptime(s.decode(), '%d-%b-%y')}
110+
return np.genfromtxt(response, delimiter=',', skip_header=1,
111+
dtype=dtype, converters=converters,
112+
missing_values='-', filling_values=-1)
113+
114+
82115
# Choose a time period reasonably calm (not too long ago so that we get
83116
# high-tech firms, and before the 2008 crash)
84-
d1 = datetime.datetime(2003, 1, 1)
85-
d2 = datetime.datetime(2008, 1, 1)
117+
d1 = datetime(2003, 1, 1)
118+
d2 = datetime(2008, 1, 1)
86119

87-
# kraft symbol has now changed from KFT to MDLZ in yahoo
88120
symbol_dict = {
89121
'TOT': 'Total',
90122
'XOM': 'Exxon',
@@ -102,7 +134,6 @@
102134
'AMZN': 'Amazon',
103135
'TM': 'Toyota',
104136
'CAJ': 'Canon',
105-
'MTU': 'Mitsubishi',
106137
'SNE': 'Sony',
107138
'F': 'Ford',
108139
'HMC': 'Honda',
@@ -111,9 +142,8 @@
111142
'BA': 'Boeing',
112143
'KO': 'Coca Cola',
113144
'MMM': '3M',
114-
'MCD': 'Mc Donalds',
145+
'MCD': 'McDonald\'s',
115146
'PEP': 'Pepsi',
116-
'MDLZ': 'Kraft Foods',
117147
'K': 'Kellogg',
118148
'UN': 'Unilever',
119149
'MAR': 'Marriott',
@@ -129,11 +159,9 @@
129159
'AAPL': 'Apple',
130160
'SAP': 'SAP',
131161
'CSCO': 'Cisco',
132-
'TXN': 'Texas instruments',
162+
'TXN': 'Texas Instruments',
133163
'XRX': 'Xerox',
134-
'LMT': 'Lookheed Martin',
135164
'WMT': 'Wal-Mart',
136-
'WBA': 'Walgreen',
137165
'HD': 'Home Depot',
138166
'GSK': 'GlaxoSmithKline',
139167
'PFE': 'Pfizer',
@@ -149,14 +177,16 @@
149177

150178
symbols, names = np.array(list(symbol_dict.items())).T
151179

152-
quotes = [quotes_historical_yahoo_ochl(symbol, d1, d2, asobject=True)
153-
for symbol in symbols]
180+
quotes = [
181+
quotes_historical_google(symbol, d1, d2) for symbol in symbols
182+
]
154183

155-
open = np.array([q.open for q in quotes]).astype(np.float)
156-
close = np.array([q.close for q in quotes]).astype(np.float)
184+
close_prices = np.stack([q['close'] for q in quotes])
185+
open_prices = np.stack([q['open'] for q in quotes])
157186

158187
# The daily variations of the quotes are what carry most information
159-
variation = close - open
188+
variation = close_prices - open_prices
189+
160190

161191
###############################################################################
162192
# Learn a graphical structure from the correlations

dev/_downloads/scikit-learn-docs.pdf

250 KB
Binary file not shown.
0 Bytes
0 Bytes
84 Bytes
84 Bytes

0 commit comments

Comments
 (0)