Posts

Showing posts from 2017

Creating Neural Network using Keras

This blog gives step by step procedure for creating your own neural network using Keras in Python.Some prerequisites for this procedure are: Data is available in csv(comma separated Values) file format. python 3.x is installed on system and includes packages keras, pandas and numpy.  The steps are as follows: Load Data: import statement: import pandas as pd data = pd.read_csv(filename.csv) Processing Data: There are different possible steps to make data in the form we want to provide to neural network for training as well as for its functionality.But here most commonly used steps are mentioned. One Hot Encoding:  Represents all categorical variables as binary vectors. Each integer value is represented as binary vector where index of integer is marked as 1 while other values are marked as zeroes syntax is: processedData = pd.get_dummies(DataToEncode, ColumnNameWithWhichToEncode)  Normalise all data to make sure that all values are in between 0 and 1. ...

Supervised ML - Naive Bayes

Steps for Naive Bayes using sklearn(Python): Import GaussianNB: from sklearn.naivebayes import GaussianNB  Create classifier: clf = GaussianNB() Fit the classifier: clf.fit(FeatureTrainingSet,LabelTrainingSet) Prediction for testing data clf.predict(FeatureTestingSet) Accuracy is one of the metrics to check fitting of model over available dataset.There are 3 ways to check accuracy Manually calculating number of correctly predicted data set upon all dataset. Using accuracy_score metrics: import statement should be: from sklearn_metrics import accuracy_score wherever you want to check accuracy : print accuracy_score(NumpyArrayToBePredicted, labelledArray) Advantage is that you can use other available metrics as well.   Using Classifier Score: clf.score(FeatureDataTobePredicted,labelledArray) It will calculate predictions for provided data and then calculates accuracy for that data. Advantage is that you don't need to calculate predictions separa...