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
km = KMeans(n_clusters = 5) | |
y_predicted = km.fit_predict(salary_story[['Total Salary Paid', 'Home Price']]) | |
salary_story['Cluster'] = y_predicted |
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.cluster import KMeans | |
from sklearn.preprocessing import MinMaxScaler | |
from sklearn.preprocessing import LabelEncoder |
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") |
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
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
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 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
#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
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
#libraries: | |
library(shiny) | |
library(shinythemes) | |
library(lubridate) | |
library(dygraphs) | |
library(xts) | |
library(tidyverse) | |
bitcoin <-read.csv(file = 'BTC-USD.csv', stringsAsFactors = F) |
NewerOlder