<jupyter_start><jupyter_text>Ecommerce Describe:**This is an ecommerce business but also have consulting sessions. The clients go to the store, meets personal stylist and go home to buy using an app or a website. The company wanna know if the website or app is better to invest**<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
sns.set_style('whitegrid')<jupyter_output><empty_output><jupyter_text>Data Collection Goals     AVG Session Lenght (in consulting)   Time on App (in minutes)   Time on Website (in minutes)   Lenght of Membership (how many years)<jupyter_code>file = "//home//vinicius//Data_Science//Notebooks//Data_Files//Ecommerce Customers"

df1 = pd.read_csv(file)
df1.head()
df1.info()
df1.describe()<jupyter_output><empty_output><jupyter_text>Create new df without object datas<jupyter_code>columns = list(df1.columns)
columns = [e for e in columns if e not in ('Address', 'Email','Avatar')]
df2= df1[columns]
df2.head()
sns.jointplot(x='Time on Website', y='Yearly Amount Spent', data=df2)
sns.jointplot(x='Time on App', y='Yearly Amount Spent', data=df2) ## app spends seens more linear than site
sns.jointplot(x='Time on App', y='Length of Membership', kind='hex',data=df2)
sns.pairplot(df2) ## length of membership vs year waste looks good
sns.lmplot(x='Length of Membership', y='Yearly Amount Spent', data=df2)
columns = list(df2.columns)
columns.remove('Yearly Amount Spent')

x = df2[columns]
y = df2['Yearly Amount Spent']
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn import metrics
x_train, x_test, y_train, y_test = train_test_split(x,y,test_size=0.3,random_state=101)
lm = LinearRegression()
lm.fit(x_train,y_train)
lm.coef_
predict = lm.predict(x_test)
## Scatter y_test by predict
plt.figure(figsize=(8,6))
ax = sns.scatterplot(y_test,predict)
ax.set(xlabel='Y test', ylabel='predict')
print('MAE:', metrics.mean_absolute_error(y_test,predict))
print('MSE:', metrics.mean_squared_error(y_test,predict))
print('RMSE:', np.sqrt(metrics.mean_squared_error(y_test,predict)))
sns.distplot(y_test-predict) ## looks like a normal, ok
coef = pd.DataFrame(lm.coef_, x.columns, columns=['Coefs'])
coef<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12140992167101827, 'fraction_numerical': 0.010008703220191472, 'mean_word_length': 6.84641638225256, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '177559', 'license': 'MIT', 'n_tokens_mistral': 818, 'n_tokens_neox': 800, 'n_words': 219, 'path': 'Regressions_Simulated_Data/02 - Linear Regression(EcommerceCustomers).ipynb', 'repo_name': 'vinicvaz/Notebooks', 'size': '2298'}