-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4aaaa6
commit d3478ce
Showing
12 changed files
with
193,102 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# you can write to stdout for debugging purposes, e.g. | ||
# print("this is a debug message") | ||
|
||
def solution(predicted, observed): | ||
# write your code in Python 3.6 | ||
sqdeviations = [] | ||
for obs, pre in zip(observed, predicted): | ||
sqdeviations.append((obs-pre)**2) | ||
|
||
mse = (sum(sqdeviations))/len(sqdeviations) | ||
rmse = mse ** 0.5 | ||
return rmse | ||
predicted = [4, 25, 0.75, 11] | ||
observed = [3, 21, -1.25, 13] | ||
|
||
solution(predicted, observed) |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
P3-Wrangle OSM Data/tokyo_japan.osm/Submission/.ipynb_checkpoints/osm_sampler-checkpoint.py
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Thu Apr 20 18:51:14 2017 | ||
@author: Christopher | ||
""" | ||
OSM_FILE = "tokyo_japan.xml" # Replace this with your osm file | ||
SAMPLE_FILE = "tokyo_extract_k_10000.xml" | ||
|
||
import codecs | ||
|
||
import xml.etree.ElementTree as ET # Use cElementTree or lxml if too slow | ||
|
||
|
||
k = 3000 # Parameter: take every k-th top level element | ||
|
||
def get_element(osm_file, tags=('node', 'way', 'relation')): | ||
"""Yield element if it is the right type of tag | ||
Reference: | ||
http://stackoverflow.com/questions/3095434/inserting-newlines-in-xml-file-generated-via-xml-etree-elementtree-in-python | ||
""" | ||
context = iter(ET.iterparse(osm_file, events=('start', 'end'))) | ||
_, root = next(context) | ||
for event, elem in context: | ||
if event == 'end' and elem.tag in tags: | ||
yield elem | ||
root.clear() | ||
|
||
if __name__== "__main__": | ||
with codecs.open(SAMPLE_FILE, 'wb') as output: | ||
output.write(b'<?xml version="1.0" encoding="UTF-8"?>\n') | ||
output.write(b'<osm>\n ') | ||
|
||
# Write every kth top level element | ||
for i, element in enumerate(get_element(OSM_FILE)): | ||
if i % k == 0: | ||
output.write(ET.tostring(element, encoding='utf-8')) | ||
|
||
output.write(b'</osm>') |
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.