Skip to main content

Posts

Showing posts from June, 2018

Simple Tensorflow example on iris dataset

This one trains the DNN on iris and also create confusion matrix. Comments will help you know what is happening. === #imports from __future__ import absolute_import from __future__ import division from __future__ import print_function import tensorflow as tf import numpy as np import pandas as pd from sklearn.model_selection import train_test_split # Load data # Download it from here : https://archive.ics.uci.edu/ml/datasets/iris. Ensure that the categories are #labeled as Iris-setosa, Iris-virginica, Iris-versicolor and their column name as Species. iris = pd.read_csv("irisdata.csv") # explore what is loaded #print(iris.shape) #print(iris.head) # Convert the data type of columns to float32 type #print(iris.dtypes) #print(iris.iloc[:,0:4]) iris.iloc[:,0:4] = iris.iloc[:,0:4].astype(np.float32) #print(iris.dtypes) # encode the classes to numeric values iris["Species"] = iris["Species"].map({"Iris-setosa":0,"