Blog KaryaVirtual

Gudang Pengetahuan Digital

The model in the Library Hard-Machine Learning

October 6, 2018 Machine Learning 0

There is one hard library used to build Python machine learning. The following step by step:

Import Library
from models import Sequentials hard.
from hard Dense import layers.

import numpy

Set Random Seed

seed = 9 numpy. random seed (9).

Import Data Sets

from read_csv import pandas dataframes = read_csv (' csv ' BBC.)  

Split the Output variables

array = dataframe. values X = array [, 0-10] y = array [:, 11]

Build A Model

On hard, the model is built layer per layer.

model = Sequential ()

models. add (Dense (11, input_dim = 11, init = ' uniform ', activation = ' relu '))

models. add (Dense (8, input_dim = 11, init = ' uniform ', activation = ' relu '))

models. add (Dense (8, input_dim = 11, init = ' uniform ', activation = ' relu '))

models. add (Dense (1, input_dim = 11, init = ' uniform ', sigmoid activation = '. '))

  In the example above, the neural network with sequential built up one of the input layer, two hidden layer and one output layer

Mengcompile Model

To execute such models need to be compiled as follows: model. compile it (loss = ' binary_crossentropy ', the optimizer = ' adam ', metrics = [' accuracy '])

Fitting Model

Fitting of the model is to load halman data into the model. models. fit (X, Y, nb_epoch = 50, batch_size = 10)

Score Model

scoring = model. evaluate (X, Y) print ("% s:% 2f%%"% (model. metrics_names [1], scoring [1] * 100)) The following is the complete code:

import hard
from models import Sequential hard.
from hard Dense import layers.
import numpy
 
numpy. random seed (9).

from read_csv import pandas

dataframes = read_csv ('/tmp/BBCN.csv ')

array = dataframes. values

X = array [:, 0:10]

Y = array [:, 11]

model = Sequential ()

models. add (Dense (10, init = 10, input_dim = ' uniform ', activation = ' relu '))

models. add (Dense (8, input_dim = 11, init = ' uniform ', activation = ' relu '))

models. add (Dense (8, input_dim = 11, init = ' uniform ', activation = ' relu '))

models. add (Dense (1, input_dim = 11, init = ' uniform ', sigmoid activation = '. '))



models. compile it (loss = ' binary_crossentropy ', the optimizer = ' adam ', metrics = [' accuracy '])

models. fit (X, Y, nb_epoch = 50, batch_size = 10)
scoring = model. evaluate (X, Y)

print ("% s:% 2f%%"% (model. metrics_names [1], scoring [1] * 100))

Leave a Reply

Your email address will not be published. Required fields are marked *