Skip to content

Instantly share code, notes, and snippets.

View ryanorsinger's full-sized avatar
🎏
Reading the readme... again :)

Ryan Orsinger ryanorsinger

🎏
Reading the readme... again :)
View GitHub Profile
@ryanorsinger
ryanorsinger / exam_scores.csv
Created August 6, 2021 21:15
exam_scores.csv
exam_score hours_studied study_strategy handedness coffee_consumed hours_slept
100.59101129985446 9.126291029886985 flashcards left 0 11
95.63708565196075 9.677437978787804 flashcards left 1 10
53.20029575279457 4.5502066553150184 NA right 5 6
63.9342682639801 6.48784774924302 flashcards right 4 7
51.186370191249075 6.720959153667016 flashcards right 5 6
99.62859279285587 5.887576815759884 NA left 1 10
10.427946120088633 1.2757594563672985 NA left 9 2
65.71187651647034 4.660530100027061 NA right 4 7
66.4234146158894 10.040814212451718 flashcards right 4 7
@ryanorsinger
ryanorsinger / clean_telco.csv
Created July 28, 2021 15:36
Telco Dataset (cleaned)
We can't make this file beautiful and searchable because it's too large.
id,customer_id,gender,is_senior_citizen,partner,dependents,phone_service,internet_service,contract_int,payment_type,monthly_charges,total_charges,churn,tenure_month,has_churned,has_phone,has_internet,has_internet_and_phone,partner_dependents,start_day,phone_type,internet_type,contract_type
0,0002-ORFBO,Female,0,Yes,Yes,1,1,1,Mailed check,65.6,593.3,No,9.0,False,True,True,True,3,2020-05-03,One Line,DSL,1 Year
1,0003-MKNFE,Male,0,No,No,2,1,0,Mailed check,59.9,542.4,No,9.1,False,True,True,True,0,2020-05-03,Two or More Lines,DSL,Month-to-Month
2,0004-TLHLJ,Male,0,No,No,1,2,0,Electronic check,73.9,280.85,Yes,3.8,True,True,True,True,0,2020-11-03,One Line,Fiber Optic,Month-to-Month
3,0011-IGKFF,Male,1,Yes,No,1,2,0,Electronic check,98.0,1237.85,Yes,12.6,True,True,True,True,1,2020-02-03,One Line,Fiber Optic,Month-to-Month
4,0013-EXCHZ,Female,1,Yes,No,1,2,0,Mailed check,83.9,267.4,Yes,3.2,True,True,True,True,1,2020-11-03,One Line,Fiber Optic,Month-to-Month
5,0013-MHZWF,Female,0,No,Yes,1,1,0,Credit card (automatic),69.4
@ryanorsinger
ryanorsinger / fix.md
Created May 21, 2021 23:10
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock'

MacOS:

  • $ brew services stop mysql

  • $ brew services list

  • $ brew uninstall mysql

  • $ brew install mysql

  • $ brew postinstall mysql

If Any error found then run those cmd

  • $ sudo rm -rf /usr/local/var/mysql
@ryanorsinger
ryanorsinger / installing_anaconda_on_mac.md
Last active April 26, 2024 02:22
Installing Homebrew and Anaconda

Installing Homebrew and Anaconda on a Mac

Install Homebrew

Run the following command on your terminal to install Homebrew. Homebrew is a package manager for Macs and is used to install useful development tools and software.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install Anaconda through Homebrew

  1. Run brew install --cask anaconda to install Anaconda
@ryanorsinger
ryanorsinger / loops_and_data_structures.md
Created April 9, 2021 22:28
loops and data type review
drinks = [
    {
        "type": "water",
        "calories": 0,
        "number_consumed": 5
    },
    {
        "type": "orange juice",
        "calories": 220,
@ryanorsinger
ryanorsinger / warmup.md
Last active April 19, 2021 20:50
Python String, List, Dictionary Warmup Exercises

Python String, List, Dictionary Warmup Exercises

Write the code that operates on a single string containing the make and model of a vehicle. The first part of the string before the space is the make The last part of the string after the space is the model We can assume that the strings will only have one space. Assume the input string is completely lower-cased.

Example inputs:

@ryanorsinger
ryanorsinger / get_a_number.py
Last active April 8, 2021 22:41
Prompting a user for a number
# Prompt the user to enter a number until they enter 5
while True:
# Obtain user input
number = input("Please input the number 5: ")
# Check if the input string is a digit
if number.isdigit():
# Now that we know the input is a digit, we can make sure to turn that string containing the number into an integer.
@ryanorsinger
ryanorsinger / is_prime.py
Created April 8, 2021 19:28
Prime checking function(s). This is the least efficient way to check for primes, I'm sure!
def is_prime(num):
"""
Returns a boolean if the input argument is a prime number or not.
"""
if type(num) != int:
return False
if num <= 0:
return False
if num == 1:
return True
@ryanorsinger
ryanorsinger / category_percentages_by_another_category.py
Last active March 27, 2021 14:50
category_percentages_by_another_category visual
# Following up on https://github.com/mwaskom/seaborn/issues/1027 and https://stackoverflow.com/questions/34615854/seaborn-countplot-with-normalized-y-axis-per-group
import pandas as pd
import seaborn as sns
def category_percentages_by_another_category(df, category_a, category_b):
(df.groupby(category_b)[category_a].value_counts(normalize=True)
.rename('percent')
.reset_index()
.pipe((sns.catplot, 'data'), x=category_a, y='percent', hue=category_b, kind='bar'))
@ryanorsinger
ryanorsinger / stratify_by_binned_continuous.py
Last active March 18, 2021 18:41
Stratify by a Binned Continuous Target Variable
import pandas as pd
from sklearn.model_selection import train_test_split
def split_stratify(df, target, bins=5):
"""
This function takes in a dataframe, the string of the target variable name, and the number of bins
This function makes bins out of the continuous target then stratifies the splits by the bins
Finally, the function returns train, validate, and test, and the binned column is removed
The current failure state of this function comes if there are bins with only one observation.
"""