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
from sklearn.linear_model import LinearRegression | |
lm = LinearRegression(fit_intercept=True, normalize=True, n_jobs=None) | |
lm.fit(X_train, Y_train) | |
accuracy = lm.score(X_test, Y_test) | |
print "Linear Regression test file accuracy:"+str(accuracy) | |
lm.coef_ |
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
X_Cols = X_train.rename(columns= {'region_cd': '지역코드(시도)', 'year': '연도', 'month':'월', 'building_type': '부동산타입', | |
'tradeprice_sido' : '매매가격지수(시도)', 'construction_realized_amount' : '건설기성액(백만원)', "cd": "cd(91일물)", | |
'spirit_deposit_rate': '정기예금금리', 'exchange_rate': '환율', 'composite_stock_price_index': '종합주가지수', | |
'economy_growth': '경제성장률','exchequer_bond_three' : '국고채3년','household_loan_all': '가계대출액(전국)', | |
'mortgage_all' : '주택대출액(전국)', 'numberofnosells':'미분양 가구수(시도)','unsalenum_c':'공사완료후 미분양(민간,시도)' }) | |
print(X_train.columns) | |
coefs = pd.DataFrame(zip(X_Cols.columns,lm.coef_), columns = ['features', 'coefficients']) | |
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
%matplotlib inline | |
import matplotlib.pyplot as plt | |
Y_pred = lm.predict(X_test) | |
plt.scatter(Y_test, Y_pred) | |
plt.xlabel("Price Index: $Y_i$") | |
plt.ylabel("Predicted price Index: $\hat{Y}_i$") | |
plt.title("Prices vs Predicted price Index: $Y_i$ vs $\hat{Y}_i$") |
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
<?php | |
echo "\nstock cron start".date("Ymd")."\n"; | |
$start=1; | |
$display=20; | |
$total=20; | |
$newname = "news.txt"; | |
$line = ""; | |
for($start=1;$start <=$total; $start=$start+$display) |
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
import pandas as pd | |
import numpy as np | |
%matplotlib inline | |
import matplotlib.pyplot as plt | |
# 파일 업로드 기능 실행 | |
from google.colab import files | |
uploaded = files.upload() | |
for fn in uploaded.keys(): |
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
# 파일 업로드 기능 실행 | |
from google.colab import files | |
uploaded = files.upload() | |
for fn in uploaded.keys(): | |
print('User uploaded file "{name}" with length {length} bytes'.format(name=fn, length=len(uploaded[fn]))) |
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
# 2017/1/1 까지의 데이터를 트레이닝셋. | |
# 그 이후 데이터를 테스트셋으로 한다. | |
split_date = pd.Timestamp('01-01-2017') | |
train = df.loc[:split_date, ['trade_price_idx_value']] | |
test = df.loc[split_date:, ['trade_price_idx_value']] | |
ax = train.plot() | |
test.plot(ax=ax) |
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
from sklearn.preprocessing import MinMaxScaler | |
sc = MinMaxScaler() | |
train_sc = sc.fit_transform(train) | |
test_sc = sc.transform(test) | |
train_sc |
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
train_sc_df = pd.DataFrame(train_sc, columns=['trade_price_idx_value'], index=train.index) | |
test_sc_df = pd.DataFrame(test_sc, columns=['trade_price_idx_value'], index=test.index) | |
train_sc_df.head() | |
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
for s in range(1, 13): | |
train_sc_df['shift_{}'.format(s)] = train_sc_df['trade_price_idx_value'].shift(s) | |
test_sc_df['shift_{}'.format(s)] = test_sc_df['trade_price_idx_value'].shift(s) | |
train_sc_df.head(13) |
OlderNewer