Skip to content

Instantly share code, notes, and snippets.

View jennyonjourney's full-sized avatar

Kyungeun, Jeon (Jenny) jennyonjourney

View GitHub Profile
@jennyonjourney
jennyonjourney / bike-sharing-demand (kaggle competition)
Created May 23, 2018 12:40
bike-sharing-demand (kaggle competition)
import numpy as np
import pandas as pd
train = pd.read_csv("data/train (bike).csv")
print(train.shape)
train.head()
train = pd.read_csv("data/train (bike).csv", parse_dates=["datetime"])
print(train.shape)
## Data processing
train["year"] = train["datetime"].dt.year
@jennyonjourney
jennyonjourney / gist:f71a36dfa36849378a1be9f7708e5e01
Last active October 16, 2022 12:38
Python Data Structures (Coursera) Assignement 10.2
# 10.2 Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages. You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon.
#From [email protected] Sat Jan 5 09:14:16 2008
# Once you have accumulated the counts for each hour, print out the counts, sorted by hour as shown below.
name = input("Enter file:")
if len(name) < 1:
name = "mbox-short.txt"
handle = open(name)
counts = dict()
@jennyonjourney
jennyonjourney / gist:0c32836a4632c6cce72e9fd5de43100d
Created April 5, 2018 01:00
ML (NN multi layers' backpropagation)
import tensorflow as tf
import numpy as np
tf.set_random_seed(777) # for reproducibility
learning_rate = 0.0001
xy = np.loadtxt('multiTimeline_bitcoin_2_normalized.csv', delimiter=',', dtype=np.float32)
X_data = xy[:, 0:-1]
def MinMaxScaler(x_data):
numerator = x_data - np.min(x_data, 0)
denominator = np.max(x_data, 0) - np.min(x_data, 0)
return numerator / (denominator + 1e-10)
@jennyonjourney
jennyonjourney / gist:eb51f1d02a6606b30a8faa4a6922e4ee
Created April 3, 2018 15:26
NN back propagation practice (ted viewer prediction) - 1layer
import tensorflow as tf
import numpy as np
tf.set_random_seed(777) # for reproducibility
# Predicting animal type based on various features
xy = np.loadtxt('ted_main_ranking_viewer.csv', delimiter=',', dtype=np.float32)
X_data = xy[:, 0:-1]
def MinMaxScaler(x_data):
numerator = x_data - np.min(x_data, 0)
denominator = np.max(x_data, 0) - np.min(x_data, 0)
import urllib.request as ur
import json
page_name='MBC'
base="https://graph.facebook.com/v2.8/"
page_id='240263402699918'
from_date='2018-01-01'
# developers/facebook.com 으로 접속
import urllib.request as ur
import json
page_name='jtbcnews'
base = "https://graph.facebook.com/v2.8"
app_id = "200920440387013"
app_secret = "daccef14d5cd41c0e95060d65e66c41d"
access_token = app_id+"|"+app_secret
@jennyonjourney
jennyonjourney / gist:659bd1152fe516bc16c3d63d12c26dd9
Created April 1, 2018 03:44
Python - Web crawling (csv파일로 저장하기)
import requests
from lxml.html import parse
from io import StringIO
def rowData(rr, kind):
cols = rr.findall('.//'+kind)
res = [vv.text_content().replace("\t","").replace("\n","") for vv in cols]
return res[:-1]
def rowWrite(rr):
@jennyonjourney
jennyonjourney / gist:804b2c2aaa17722d00572e26c0a6b903
Last active April 1, 2018 03:22
Python - web data crawling
import requests
from lxml.html import parse
from io import StringIO
url='http://finance.naver.com/sise/sise_market_sum.nhn'
text = requests.get(url)
ppp = parse(StringIO(text.text))
doc = ppp.getroot()
tables = doc.findall('.//table')
largest = None
smallest = None
while True:
inp = raw_input("Enter a number: ")
if inp == "done" : break
try:
num = float(inp)
except:
print ("Invalid input")
def order(ih,name='아시아노'):
dd = {'아메리카노': 2000,
'아프리카노': 3000,
'아시아노': 3500}
print(name, ih, dd[name])
order('아이스','아메리카노')
order('핫','아프리카노')
order('아이스')
print('----실습----')