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 datetime import date | |
sundays=0 | |
for year in range(1901,2001): | |
for month in range(1,13): | |
if date(year,month,1).weekday()==6: | |
sundays+=1 | |
print sundays |
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 | |
import matplotlib.pyplot as plt | |
import seaborn as sns | |
from sklearn import datasets | |
from sklearn.linear_model import LinearRegression | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score | |
from scipy.optimize import minimize |
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
boston = datasets.load_boston() | |
y = boston.target | |
X = pd.DataFrame(boston.data, columns = boston.feature_names) | |
ss = StandardScaler() | |
Xs = ss.fit_transform(X) | |
Xs = pd.DataFrame(Xs, columns=boston.feature_names) | |
Xs['const'] = 1 | |
# calculate y |