Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sanathvernekar authored Jan 25, 2018
1 parent 3ac5495 commit dfb32f5
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions Activity1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import numpy as np
import pandas as pd
import os
import matplotlib.pyplot as plt

def dist(x,y):
Expand All @@ -33,7 +34,10 @@ def mode(arr) :
y=np.array(dfs.iloc[0:,2])
#print(len(y))


print("Initial Plot of Customer Distribution")
plt.figure(1)
plt.scatter(x,y)
plt.show()



Expand Down Expand Up @@ -68,10 +72,7 @@ def mode(arr) :



print("Initial Plot of Customer Distribution")
plt.figure(1)
plt.scatter(x,y)
plt.show()

#since much of the data lies in the centre i.e 150/170 points lie at the centre therefore
#It would be better if we consider Median rather than mean ,since we have 20 outliers here
#Here in our case these outliers are far from the centre ,so we will consider Median
Expand All @@ -80,11 +81,14 @@ def mode(arr) :
baseradius=dist(medianx,mediany)
print("Our New Base Location should be X= ",medianx," Y=",mediany,",to gain max customers")
print("\n")

temp=dist((medianx),(mediany))
print("Distance from initial location to New base location is",temp)

#Retaining Maximum Customers within redius of 2 km
custx=[]
custy=[]
clist=[]
temp=dist((medianx),(mediany))
print("Distance from initial location to New base location is",temp)
#myarr=[]
print("\n")
l=len(x)
Expand All @@ -111,34 +115,40 @@ def mode(arr) :
custy=np.array(custy)
#myarr=np.array(myarr)



df=pd.DataFrame(clist)
df.to_excel("Activity_1_Retain.xlsx", sheet_name='Retained Customers',index=False)

df=pd.DataFrame(tcust)
df.to_excel("Activity_1_Transfer.xlsx", sheet_name='Transferred Customers',index=False)


print("Retained Customers Graph")
print("Retained Customers plot")
plt.figure(2)
plt.scatter(custx,custy)
plt.show()

print("transferred Customers Plot")

tcustx=[]
tcusty=[]
for i in range(tcustlen):

tcustx.append(x[tcust[i]-1])
tcusty.append(y[tcust[i]-1])

print("transferred Customers Plot")
plt.figure(3)
plt.scatter(tcustx,tcusty)
plt.show()



df=pd.DataFrame(clist)
try:
df.to_excel("Activity_1_Retain.xlsx", sheet_name='Retained Customers',index=False)
print("Activity_1_Retain.xlsx file is successfully saved in ",os.getcwd(),"directory")
except:
print("Could not save file")
df=pd.DataFrame(tcust)
try:
df.to_excel("Activity_1_Transfer.xlsx", sheet_name='Transferred Customers',index=False)
print("Activity_1_Transfer.xlsx file is successfully saved in ",os.getcwd(),"directory")
except:
print("Could not save file")



"""
#Manual removal of Outliers
Expand Down

0 comments on commit dfb32f5

Please sign in to comment.