Skip to content

Instantly share code, notes, and snippets.

View NMZivkovic's full-sized avatar

Nikola Živković NMZivkovic

View GitHub Profile
scores = model.evaluate(X_test, y_test)
print("\nAccuracy: %.2f%%" % (scores[1]*100))
model.fit(X_train, y_train, epochs=300, batch_size=10)
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)
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)
data['Species'] = data['Species'].astype("category")
data.dtypes
COLUMN_NAMES = [
'SepalLength',
'SepalWidth',
'PetalLength',
'PetalWidth',
'Species'
]
data = pd.read_csv('iris_data.csv', names=COLUMN_NAMES, header=0)
data.head()
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)
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')
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)
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'))