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.linear_model import LinearRegression | |
from sklearn.metrics import r2_score | |
clf = LinearRegression(normalize=True) | |
clf.fit(x_train,y_train) | |
y_pred = clf.predict(x_test) | |
print(r2_score(y_test,y_pred)) |
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 | |
from sklearn.cross_validation import train_test_split | |
## Retrieve features | |
X = df.values.tolist() | |
Y = [] | |
## Convert classes in Strings to Integers | |
for val in target: | |
if(val == 'Iris-setosa'): | |
Y.append(0) |
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 simplegan.gan import Pix2Pix | |
## Create an object | |
gan = Pix2Pix() ## Customize the model by specifying parameters for Pix2Pix object | |
## Load the training and testing data | |
train_ds, test_ds = gan.load_data(use_edges2handbags = True, batch_size = 32) | |
## Get samples from training data | |
train_samples = gan.get_sample(data= train_ds, n_samples = 2) | |
## Get samples from testing data | |
train_samples = gan.get_sample(data= test_ds, n_samples = 2) | |
## train the model |
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 simplegan.autoencoder import ConvolutionalAutoencoder | |
## Create an object | |
autoenc = ConvolutionalAutoencoder() ## Modify the architecture of the model by specifying parameters | |
## Load the MNIST data | |
train_ds, test_ds = autoenc.load_data(use_mnsist = True) | |
## Get samples from the loaded training data to view them | |
train_samples = autoenc.get_sample(data = train_ds, n_samples = 2) | |
## Get samples from the loaded testing data to view them | |
test_samples = autoenc.get_sample(data = test_ds, n_samples = 2) | |
## Train the model |
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
## Support Vector Machine | |
import numpy as np | |
train_f1 = x_train[:,0] | |
train_f2 = x_train[:,1] | |
train_f1 = train_f1.reshape(90,1) | |
train_f2 = train_f2.reshape(90,1) | |
w1 = np.zeros((90,1)) |
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 | |
x = df['SepalLengthCm'] | |
y = df['PetalLengthCm'] | |
setosa_x = x[:50] | |
setosa_y = y[:50] | |
versicolor_x = x[50:] | |
versicolor_y = y[50:] |
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 | |
cam = cv2.VideoCapture(0) | |
cv2.namedWindow("take a picture") | |
img_counter = 0 | |
while True: | |
ret, frame = cam.read() | |
cv2.imshow("test", frame) | |
if not ret: |
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 | |
os.system('top') |
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 webbrowser | |
webbrowser.open('http://google.com') |
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 osascript | |
vol = osascript.osascript('get volume settings') | |
cur_vol = int(vol[1].split(':')[1].split(',')[0]) | |
cur_vol = cur_vol + 20 | |
if(cur_vol > 100): | |
cur_vol = 100 | |
osascript.osascript("set volume output volume "+str(cur_vol)) |