Plot not working
John Ladasky
john_ladasky at sbcglobal.net
Sat May 5 01:28:58 EDT 2018
On Friday, May 4, 2018 at 9:13:02 PM UTC-7, Sharan Basappa wrote:
> I am new to Python and using it to learn machine learning.
>
> Below is a sample program I am running to plot IRIS data set.
> The code runs but no plot comes up. I am not sure what the issue is with the code.
>
> # Imports
> from matplotlib import pyplot as plt
> from sklearn.datasets import load_iris
> import numpy as np
>
> # load the data with load_iris from sklearn
> data = load_iris()
> features = data['data']
> feature_names = data['feature_names']
> target = data['target']
>
> #print("features\n",features)
> #print("feature names\n",feature_names)
> #print("target\n",target);
> #print("data\n",data)
>
> for t,marker,c in zip(range(3),">ox","rgb"):
> # plot each class on its own to get different colored markers
> plt.scatter(features[target == t,0],
> features[target == t,1],
> marker=marker,
> c=c)
Try adding a call to plt.show() at the end.
More information about the Python-list
mailing list