{"id":17109,"date":"2022-08-23T13:27:47","date_gmt":"2022-08-23T07:57:47","guid":{"rendered":"https:\/\/copyassignment.com\/?p=17109"},"modified":"2022-12-05T16:22:21","modified_gmt":"2022-12-05T10:52:21","slug":"customer-behaviour-analysis-machine-learning-and-python","status":"publish","type":"post","link":"https:\/\/copyassignment.com\/customer-behaviour-analysis-machine-learning-and-python\/","title":{"rendered":"Customer Behaviour Analysis &#8211; Machine Learning and Python"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p>A company runs successfully due to its customers. Understanding the need of customers and fulfilling them through the products is the aim of the company. <br>Most successful businesses achieved the heights by knowing the need of customers and dynamically changing their strategies and development process.<\/p>\n\n\n\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-9886351916045880\" data-ad-slot=\"2002566052\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>Customer Behaviour Analysis is as important as a customer for a company or firm. It is a qualitative and quantitative observation of how customers interact with the company. It is important to ensure customers&#8217; needs and desires, contributing to customer loyalty and retention.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is Customer Analysis?<\/h2>\n\n\n\n<p>According to medium.com, <strong>Customer analytics<\/strong>&nbsp;is critical for gaining a thorough understanding of customers\u2019 purchasing habits, use trends, demographic distribution, and profitability. Organizations must devote a significant amount of time and resources to learning about their consumers and analyzing the data created by their interactions with them.<\/p>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong>How customer behavior analysis can be carried out? <\/strong><\/h3>\n\n\n\n<p>On a small scale or where the data is very less, this can be done manually by understanding the data.<\/p>\n\n\n\n<p>Wherein, cases, where the customer&#8217;s dataset is huge and it is almost impossible to look for individual rows manually and find some patterns from data, Machine Learning comes to the rescue!<\/p>\n\n\n\n<p>There are several built-in algorithms and models available in Machine Learning, making the analysis procedure at peak of easy.<\/p>\n\n\n\n<p>There are various frameworks designed and used by data scientists to carry out this analysis. One of the frameworks is,<\/p>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong><span style=\"text-decoration: underline\">STP<\/span><\/strong><\/h3>\n\n\n\n<p>STP stands for Segmentation, Targeting, and Positioning. It&nbsp;is a three-step marketing framework. With the STP process, it is easy to segment the market, target the customers, and position the offering to each segment.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-113.png\" alt=\"STP in Customer Behaviour Analysis\" class=\"wp-image-17113 lazyload\" width=\"467\" height=\"365\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-113.png 640w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-113-300x234.png 300w\" data-sizes=\"(max-width: 467px) 100vw, 467px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 467px; --smush-placeholder-aspect-ratio: 467\/365;\" \/><\/figure>\n\n\n\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-9886351916045880\" data-ad-slot=\"2002566052\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"text-decoration: underline\">Segmentation:<\/span><\/h4>\n\n\n\n<p>Segmentation<strong>&nbsp;<\/strong>is the process of dividing a population, potential or existing customers into groups with shared similar characteristics. This group will have comparable purchase behaviors. This Segment will likely respond to different marketing activities.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"text-decoration: underline\">Targeting:<\/span><\/h4>\n\n\n\n<p>Targeting deals with the evaluation of potential profits from segments and deciding which segments to focus on. Considering factors to determine where to extend to the whole segment or part of the segment.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span style=\"text-decoration: underline\">Positioning:<\/span><\/h4>\n\n\n\n<p>After deciding where to Target, positioning is next. Positioning in marketing is a strategic process that entails developing an identity of a brand or product in the mind of potential buyers.<\/p>\n\n\n\n<p>Customer segmentation with the STP framework can be carried out using PCA, Hierarchical Clustering, and K-Means Algorithm in Python using supported libraries like Numpy, Matplotlib, Seaborn, StandardScaler, Scipy, etc.<\/p>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong><span style=\"text-decoration: underline\">RFM<\/span><\/strong><\/h3>\n\n\n\n<p>RFM segmentation enables marketers to target specific groups of consumers with communications that are far more relevant to their individual behaviors. This practice results in much greater response rates and improved loyalty and customer lifetime value. <\/p>\n\n\n\n<p>RFM segmentation is an effective tool to identify groups of consumers who should be treated differently. RFM stands for Recency, Frequency, and Monetary.<\/p>\n\n\n\n<p>The advantage of RFM over other segmentation models is that it employs objective numerical scales to produce a high-level picture of consumers that is both succinct and instructive. Also, marketers can utilize it without expensive tools. And the most important factor, the segmentation method\u2019s output is simple to comprehend and analyze.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong><span style=\"text-decoration: underline\">Clustering<\/span><\/strong><\/h4>\n\n\n\n<p>Clustering is the unsupervised learning method. It is a technique where a group of data is partitioned into different clusters.  There are many popular algorithms for clustering like the K-means algorithm, Mean Shift, BIRCH, OPTICS, Special Clustering, etc. Each algorithm offers a different approach to the challenge of discovering natural groups in data.<\/p>\n\n\n\n<p>All the clusters are significantly different from each other while all the data elements inside the same clusters are of the same category. Distance-based clustering&nbsp;groups the points into some number of clusters such that distances within the cluster should be small while distances between clusters should be large.<\/p>\n\n\n\n<p>One of the most powerful and popular algorithms in Python, the K-means Clustering algorithm can be used to categorize data into clusters. <\/p>\n\n\n\n<p>For eg., if you want to target any particular type of customer for a new product, you can cluster the data into the corresponding categories and really try to find the patterns in between them. And then analyzing the output of various algorithms or PCA to come to a solution.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong><span style=\"text-decoration: underline\"> Logistic Regression<\/span><\/strong><\/h4>\n\n\n\n<p>Logistic Regression is a linear classifier, which predicts the outcome as a categorical value. Maybe True or False, 1 or 0, Human or Animal, etc. kinds of binary outcomes are predicted by logistic regression.<\/p>\n\n\n\n<p>On the basis of logistic regression, we can predict if the customer can have an interest in a particular product.<\/p>\n\n\n\n<p>For eg, here, we are going to understand in little depth by taking a problem statement and then generating the outcome related to customer behavior analysis.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Problem Statement:<\/strong> <\/h2>\n\n\n\n<p> A company wants to find out whether their old or new customer is interested in buying a car. We have to predict the possibility from the dataset given.<\/p>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong>The dataset:<\/strong><\/h3>\n\n\n\n<p>You can download the dataset from here: <a href=\"https:\/\/www.kaggle.com\/datasets\/rakeshrau\/social-network-ads\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.kaggle.com\/datasets\/rakeshrau\/social-network-ads<\/a><\/p>\n\n\n\n<p>In the dataset, we have UserID, Gender, Age, Salary, and a binary variable Purchased. Out of all these, UserID, Gender, Age and Salary are independent variables whereas if the customer has purchased the product is the dependent term.<\/p>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong>Approach:<\/strong><\/h3>\n\n\n\n<p>The marketing team can target only those customers who have the possibility to buy the products.<\/p>\n\n\n\n<p>Hence, we will predict 0 or 1 as outcomes representing whether the customer will buy a car or not.<\/p>\n\n\n\n<p>Let&#8217;s begin:<\/p>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong>Import the libraries:<\/strong><\/h3>\n\n\n\n<p>To preprocess data we&#8217;ll need,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import numpy as np\nimport matplotlib.pyplot as plt\nimport pandas as pd<\/code><\/pre>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong>Import the dataset:<\/strong><\/h3>\n\n\n\n<p>We need age and estimated salary as our independent variables, so we&#8217;ll only consider them as X. <\/p>\n\n\n\n<p>Y would be the dependent variable &#8216;Purchased&#8217; which has to be predicted<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dataset = pd.read_csv('Social_Network_Ads.csv')\n <\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\nX = dataset.iloc&#91;:, 2:4].values \ny = dataset.iloc&#91;:, -1].values<\/code><\/pre>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong>Split the dataset into train and test:<\/strong><\/h3>\n\n\n\n<p>We will use scikit learns train_test_split method to split our dataset into training and testing.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from sklearn.model_selection import train_test_split\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25, random_state = 0)<\/code><\/pre>\n\n\n\n<p>We can check the data, <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>print(X_train)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"401\" height=\"474\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-114.png\" alt=\"Output 1, x_train, Customer Behaviour Analysis in Python\" class=\"wp-image-17130 lazyload\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-114.png 401w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-114-254x300.png 254w\" data-sizes=\"(max-width: 401px) 100vw, 401px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 401px; --smush-placeholder-aspect-ratio: 401\/474;\" \/><figcaption class=\"wp-element-caption\">X_train<\/figcaption><\/figure>\n\n\n\n<p>We can see large rows of train data.<\/p>\n\n\n\n<p>Similarly, we can check X_test, y_train, and y_test.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"436\" height=\"519\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-115.png\" alt=\"Output 2, x_test, Customer Behaviour Analysis in Python\" class=\"wp-image-17131 lazyload\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-115.png 436w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-115-252x300.png 252w\" data-sizes=\"(max-width: 436px) 100vw, 436px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 436px; --smush-placeholder-aspect-ratio: 436\/519;\" \/><figcaption class=\"wp-element-caption\">X_test<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-116.png\" alt=\"Output 3, y_train, Customer Behaviour Analysis in Python\" class=\"wp-image-17132 lazyload\" width=\"439\" height=\"185\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-116.png 803w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-116-300x127.png 300w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-116-768x324.png 768w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-116-675x285.png 675w\" data-sizes=\"(max-width: 439px) 100vw, 439px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 439px; --smush-placeholder-aspect-ratio: 439\/185;\" \/><figcaption class=\"wp-element-caption\">y_train<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-117.png\" alt=\"Output 4, y_test, Customer Behaviour Analysis in Python\" class=\"wp-image-17133 lazyload\" width=\"466\" height=\"117\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-117.png 696w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-117-300x75.png 300w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-117-675x169.png 675w\" data-sizes=\"(max-width: 466px) 100vw, 466px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 466px; --smush-placeholder-aspect-ratio: 466\/117;\" \/><figcaption class=\"wp-element-caption\">y_test<\/figcaption><\/figure>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong>Feature Scaling:<\/strong><\/h3>\n\n\n\n<p><span style=\"text-decoration: underline\">What is feature scaling?<\/span><\/p>\n\n\n\n<p>Feature Scaling is a data pre-processing step and applied to independent variables or features of the data. It basically helps to normalize the data within a particular range. Sometimes, it also helps in speeding up the calculations in an algorithm.<\/p>\n\n\n\n<p>Here, it is not required but improving training performance is necessary.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from sklearn.preprocessing import StandardScaler\nsc = StandardScaler()\nX_train = sc.fit_transform(X_train)\nX_test = sc.transform(X_test)<\/code><\/pre>\n\n\n\n<p>Here, we are normalizing the train and test data.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>X_train<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"455\" height=\"541\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-118.png\" alt=\"x_train after normalization\" class=\"wp-image-17135 lazyload\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-118.png 455w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-118-252x300.png 252w\" data-sizes=\"(max-width: 455px) 100vw, 455px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 455px; --smush-placeholder-aspect-ratio: 455\/541;\" \/><figcaption class=\"wp-element-caption\">Normalized X_train<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>X_test<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"369\" height=\"477\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-119.png\" alt=\"x_testafter normalization\" class=\"wp-image-17136 lazyload\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-119.png 369w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-119-232x300.png 232w\" data-sizes=\"(max-width: 369px) 100vw, 369px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 369px; --smush-placeholder-aspect-ratio: 369\/477;\" \/><figcaption class=\"wp-element-caption\">Normalized X_test<\/figcaption><\/figure>\n\n\n\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-9886351916045880\" data-ad-slot=\"2002566052\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong>Build Model with Logistic Regression:<\/strong><\/h3>\n\n\n\n<p>When comes to Python, has all the powerful models built in, hence is no need to create anything from scratch. Just import the module and fit the data into it to train the model.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from sklearn.linear_model import LogisticRegression\nclassifier = LogisticRegression(random_state = 0)\nclassifier.fit(X_train, y_train)<\/code><\/pre>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong>Test result prediction:<\/strong><\/h3>\n\n\n\n<p>Let&#8217;s predict the result for the test data.<\/p>\n\n\n\n<p>We are comparing this prediction with our y_train i.e. original result to see how our model is doing.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>y_pred = classifier.predict(X_test)\nprint(np.concatenate((y_pred.reshape(len(y_pred),1),y_test.reshape(len(y_test),1)),1))<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-120.png\" alt=\"model prediction\" class=\"wp-image-17137 lazyload\" width=\"118\" height=\"388\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-120.png 191w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-120-91x300.png 91w\" data-sizes=\"(max-width: 118px) 100vw, 118px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 118px; --smush-placeholder-aspect-ratio: 118\/388;\" \/><figcaption class=\"wp-element-caption\">Model prediction<\/figcaption><\/figure>\n\n\n\n<p>Hmm, it is quite well. But how well? <\/p>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong>Accuracy score with Confusion Matrix:<\/strong><\/h3>\n\n\n\n<p>We&#8217;ll use the confusion matrix utility to calculate the accuracy of this model.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from sklearn.metrics import confusion_matrix, accuracy_score\ncm = confusion_matrix(y_test, y_pred)\nprint(cm)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"179\" height=\"50\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-121.png\" alt=\"confusion matrix\" class=\"wp-image-17138 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 179px; --smush-placeholder-aspect-ratio: 179\/50;\" \/><figcaption class=\"wp-element-caption\">Output<\/figcaption><\/figure>\n\n\n\n<p>Here, for test data, 65 is the correct prediction for class 0 i.e. not buy and 3 is incorrect for class 1 i.e. buy, and in training 8 is incorrect for class 0 and 24 is correct for class 1.<\/p>\n\n\n\n<p>Let&#8217;s calculate the accuracy score:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>accuracy_score(y_test, y_pred)<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>#Output\n0.89<\/code><\/pre>\n\n\n\n<p>Hurray! Our model is 89% true.<\/p>\n\n\n\n<p>Predict for new data:<\/p>\n\n\n\n<p>Let&#8217;s take the input value and depict what our model predicts:<\/p>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\"><strong>Predicting new results:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>age=int(input(\"Enter the age: \"))\nsalary = int(input(\"Enter the estimated salary: \"))\nresult = classifier.predict(sc.transform(&#91;&#91;age,salary]]))\nprint(result)<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"333\" height=\"74\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-122.png\" alt=\"predicting new results\" class=\"wp-image-17139 lazyload\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-122.png 333w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-122-300x67.png 300w\" data-sizes=\"(max-width: 333px) 100vw, 333px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 333px; --smush-placeholder-aspect-ratio: 333\/74;\" \/><figcaption class=\"wp-element-caption\">Output<\/figcaption><\/figure>\n\n\n\n<p>Let&#8217;s make the result more readable:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if result==&#91;1]:\n  print(\"Yay! This customer can buy a car!\")\nelse:\n  print(\"Sorry! It seems this customer won't buy a car\")<\/code><\/pre>\n\n\n\n<p>Let&#8217;s print the result again for the previous inputs.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"426\" height=\"29\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-123.png\" alt=\"making readable output\" class=\"wp-image-17140 lazyload\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-123.png 426w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-123-300x20.png 300w\" data-sizes=\"(max-width: 426px) 100vw, 426px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 426px; --smush-placeholder-aspect-ratio: 426\/29;\" \/><figcaption class=\"wp-element-caption\">Output<\/figcaption><\/figure>\n\n\n\n<p>Let&#8217;s run for one more,<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-124.png\" alt=\"checking modal finally\" class=\"wp-image-17141 lazyload\" width=\"460\" height=\"234\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-124.png 499w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/image-124-300x153.png 300w\" data-sizes=\"(max-width: 460px) 100vw, 460px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 460px; --smush-placeholder-aspect-ratio: 460\/234;\" \/><figcaption class=\"wp-element-caption\">Model Check<\/figcaption><\/figure>\n\n\n\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-9886351916045880\"\n     crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\"\n     style=\"display:block\"\n     data-ad-format=\"autorelaxed\"\n     data-ad-client=\"ca-pub-9886351916045880\"\n     data-ad-slot=\"7933252109\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>Seems great!<br>For more detailed info, you can check <a href=\"https:\/\/www.ris-ai.com\/predicting-customer-behavior-with-logistic-regression\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.ris-ai.com\/predicting-customer-behavior-with-logistic-regression<\/a><\/p>\n\n\n\n<p>This is how we can really use ML integrated with Python and build such analysis to set the target and retain the customers.<\/p>\n\n\n\n<p>Thank you for visiting, don&#8217;t forget to check <a href=\"https:\/\/www.violet-cat-415996.hostingersite.com\">violet-cat-415996.hostingersite.com<\/a><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>Also Read:<\/strong><\/p>\n\n\n<ul class=\"wp-block-latest-posts__list is-grid columns-3 wp-block-latest-posts\"><li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/flower-classification-using-cnn\/\">Flower classification using CNN<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/music-recommendation-system-in-machine-learning\/\">Music Recommendation System in Machine Learning<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/top-15-machine-learning-projects-in-python-with-source-code\/\">Top 15 Machine Learning Projects in Python with source code<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/gender-recognition-by-voice-using-python\/\">Gender Recognition by Voice using Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/top-15-python-libraries-for-data-science-in-2022\/\">Top 15 Python Libraries For Data Science in 2022<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/top-15-python-libraries-for-machine-learning-in-2022\/\">Top 15 Python Libraries For Machine Learning\u00a0in 2022<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/machine-learning-in-visual-studio-code\/\">Setup and Run Machine Learning in Visual Studio Code<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/diabetes-prediction-using-machine-learning\/\">Diabetes prediction using Machine Learning<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/15-deep-learning-projects-for-final-year\/\">15 Deep Learning Projects for Final year<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/machine-learning-scenario-based-questions\/\">Machine Learning Scenario-Based Questions<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/customer-behaviour-analysis-machine-learning-and-python\/\">Customer Behaviour Analysis &#8211; Machine Learning and Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/nxnxn-matrix-in-python-3\/\">NxNxN Matrix in Python 3<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/3-vs-of-big-data\/\">3 V&#8217;s of Big data<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/naive-bayes-in-machine-learning\/\">Naive Bayes in Machine Learning<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/automate-data-mining-with-python\/\">Automate Data Mining With Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/support-vector-machine-svm-in-machine-learning\/\">Support Vector Machine(SVM) in Machine Learning<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/convert-ipynb-to-python\/\">Convert ipynb to Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/data-science-projects-for-final-year\/\">Data Science Projects for Final Year<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/multiclass-classification-in-machine-learning\/\">Multiclass Classification in Machine Learning<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/movie-recommendation-system-with-streamlit-and-python-ml\/\">Movie Recommendation System: with Streamlit and Python-ML<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/getting-started-with-seaborn-install-import-and-usage\/\">Getting Started with Seaborn: Install, Import, and Usage<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/list-of-machine-learning-algorithms\/\">List of Machine Learning Algorithms<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/recommendation-engine-in-machine-learning\/\">Recommendation engine in Machine Learning<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/machine-learning-projects-for-final-year\/\">Machine Learning Projects for Final Year<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/ml-systems\/\">ML Systems<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/python-derivative-calculator\/\">Python Derivative Calculator<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/mathematics-for-machine-learning\/\">Mathematics for Machine Learning<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/data-science-homework-help-get-the-assistance-you-need\/\">Data Science Homework Help &#8211; Get The Assistance You Need<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/how-to-ace-your-machine-learning-assignment-a-guide-for-beginners\/\">How to Ace Your Machine Learning Assignment &#8211; A Guide for Beginners<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/top-10-resources-to-find-machine-learning-datasets-in-2022\/\">Top 10 Resources to Find Machine Learning Datasets in 2022<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>Introduction A company runs successfully due to its customers. Understanding the need of customers and fulfilling them through the products is the aim of the&#8230;<\/p>\n","protected":false},"author":62,"featured_media":17334,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,1137,1476],"tags":[],"class_list":["post-17109","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-allcategorites","category-machine-learning","category-ml-ai-ds-project","wpcat-22-id","wpcat-1137-id","wpcat-1476-id"],"_links":{"self":[{"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/posts\/17109","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/users\/62"}],"replies":[{"embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/comments?post=17109"}],"version-history":[{"count":0,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/posts\/17109\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/media\/17334"}],"wp:attachment":[{"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/media?parent=17109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/categories?post=17109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/tags?post=17109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}