Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
# United States of America Python Dictionary to translate States, | |
# Districts & Territories to Two-Letter codes and vice versa. | |
# | |
# Canonical URL: https://gist.github.com/rogerallen/1583593 | |
# | |
# Dedicated to the public domain. To the extent possible under law, | |
# Roger Allen has waived all copyright and related or neighboring | |
# rights to this code. Data originally from Wikipedia at the url: | |
# https://en.wikipedia.org/wiki/ISO_3166-2:US | |
# |
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
#libraries: | |
library(shiny) | |
library(shinythemes) | |
library(lubridate) | |
library(dygraphs) | |
library(xts) | |
library(tidyverse) | |
bitcoin <-read.csv(file = 'BTC-USD.csv', stringsAsFactors = F) |
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
def get_feature_groups(): | |
num_features = housing.select_dtypes(include=['int64','float64']).columns | |
return list(num_features.drop(['PID','SalePrice'])) | |
num_features = get_feature_groups() | |
corr = housing[['SalePrice'] + num_features].corr() | |
corr = corr.sort_values('SalePrice', ascending=False) | |
plt.figure(figsize=(8,10)) | |
sns.barplot(x=corr.SalePrice[1:], y=corr.index[1:], orient='h') |
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 the following libraries | |
import numpy as np | |
import pandas as pd | |
from sklearn.model_selection import train_test_split | |
from sklearn.ensemble import RandomForestRegressor | |
from sklearn.preprocessing import LabelEncoder | |
import matplotlib.pyplot as plt | |
#separate numerical and catergorical features | |
housing_numerical = housing.drop(['PID'], axis =1).select_dtypes(include = ('int64', 'float64')) |
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 seaborn as sns | |
sns.set(rc = {'figure.figsize':(15,8)}) | |
sns.boxplot(x='OverallQual', y='SalePrice', data=housing).set(title = "House Overall Quality Boxplot") |
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
price = housing['SalePrice'] | |
tot_liv_area = housing['TotLivArea'] | |
plt.figure(figsize=(9, 6)) | |
plt.scatter(tot_liv_area, price) | |
plt.ylabel('Sale Price') | |
plt.xlabel('TotLivArea') | |
plt.title('Sale Price per Total Living Area') | |
plt.show() |
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 scipy.stats as stats | |
plt.figure(figsize=(16, 10)) | |
for f, label in ((same_1990s, "Not Remodelled"), | |
(remodelled_1990s, "Remodelled"), | |
(built_1990s, "Built after 1990")): | |
x = np.sort(price[f]) | |
plt.hist(x, density=True, alpha=0.1) | |
density = stats.gaussian_kde(x) |
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
sns.set(rc = {'figure.figsize':(15,8)}) | |
sns.distplot(a=salary_story['Total Salary Paid'], bins = 40, color='green', | |
hist_kws={"edgecolor": 'black'}).set(title = "Density Plot for Income") | |
plt.show() |
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
sns.set(rc = {'figure.figsize':(14,7)}) | |
sns.scatterplot(data = salary_story, x = 'Total Salary Paid', y = 'Home Price').set(title = "Income per Home Price") |
OlderNewer