An ecommerce company based in New York City sells clothing online and they also have in-store style and clothing advice sessions.
Python, Pandas, Numpy, Seaborn, Scikit-learn
Based on a customer dataset given by the company, find out whether the company should focus on developing
their
mobile app or web app to best serve the customers that will
, in turn, generate the most profit for the company.
Let's begin!
Let's read in the dataset
import pandas as pd
customers = pd.read_csv("ecomm_customers")
list(customers.columns)
import seaborn as sns
sns.heatmap(customers.corr(), annot=True)
sns.jointplot(x="Time on App", y="Yearly Amount Spent", data=customers)
sns.jointplot(x="Time on Website", y="Yearly Amount Spent", data=customers)
from sklearn.model_selection import train_test_split
y = customers['Yearly Amount Spent']
X = customers[['Avg. Session Length', 'Time on App', 'Time on Website', 'Length of Membership']]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)
from sklearn.linear_model import LinearRegression
lm = LinearRegression()
lm.fit(X_train, y_train)
predictions = lm.predict(X_test)
from sklearn import metrics
import numpy as np
print("RMSE:", np.sqrt(metrics.mean_squared_error(y_test, predictions)))
coeffs = pd.DataFrame(lm.coef_, X.columns)
coeffs.columns = ['Coefficient']
coeffs
The End.
I hope you enjoyed the reading. <3