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
if passenger['Sex'] == 'male': | |
# male | |
if passenger['Age'] < 10: | |
if passenger['Pclass'] == 3: | |
if passenger['SibSp'] > 1: | |
predictions.append(0) | |
else: | |
predictions.append(1) | |
else: |
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
Task | Sklearn | TFLearn | |
---|---|---|---|
Train a classifier | .fit(X) | .fit(X) | |
Get the accuracy score | .score(X, y) | .evaluate(X, y) | |
Predict classes | .predict(X) | .predict_label(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
from sklearn.datasets import load_breast_cancer | |
from sklearn.model_selection import train_test_split | |
from tflearn.data_utils import to_categorical | |
import tflearn | |
## Load the dataset | |
X, y = load_breast_cancer(True) | |
## Train/Test Split and convert class vector to a binary class matrix | |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42) |
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 numpy as np | |
import cv2, os | |
face_cascade = cv2.CascadeClassifier('cascade/haarcascades/haarcascade_frontalface_alt2.xml') | |
cap = cv2.VideoCapture(0) | |
while(True): | |
# Capture frame-by-frame | |
ret, frame = cap.read() | |
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) | |
faces = face_cascade.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5) | |
for (x, y, w, h) in faces: |
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
print(__doc__) | |
# Code source: Gaël Varoquaux | |
# Andreas Müller | |
# Modified for documentation by Jaques Grobler | |
# License: BSD 3 clause | |
import numpy as np | |
import matplotlib.pyplot as plt |
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
""" | |
### Implemented Methods | |
- Get contacts from a selected group | |
### Requires | |
- Selenium: `pip install selenium` | |
- ChromeDriver: http://chromedriver.chromium.org/ | |
- After downloading chromedriver, make sure to add in a folder accessible from the PATH | |
### Example of Usage: |
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 os | |
def rename_dir(path,sufix,extension_searched): | |
for file_name in os.listdir(path): | |
file_name_without_ext = os.path.splitext(file_name)[0] | |
extension = os.path.splitext(file_name)[1] | |
if extension == extension_searched: | |
if file_name_without_ext.rfind(sufix) > 0: | |
new_file_name = file_name[:file_name_without_ext.rfind(sufix)] + extension_searched | |
os.rename(os.path.join(path,file_name),os.path.join(path,new_file_name)) |
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 matplotlib.pyplot as plt | |
import keras.backend as K | |
from keras.callbacks import Callback | |
class LRFinder(Callback): | |
''' | |
A simple callback for finding the optimal learning rate range for your model + dataset. | |
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
## Imports | |
from ashrae_utils import reduce_mem_usage, CyclicLR, LRFinder | |
import numpy as np # linear algebra | |
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) | |
import math | |
import tqdm | |
import gc | |
from sklearn.linear_model import RidgeCV | |
import seaborn as sns |
OlderNewer