This file contains hidden or 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 boto3 | |
| import os | |
| from botocore.exceptions import ClientError | |
| from cryptography.fernet import Fernet | |
| from typing import Tuple, List | |
| def create_s3_client(): | |
| """Create and return an S3 client.""" | |
| return boto3.client('s3') |
This file contains hidden or 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 clean_dataframe_columns(df): | |
| df.columns = column_cleaner(df.columns) | |
| # Takes a dataframe and cleans all the column names | |
| def column_cleaner(columns): | |
| clean_list = [] | |
| for c in columns: | |
| c = clean_column(c) | |
| clean_list.append(create_unique_name(c, clean_list)) | |
| return clean_list |
This file contains hidden or 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 sklearn | |
| print('The scikit-learn version is {}.'.format(sklearn.__version__)) |
This file contains hidden or 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 num_nodes(n): | |
| return 2**(n) - 1 | |
| def parent_of_value(value, tree): | |
| for n in tree: | |
| if n.value == value: | |
| if n.parent != None: | |
| return n.parent.value | |
| else: |
This file contains hidden or 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
| # making file *.csv gets rid of all csvs | |
| git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch <file/dir>' HEAD | |
| # THIS IS DANGEROUS. WILL BREAK EVERYTHING. But it works if you are okay with that... |
This file contains hidden or 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.ensemble import BaggingClassifier | |
| dtc_params = { | |
| 'max_features': [0.5, 0.7, 1.0], | |
| 'max_samples': [0.5, 0.7, 1.0], | |
| 'n_estimators': [2, 5, 10, 20], | |
| } | |
| dtc_gs = GridSearchCV(BaggingClassifier(), dtc_params, cv=5, verbose=1) | |
| dtc_gs.fit(X, y) |
This file contains hidden or 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.ensemble import BaggingClassifier | |
| from sklearn.ensemble import RandomForestClassifier | |
| bc_params = {"base_estimator__max_depth": [3,5,10,20], | |
| "base_estimator__max_features": [None, "auto"], | |
| "base_estimator__min_samples_leaf": [1, 3, 5, 7, 10], | |
| "base_estimator__min_samples_split": [2, 5, 7], | |
| 'bootstrap_features': [False, True], |
This file contains hidden or 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 requests | |
| import bs4 | |
| from bs4 import BeautifulSoup | |
| import time | |
| import numpy as np | |
| import pandas as pd | |
| import time | |
| from selenium.webdriver.chrome.options import Options | |
| from selenium import webdriver | |
| from selenium.common.exceptions import NoSuchElementException |
This file contains hidden or 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.ensemble import ExtraTreesClassifier | |
| plt.style.use('fivethirtyeight') | |
| def feature_importance_eda(X, y): | |
| '''Get an estimate of the feature importance of data''' | |
| # Build a forest and compute the feature importances | |
| forest = ExtraTreesClassifier(n_estimators=250, | |
| random_state=0) |
This file contains hidden or 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
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Bokeh Plot</title> | |
| <link rel="stylesheet" href="https://cdn.pydata.org/bokeh/release/bokeh-0.12.5.min.css" type="text/css" /> | |
NewerOlder