Skip to content

Cleanup #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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ w = [4, 5, 6]
print distance(v, w)
print vector_mean([v, w])
```

Or can be run from the command line to get a demo of what it does (and to execute the examples from the book):

```bat
python recommender_systems.py
```
```

Additionally, I've collected all the [links](https://github.com/joelgrus/data-science-from-scratch/blob/master/links.md) from the book.

And, by popular demand, I made an index of functions defined in the book, by chapter and page number.
And, by popular demand, I made an index of functions defined in the book, by chapter and page number.
The data is in a [spreadsheet](https://docs.google.com/spreadsheets/d/1mjGp94ehfxWOEaAFJsPiHqIeOioPH1vN1PdOE6v1az8/edit?usp=sharing), or I also made a toy (experimental) [searchable webapp](http://joelgrus.com/experiments/function-index/).

## Installations

```
pip install -r requirements.txt
```

## Table of Contents

1. Introduction
Expand Down
Empty file removed code-python3/charts.py
Empty file.
8 changes: 4 additions & 4 deletions code-python3/getting_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def process(date, symbol, price):

print("tab delimited stock prices:")

with open('tab_delimited_stock_prices.txt', 'r', encoding='utf8',newline='') as f:
with open('../data/tab_delimited_stock_prices.txt', 'r', encoding='utf8',newline='') as f:
reader = csv.reader(f, delimiter='\t')
# reader = csv.reader(codecs.iterdecode(f, 'utf-8'), delimiter='\t')
for row in reader:
Expand All @@ -170,7 +170,7 @@ def process(date, symbol, price):

print("colon delimited stock prices:")

with open('colon_delimited_stock_prices.txt', 'r', encoding='utf8',newline='') as f:
with open('../data/colon_delimited_stock_prices.txt', 'r', encoding='utf8',newline='') as f:
reader = csv.DictReader(f, delimiter=':')
# reader = csv.DictReader(codecs.iterdecode(f, 'utf-8'), delimiter=':')
for row in reader:
Expand All @@ -181,11 +181,11 @@ def process(date, symbol, price):

print()

print("writing out comma_delimited_stock_prices.txt")
print("writing out ../data/comma_delimited_stock_prices.txt")

today_prices = { 'AAPL' : 90.91, 'MSFT' : 41.68, 'FB' : 64.5 }

with open('comma_delimited_stock_prices.txt','w', encoding='utf8',newline='') as f:
with open('../data/comma_delimited_stock_prices.txt','w', encoding='utf8',newline='') as f:
writer = csv.writer(f, delimiter=',')
for stock, price in today_prices.items():
writer.writerow([stock, price])
Expand Down
2 changes: 1 addition & 1 deletion code-python3/plot_state_borders.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

lat_long_regex = r"<point lat=\"(.*)\" lng=\"(.*)\""

with open("states.txt", "r") as f:
with open("../data/states.txt", "r") as f:
lines = [line for line in f]

for line in lines:
Expand Down
4 changes: 2 additions & 2 deletions code-python3/working_with_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def transform(X, components):

data = []

with open("comma_delimited_stock_prices.csv", "r", encoding='utf8', newline='') as f:
with open("../data/comma_delimited_stock_prices.csv", "r", encoding='utf8', newline='') as f:
reader = csv.reader(f)
for line in parse_rows_with(reader, [dateutil.parser.parse, None, float]):
data.append(line)
Expand All @@ -405,7 +405,7 @@ def transform(X, components):
print(row)

print("stocks")
with open("stocks.txt", "r", encoding='utf8', newline='') as f:
with open("../data/stocks.txt", "r", encoding='utf8', newline='') as f:
reader = csv.DictReader(f, delimiter="\t")
data = [parse_dict(row, { 'date' : dateutil.parser.parse,
'closing_price' : float })
Expand Down
Empty file removed code/charts.py
Empty file.
4 changes: 0 additions & 4 deletions code/colon_delimited_stock_prices.txt

This file was deleted.

6 changes: 0 additions & 6 deletions code/comma_delimited_stock_prices.csv

This file was deleted.

3 changes: 0 additions & 3 deletions code/comma_delimited_stock_prices.txt

This file was deleted.

8 changes: 4 additions & 4 deletions code/getting_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def process(date, symbol, price):

print "tab delimited stock prices:"

with open('tab_delimited_stock_prices.txt', 'rb') as f:
with open('../data/tab_delimited_stock_prices.txt', 'rb') as f:
reader = csv.reader(f, delimiter='\t')
for row in reader:
date = row[0]
Expand All @@ -170,7 +170,7 @@ def process(date, symbol, price):

print "colon delimited stock prices:"

with open('colon_delimited_stock_prices.txt', 'rb') as f:
with open('../data/colon_delimited_stock_prices.txt', 'rb') as f:
reader = csv.DictReader(f, delimiter=':')
for row in reader:
date = row["date"]
Expand All @@ -180,11 +180,11 @@ def process(date, symbol, price):

print

print "writing out comma_delimited_stock_prices.txt"
print "writing out ../data/comma_delimited_stock_prices.txt"

today_prices = { 'AAPL' : 90.91, 'MSFT' : 41.68, 'FB' : 64.5 }

with open('comma_delimited_stock_prices.txt','wb') as f:
with open('../data/comma_delimited_stock_prices.txt','wb') as f:
writer = csv.writer(f, delimiter=',')
for stock, price in today_prices.items():
writer.writerow([stock, price])
Expand Down
2 changes: 1 addition & 1 deletion code/plot_state_borders.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

lat_long_regex = r"<point lat=\"(.*)\" lng=\"(.*)\""

with open("states.txt", "r") as f:
with open("../data/states.txt", "r") as f:
lines = [line for line in f]

for line in lines:
Expand Down
Loading