GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — DAT3/code/08_iris_class.py at master · justmarkham/DAT3 Expand file tree/ Copy path08_iris_class.pyMore file actions 51 lines (31 loc) · 1.17 KB / Copy path08_iris_class.pyFile metadata and controls51 lines (31 loc) · 1.17 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 ''' CLASS: "Human Learning" with iris data ''' from sklearn.datasets import load_iris import pandas as pd import numpy as np import matplotlib.pyplot as plt # load the famous iris data iris = load_iris() # what do you think these attributes represent? iris.data iris.data.shape iris.feature_names iris.target iris.target_names # intro to numpy type(iris.data) ## PART 1: Read data into pandas and explore # read iris.data into a pandas DataFrame (df), including column names # clean up column names # read into pandas again, with better column names # create a list of species (150 elements) using iris.target and iris.target_names # add the species list as a new DataFrame column # explore data numerically, looking for differences between species # explore data by sorting, looking for differences between species # explore data visually, looking for differences between species ## PART 2: Write a function to predict the species for each observation # create a dictionary so we can reference columns by name # define function that takes in a row of data and returns a predicted species # make predictions and store as numpy array # calculate the accuracy of the predictions |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |