This file contains hidden or 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
scores = model.evaluate(X_test, y_test) | |
print("\nAccuracy: %.2f%%" % (scores[1]*100)) |
This file contains hidden or 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
model.fit(X_train, y_train, epochs=300, batch_size=10) |
This file contains hidden or 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
output_data = data["Species"] | |
input_data = data.drop("Species",axis=1) | |
X_train, X_test, y_train, y_test = train_test_split(input_data, output_data, test_size=0.3, random_state=42) |
This file contains hidden or 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
corrMatt = data[["SepalLength","SepalWidth","PetalLength","PetalWidth","Species"]].corr() | |
mask = np.array(corrMatt) | |
mask[np.tril_indices_from(mask)] = False | |
fig,ax= plt.subplots() | |
fig.set_size_inches(20,10) | |
sn.heatmap(corrMatt, mask=mask,vmax=.8, square=True,annot=True) |
This file contains hidden or 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
data['Species'] = data['Species'].astype("category") | |
data.dtypes |
This file contains hidden or 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
COLUMN_NAMES = [ | |
'SepalLength', | |
'SepalWidth', | |
'PetalLength', | |
'PetalWidth', | |
'Species' | |
] | |
data = pd.read_csv('iris_data.csv', names=COLUMN_NAMES, header=0) | |
data.head() |
This file contains hidden or 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
class IrisClassifier(Model): | |
def __init__(self): | |
super(IrisClassifier, self).__init__() | |
self.layer1 = Dense(10, activation='relu') | |
self.layer2 = Dense(10, activation='relu') | |
self.outputLayer = Dense(3, activation='softmax') | |
def call(self, x): | |
x = self.layer1(x) | |
x = self.layer2(x) |
This file contains hidden or 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 import Model | |
from tensorflow.keras.layers import Dense | |
class SimpleNeuralNetwork(Model): | |
def __init__(self): | |
super(SimpleNeuralNetwork, self).__init__() | |
self.layer1 = Dense(2, activation='relu') | |
self.layer2 = Dense(3, activation='relu') | |
self.outputLayer = Dense(1, activation='softmax') |
This file contains hidden or 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 Input, Dense | |
input_layer = Input(shape=(2,)) | |
model = Dense(3, activation='relu')(input_layer) | |
model = Dense(1, activation='softmax')(model) |
This file contains hidden or 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 import Sequential | |
from tensorflow.keras.layers import Dense | |
model = Sequential() | |
model.add(Dense(3, input_dim=2, activation='relu')) | |
model.add(Dense(1, activation='softmax')) |