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 matplotlib.pyplot as plt | |
from matplotlib.colors import ListedColormap | |
from sklearn.cross_validation import train_test_split | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.datasets import make_moons, make_circles, make_classification | |
from sklearn.svm import SVC | |
h = .02 # step size in the mesh |
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
import cv2, os | |
# Funcao para busca de arquivos | |
def find(name, path): | |
for root, dirs, files in os.walk(path): | |
if (name in files) or (name in dirs): | |
print("O diretorio/arquivo {} encontra-se em: {}".format(name, root)) | |
return os.path.join(root, name) | |
# Caso nao encontre, recursao para diretorios anteriores | |
return find(name, os.path.dirname(path)) |
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 cv2, os | |
BLUE_COLOR = (255, 0, 0) | |
STROKE = 2 | |
xml_path = 'haarcascade_frontalface_alt2.xml' | |
clf = cv2.CascadeClassifier(xml_path) | |
cap = cv2.VideoCapture(0) | |
while(not cv2.waitKey(20) & 0xFF == ord('q')): |
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)) |
OlderNewer