0% found this document useful (0 votes)
14 views3 pages

Prediction Using ANN

Uploaded by

agwonadavid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views3 pages

Prediction Using ANN

Uploaded by

agwonadavid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#Prediction using ANN

#importing libraries

import pandas as pd # data minupulation and analsysis

#import numpy as np # matrices, arrrays

from [Link] import LabelEncoder, StandardScaler # StandardScaler is used to


standardize dataset resources,

#LabelEncoder - used to encode categorical labels into numeric


values

from sklearn.model_selection import train_test_split # is used to split the dataset into training and test
sets

import tensorflow as tf #is a popular framework for building and training machine learning models

from [Link] import Sequential # is a sequential model where the layers are linearly stacked

from [Link] import Dense # defines a dense (fully connected) layer of the neural
network

from [Link] import Dropout # is used to add dropout layers to avoid overfitting

#Loading Data

data= pd.read_csv("[Link]")

[Link]()

#Splitting the data into training and testing sets

X = [Link]('Outcome', axis =1)

Y = data['Outcome']

Xtrain, xtest, Ytrain, ytest = train_test_split(X,Y, test_size =0.2)

# data has been splitted , 20% - testing and 80 training


#Standardized data

scaler = StandardScaler()

Xtrain = scaler.fit_transform(Xtrain)

xtest = [Link](xtest)

#Creating training model

model = Sequential([

Dense(32, activation = 'relu', input_shape = ([Link][1],)),

Dropout(0.1),

Dense(32, activation = 'relu'),

Dropout(0.5),

Dense(1, activation = 'sigmoid')

])

#Model Compilation and summary

[Link](loss = 'binary_crossentropy', optimizer = 'adam', metrics = ['accuracy'])

[Link]()

#Training Model

[Link](Xtrain, Ytrain, epochs = 10, batch_size = 16, validation_data = (xtest, ytest))

#Model Results

loss, accuracy = [Link](xtest, ytest)


print(f'Test loss: {loss:.4f}')
print(f'Test accuracy: {accuracy:.4f}')

You might also like