# 02#Machine Learning: Brazilian E-commerce Predictions

### Kaggle Dataset Brazilian E-Commerce

Photo by [rupixen.com](https://unsplash.com/@rupixen?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)

### 1\. Dataset from Kaggle

#### Brazilian E-Commerce Public Dataset by

[**Brazilian E-Commerce Public Dataset by Olist**  
*100,000 Orders with product, customer and reviews info*www.kaggle.com](https://www.kaggle.com/olistbr/brazilian-ecommerce "https://www.kaggle.com/olistbr/brazilian-ecommerce")[](https://www.kaggle.com/olistbr/brazilian-ecommerce)

Welcome! This is a Brazilian ecommerce public dataset of orders made at [Olist Store](http://www.olist.com/). The dataset has information of 100k orders from 2016 to 2018 made at multiple marketplaces in Brazil. Its features allows viewing an order from multiple dimensions: from order status, price, payment and freight performance to customer location, product attributes and finally reviews written by customers. We also released a geolocation dataset that relates Brazilian zip codes to lat/lng coordinates.

This is real commercial data, it has been anonymised, and references to the companies and partners in the review text have been replaced with the names of Game of Thrones great houses.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834582367/T_lI36X26.png)

### 2\. Brazilian E-Commerce Study by Statisca.com

[**Topic: E-commerce in Brazil**  
*In July 2020, Mercado Livre - the name in Portuguese for Argentine e-commerce giant Mercado Libre - was the most…*www.statista.com](https://www.statista.com/topics/4697/e-commerce-in-brazil/#dossierKeyfigures "https://www.statista.com/topics/4697/e-commerce-in-brazil/#dossierKeyfigures")[](https://www.statista.com/topics/4697/e-commerce-in-brazil/#dossierKeyfigures)

After a year marked by unparalleled mobility restrictions, online shopping in Brazil is even bigger and more mobile-oriented. The [largest e-commerce market in Latin America](https://www.statista.com/forecasts/256166/regional-distribution-of-b2c-e-commerce-in-latin-america) rose to the occasion and turned the sour lemons of the COVID-19 outbreak into a profitable, home-delivered lemonade. In 2020, its [online shopping revenue](https://www.statista.com/statistics/222115/online-retail-revenue-in-brazil-projection/) amounted to 126.3 billion Brazilian reals, more than twice as much as two years earlier. [Sales through mobile devices](https://www.statista.com/statistics/804001/mobile-desktop-e-commerce-sales-brazil/) — known as m-commerce — generated most of the South American country’s e-commerce revenue in 2020, a trend set to increase in the near future. As the protagonists of these changing times, the major players in this industry benefited from the coronavirus pandemic, and now the competition is tighter than ever.

### 3\. Python Code

[**Ecommerce-Brazilian-Predictions**  
*Explore and run machine learning code with Kaggle Notebooks | Using data from Brazilian E-Commerce Public Dataset by…*www.kaggle.com](https://www.kaggle.com/viannaandresouza/ecommerce-brazilian-predictions "https://www.kaggle.com/viannaandresouza/ecommerce-brazilian-predictions")[](https://www.kaggle.com/viannaandresouza/ecommerce-brazilian-predictions)

#### 1\. Python Enviroment

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834584022/wZjIn-mjRE.png)

#### 2\. Data Science Libraries

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834585430/YuEwcyFFU.png)

#### 3\. Import E-Commerce Dataset

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834586959/16gmQmyCJ.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834588262/71hg3yIEO.png)

#### 4\. Store Dataset on Python Space

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834589513/M2kYpowjD.png)

#### 5\. Exploration Data Analysis

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834591325/6oPKXPpKL.jpeg)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834592704/73d2cAb7G.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834594543/rAc9jL4gr.png)

#### Pandas Statistics Description

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834596087/V-J_aiQJ9.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834597402/3sm1bS_gY9.png)

#### What are the cities with the most sales ?

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834600812/MkblhdxD7.jpeg)

Photo by [Adrian Schwarz](https://unsplash.com/@aeschwarz?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834602433/T3DDxUOBr.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834603846/Eq8DGlPhL.png)

#### How many cities to buy through e-commerce in Brazil ?

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834605109/SgM7PqoxB.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834606725/G_D2icDA-.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834608029/6q7eWXfyZ.png)

#### Consumers by state

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834615698/T3Z5fklHT.jpeg)

Photo by [abillion](https://unsplash.com/@abillion?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834617144/k-x1ZEnu0.png)

#### Total States with Consumers

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834618527/NnhQertkw.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834619849/yZ81GTUNx.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834621316/FjDtP4MEP.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834623071/ahF4S1Fn1Q.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834624496/lwBAQQKGz.png)

### Analyis of products and items

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834626371/g1EgLB7qF.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834627772/p2AXC5Xda.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834629245/OSshEYyux.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834630617/q_yCqDsgL.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834631985/iRz0KyT8U.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834633403/XTmTfCe0t.png)

### Payments Analysis

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834638208/4uOkYAFLH.jpeg)

Photo by [David Dvořáček](https://unsplash.com/@dafidvor?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834639711/wse8nVDB5.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834641174/2zh_pYp1cE.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834642496/w2lUKfVOK.png)

#### Out of 5 types of methods, credit card is used on the top, then boleto and then voucher

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834643836/DK-YuAe4X.png)

#### Since this is a series object we can draw a histplot using its index and values

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834645029/G6XCz7hdN.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834646357/eZIpVUzb1.png)

From the above bar graph we can see that,uses of Credit Card is the highest aroud 75000, then boleto that is slightly less than 20000,

### Products Reviews

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834651490/_si7yvXegE.jpeg)

Photo by [Petrebels](https://unsplash.com/@petrebels?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834653033/x1h_P2YkR.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834654455/oL9Pk644n.png)

#### We can join it based on order\_id column which is common to both, for this we will make another dataframe named “reviews\_df”

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834655939/PnsdDREGS.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834657346/WNF4IeSsj.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834658639/d7a5Dvh5i.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834659971/hAwScxofX.png)

Most of the products have been rated 5,then 4. also 1 rating is higher than 2 and 3

### Top Ten rated products

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834661443/4My9u0KF4.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834662941/swMiAifDu.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834664504/8CG9ExZ_z.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834669628/d1xOPWi2R.jpeg)

Photo by [Marcin Jozwiak](https://unsplash.com/@marcinjozwiak?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834671180/LUSsPwpfN.png)

#### Music, dvd, and cds category have the highest average ratings. after tha infant’s fashion clothes come.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834672858/HTclqFoMr.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834674587/o40k8x0bW.png)

#### Insurance Services have the worst ratings, followed by fraldas higiene products

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834676018/-ffrofCwK.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834677445/EAt3NICJmH.png)

#### Brazilian Delivery Ecommerce

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834678725/72U2wUpc4H.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834680443/Bz0ABPLXLK.png)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1662834684111/w68i6Aw2E.jpeg)

Photo by [Bannon Morrissy](https://unsplash.com/@bannon15?utm_source=medium&utm_medium=referral) on [Unsplash](https://unsplash.com?utm_source=medium&utm_medium=referral)

#### Cities with a history of ecommerce deliveries in Brazil

There are 8011 unique city from geolocation data.
