Skip to content

Instantly share code, notes, and snippets.

@liliya2022
liliya2022 / estimate_pi.ipynb
Created April 22, 2022 03:48 — forked from nikhilkumarsingh/estimate_pi.ipynb
A Monte Carlo simulation to estimate the value of π using Python.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@liliya2022
liliya2022 / us_state_abbrev.py
Created April 23, 2022 19:08 — forked from rogerallen/us_state_abbrev.py
A Python Dictionary to translate US States to Two letter codes
# 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
#
#libraries:
library(shiny)
library(shinythemes)
library(lubridate)
library(dygraphs)
library(xts)
library(tidyverse)
bitcoin <-read.csv(file = 'BTC-USD.csv', stringsAsFactors = F)
@liliya2022
liliya2022 / bar chart
Last active March 10, 2023 01:32
Machine learning blog
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')
#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'))
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")
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()
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)
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()
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")