Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2
- # -*- coding: utf-8 -*-
- """
- Created on Wed Oct 26 11:11:36 2016
- @author: Kamalkhan
- """
- import numpy as np
- import csv
- import pandas as pd
- from sklearn import preprocessing
- from sklearn.cross_validation import train_test_split
- from sklearn.datasets import load_iris
- X = []
- Y = []
- dataset = load_iris()
- iris = pd.DataFrame(dataset.data)
- iris.columns = ["s.L", "s.W", "p.L", "p.W"]
- iris_normalized = preprocessing.normalize(iris)
- X = iris
- Y = dataset.target
- X_norm = iris_normalized
- def scatter_plot():
- ind = 0
- x = np.arange(4)
- ys = [i+x+(i*x)**2 for i in range(4)]
- colors = cm.rainbow(np.linspace(0, 1, len(ys)))
- for i in range(4):
- for j in range(i+1,3):
- print 'Correlation between'+str(X.columns[i]) +' and '+str(X.columns[j])
- print 'Correlation: '+ str((pearsonr(np.array(X)[:,j], np.array(X)[:,i])[0]))
- for feature,target in zip(np.array(X)[:,j], np.array(X)[:,i]):
- plt.scatter(feature,target,color=colors[ind])
- ind+=1
- plt.legend()
- plt.show()
- def norm_scatter_plot():
- ind = 0
- x = np.arange(4)
- ys = [i+x+(i*x)**2 for i in range(4)]
- colors = cm.rainbow(np.linspace(0, 1, len(ys)))
- for i in range(4):
- for j in range(i+1,3):
- print 'Correlation between'+str(X.columns[i]) +' and '+str(X.columns[j])
- print 'Correlation: '+ str((pearsonr(np.array(X)[:,j], np.array(X)[:,i])[0]))
- for feature,target in zip(np.array(X_norm)[:,j], np.array(X_norm)[:,i]):
- plt.scatter(feature,target,color=colors[ind])
- ind+=1
- plt.legend()
- plt.show()
- print 'After normalization-->'
- scatter_plot()
- print 'Before normalization-->'
- norm_scatter_plot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement