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 tensorflow as tf | |
from tensorflow.keras.layers import Dense, Flatten, Conv2D, MaxPool2D, Dropout | |
# Create training and testing datasets from tensors | |
train_ds = tf.data.Dataset.from_tensor_slices((X_train, y_train)).batch(1) | |
test_ds = tf.data.Dataset.from_tensor_slices((X_test, y_test)).batch(1) | |
# CNN Model | |
class Command(Model): | |
def __init__(self): |
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 pandas as pd | |
import numpy as np | |
df_train = pd.read_csv('/Users/rohith/Documents/Datasets/Linear_Regression/train.csv') | |
df_test = pd.read_csv('/Users/rohith/Documents/Datasets/Linear_Regression/test.csv') | |
x_train = df_train['x'] | |
y_train = df_train['y'] | |
x_test = df_test['x'] | |
y_test = df_test['y'] |
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.svm import SVC | |
from sklearn.metrics import accuracy_score | |
clf = SVC(kernel='linear') | |
clf.fit(x_train,y_train) | |
y_pred = clf.predict(x_test) | |
print(accuracy_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 pyaudio | |
import wave | |
from keras.models import load_model | |
import librosa | |
import numpy as np | |
import warnings | |
import osascript | |
import webbrowser | |
import os | |
import cv2 |
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
## Linear Regression | |
import numpy as np | |
n = 700 | |
alpha = 0.0001 | |
a_0 = np.zeros((n,1)) | |
a_1 = np.zeros((n,1)) | |
epochs = 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
import pandas as pd | |
df = pd.read_csv('/Users/rohith/Documents/Datasets/Iris_dataset/iris.csv') ## Load data | |
df = df.drop(['Id'],axis=1) | |
rows = list(range(100,150)) | |
df = df.drop(df.index[rows]) ## Drop the rows with target values Iris-virginica | |
Y = [] | |
target = df['Species'] | |
for val in target: | |
if(val == 'Iris-setosa'): |
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 | |
y_prediction = a_0 + a_1 * x_test | |
print('R2 Score:',r2_score(y_test,y_prediction)) | |
y_plot = [] | |
for i in range(100): | |
y_plot.append(a_0 + a_1 * i) | |
plt.figure(figsize=(10,10)) | |
plt.scatter(x_test,y_test,color='red',label='GT') |
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 pyaudio | |
import wave | |
import warnings | |
warnings.filterwarnings(action='ignore',category=FutureWarning) | |
CHUNK = 256 | |
FORMAT = pyaudio.paInt16 | |
CHANNELS = 2 |
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 keras | |
from keras.datasets import mnist | |
from keras.models import Sequential | |
from keras.layers import Dense, Dropout, Flatten | |
from keras.layers import Conv2D, MaxPooling2D | |
from keras import backend as K | |
(x_train, y_train), (x_test, y_test) = mnist.load_data() | |
img_rows, img_cols = 28, 28 |
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.model_selection import train_test_split | |
x_train = [] | |
y_train = [] | |
x_test = [] | |
y_test = [] | |
X = [] | |
Y = [] | |
for row in rows: | |
X.append(int(''.join(row[0].split('/')))) | |
Y.append(row[3]) |
NewerOlder