Skip to content

Instantly share code, notes, and snippets.

View grohith327's full-sized avatar

Rohith Gandhi G grohith327

View GitHub Profile
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))
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)
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
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
@grohith327
grohith327 / svm_4.py
Last active January 11, 2020 18:32
## 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))
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:]
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:
import os
os.system('top')
import webbrowser
webbrowser.open('http://google.com')
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))