<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by NeoxData on Medium]]></title>
        <description><![CDATA[Stories by NeoxData on Medium]]></description>
        <link>https://medium.com/@neoxData?source=rss-66c0307c0c24------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*BqAVjOxj4CPU1-8Y.jpg</url>
            <title>Stories by NeoxData on Medium</title>
            <link>https://medium.com/@neoxData?source=rss-66c0307c0c24------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:49:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@neoxData/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Using CRISP-DM framework on IMBd movies dataset]]></title>
            <link>https://medium.com/@neoxData/using-crisp-dm-framework-on-imbd-movies-dataset-43a88678c279?source=rss-66c0307c0c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/43a88678c279</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[crisp-dm]]></category>
            <dc:creator><![CDATA[NeoxData]]></dc:creator>
            <pubDate>Thu, 27 Jun 2019 16:10:10 GMT</pubDate>
            <atom:updated>2019-06-27T16:10:10.291Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9_KQTx8_Odmx_yQAwwvOzA.png" /><figcaption><a href="https://www.imdb.com/pressroom/brand-guidelines/">Source</a></figcaption></figure><p>In this post, I will use the CRISP-DM framework to get an answer about movies revenue prediction based on a IMBd dataset. I will answer the following questions:</p><ul><li>What is the total number of movies in different categories?</li><li>Which genres are most popular from year to year?</li><li>Which vote average got the 10 most expensive films in terms of budget?</li><li>Which is the highest budget and its revenue for a film categorized as drama?</li><li>Which director did more than 15 films above median revenue?</li><li>Can we predict the revenue of film based on director, budget, runtime, genres and vote average?</li></ul><p>First of all, let’s understand a bit better this framework which you have a full picture right below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*nGZULT8YJWhiu1F4IyUIDw.png" /><figcaption><a href="https://www.kdnuggets.com/2017/01/four-problems-crisp-dm-fix.html">Source</a></figcaption></figure><p>A lot of tools and techniques exist in the industry falling under the domain of data science. All frameworks have their pro and cons. However, one of the most common one is the CRISP-DM framework, stated for Cross-Industry Standard Process of Data Mining. It is a proven way to guide data mining effort.</p><p>The sequence of the phases is not strict. Many projects move back and forth between phases as necessary. It is flexible and can be customized easily.</p><p>The data mining life cycle goes in 6 steps:</p><h4>Business Understanding</h4><p>This is a very important step as it will drive all the subsequent processes. It is about to know your business problems. The question to be answered should be clearly stipulated and laser focused on your issues.</p><p>Here, I will try to answer if I can predict the revenue of a film based on specific features. It is an important question as movies require lot of budget, for example, <a href="https://metro.co.uk/2019/05/14/what-is-the-game-of-thrones-season-8-budget-9524749/">Game of Thrones season 8</a> around $90 million was spent. It is huge for a TV show of only 6 episodes.</p><h4>Data Understanding</h4><p>Business are nowadays gathering huge amount of data . It is critical to understand what has been collected and which data are required to solve our business problems.</p><p>As it is not possible to know before hand which data are useful or not, companies tend to collect all possible information, fearing to miss something useful for their insights in the future.</p><p>In our project, the dataset has more than 10&#39;000 entries with the following 21 parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*NXvoJlBwVPxHa8jM7SOBJw.png" /></figure><p>An row example :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*4gPm90tkVlmMJKujHIsvgQ.png" /></figure><p>As we can see there is some missing data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*4XOqS2RIfCQyPfqLexWwPw.png" /></figure><h4>Data preparation</h4><p>This part is about wrangling data. You need to select data and clean your dataset.</p><p>We dropped all useless columns and missing values. For the features like genres and directors, we saw multiple entries. I will separate them.</p><p>Now that I have cleaned the dataset, let’s see if we can answer to our questions stated at the beginning.</p><ul><li>What is the total number of movies in different categories?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*mUFT_Z0ydzDy5dz8WWitQg.png" /></figure><ul><li>Which genres are most popular from year to year?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*b1QI5znJvQ6TlottD_sk_Q.png" /></figure><p>According to our investigation we can see that the general trend is drama, comedy, thriller and action in fourth position. We can conclude that these kind of film are quite demanding from customers side. We have explored then what kind of genres is the most popular from year to year and we can see that drama is the most popular one throughout years followed by comedy.</p><ul><li>Which vote average got the 10 most expensive films in terms of budget?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*7pZy_XrO9zIHPTHWNdvVcQ.png" /></figure><ul><li>Which is the highest budget and its revenue for a film categorized as drama?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*_7yGkHa8kg826_3-4nqL5Q.png" /></figure><p>The most expensive film in terms of budget are The Warrior’s Way followed by Pirates of the Caribbean. We can see that the members rating is quite low and we can as an hypothesis say that a high budget film does not necessary mean a film that people like. Indeed, in the drama category, the highest budget (which is half of the most expensive one) returned a strong revenue.</p><ul><li>Which director did more than 15 films above median revenue?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*WjzZOb8ORIxbtp-A6v4WhA.png" /></figure><p>In general, according to this dataset, the directors producing more than 15 films with revenue higher than the mean are the most famous one like Spielberg, Scott, Howard and Eastwood. So it might be a good idea to bet on them to realize movies.</p><h4>Modeling</h4><p>In this step, you will choose and implement a model to use for your prediction. If this step is not successful, you might rework the data preparation part.</p><p>I have used an ensemble model i.e. a Random Forest. It is considered as a highly accurate and robust method because of the number of decision trees participating in the process. It also does not suffer from the overfitting problem. The main reason is that it takes the average of all the predictions, which cancels out the biases.</p><h4>Evaluation</h4><p>In this part, it is time to evaluate the model with metrics specific to the case under investigation. If we are not satisfied, we either rethink about our business requirement or to optimize the model.</p><p>With the above model I have reached a prediction success of 97%.</p><h4>Deployment</h4><p>If everything went well, I mean the evaluation and testing, the model is ready to be pushed into production and deployed.</p><p>In our case, the model is ready!</p><p>In this article, we used the CRISP-DM framework on a IMBd dataset to predict the revenue for a new film. The source code could be found in <a href="https://github.com/NeoxData/Crisp">GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43a88678c279" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to predict customer churn on huge dataset?]]></title>
            <link>https://medium.com/@neoxData/how-to-predict-customer-churn-on-huge-dataset-cd36ea15e3ac?source=rss-66c0307c0c24------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd36ea15e3ac</guid>
            <category><![CDATA[apache-spark]]></category>
            <dc:creator><![CDATA[NeoxData]]></dc:creator>
            <pubDate>Wed, 19 Jun 2019 19:13:58 GMT</pubDate>
            <atom:updated>2019-06-26T09:05:41.913Z</atom:updated>
            <content:encoded><![CDATA[<p>Using Apache Spark on a cluster hold by AWS EMR</p><p>The final Udacity project for the Data science NanoDegree program was to use Apache Spark on a huge dataset (12 GB) to predict if users will churn or not their subscriptions (both paid and free subscribers) in a fictional online music streaming service, Sparkify.</p><p>Every time, users are interacting with the service a lot of information is gathered (gender, bowser, playing songs, downgrading service, liking a song etc.).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0m_WnFIjyIuxnQSk7IO4Gg.png" /></figure><p>The project (available on G<a href="https://github.com/NeoxData/Sparkify">itHub</a>) has been separated in 2 parts. The first one had a small portion of the dataset (128MB) and was used to easily explore, clean and engineer. The second one used the full size which was not possible to be handle on a single computer. The platform Spark on AWS EMR (Amazon web Service Elastic MapReduce) makes it easy to handle this large dataset and reduce the time of computing.</p><p>The strategy was to first explore and clean on a subset then be applied to the entire dataset. We have choosen the logistic regression model as the target is binary (0 if the user cancels or 1 if not). If the metrics for the prediction we used is too low we will need to tune the model.</p><p>We will use the following metric:</p><p>Accuracy = (True Positives + True Negatives) / Dataset Size</p><p>However depending on the dataset, especially if imbalanced, F1 measure might be a better solution.</p><h3>Step 1: Load and explore data</h3><p>I have imported the necessary libraries and loaded a Spark session:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FzL55N9f0VCaSi1oYlskzA.png" /></figure><p>I noticed that the small dataset has 286&#39;500 log entries with 18 unique columns. These 286&#39;500 entries are not unique users, but rather a totality of transactions.</p><p>The dataset is structured as follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*C7c-xkGwJp4Ur_Qix8MYGw.png" /></figure><p>· <strong>Artist</strong>: The artist being listened to</p><p>· <strong>Auth</strong>: Whether or not the user is logged in</p><p>· <strong>FirstName</strong>: First name of the user</p><p>· <strong>Gender</strong>: Gender of the user</p><p>· <strong>ItemInSession</strong>: Item number in session</p><p>· <strong>LastName</strong>: Last name of the user</p><p>· <strong>Length</strong>: Length of time for specific log</p><p>· <strong>Level</strong>: Free or Paid user</p><p>· <strong>Location</strong>: Physical location of user</p><p>· <strong>Method</strong>: Get or Put requests (Web calls)</p><p>· <strong>Page</strong>: Which page are they on in the site</p><p>· <strong>Registration</strong>: Users registration number</p><p>· <strong>SessionId</strong>: Session ID</p><p>· <strong>Song</strong>: Song currently being played</p><p>· <strong>Status</strong>: Web status (200 for OK, etc.)</p><p>· <strong>Ts</strong>: Timestamp of current log</p><p>· <strong>UserAgent</strong>: Type of browser user is on</p><p>· <strong>UserId</strong>: UserID for user</p><p>A line of dataset contains the following information:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/1*CB6Bb5Xq4VnpM4TLY8jatw.png" /></figure><p>The page column:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*1LjO1KjNjoPLaMBV0xH8cg.png" /></figure><p>The interesting feature is “Cancellation Confirmation” in our case.</p><p>To have a better idea how the dataset is balanced, I have calculated the number of churned customers:</p><p>For the small dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*DTGIHlsoLbRJj38FLHHViw.png" /></figure><p>For the full one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*BN7j2TgXG33lWQ93eJl08A.png" /></figure><p>It is quite unbalanced, which might be problematic with our choosen metric.</p><p>Let’s see which artist has the most played songs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*54zwiYPThdnwgG6irN82Iw.png" /></figure><p>We can see below the repartition of customers by gender and level (subscription or not) on the small dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/918/1*sGgBaZxGkZlEqHFmxlhmmw.png" /></figure><p>A little overview of how many songs are played per hour by users on the small dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*qUiNRhmKBkridefhgsMYVA.png" /></figure><p>It appears that users listen music mostly during the afternoon.</p><h3>Step 2: Cleaning</h3><p>In this part, I will convert the necessary data to feed the machine learning model.</p><p>We will first drop all missing userID and keep only non empty one:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*lGhFkMoyuLZUBnbahdJ29g.png" /></figure><p>Then I have created a “Churn” column, which shall be referenced as anyone, whether a free or paid user, successfully completes the “Cancellation Confirmation” page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*fbWAKc_vD2q3fdTtrwaPgQ.png" /></figure><p>I have also created a column “hour” to have some information on when user has been logged:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/728/1*Efh2nTpuNk9HkOd1346ADg.png" /></figure><p>Finally, many columns are in string format which is not suitable for machine learning. Nevertheless I will not convert all of them but only those which are interesting.</p><h3>Step 3: Model</h3><h4>Implementation:</h4><p>It turns out that the column hour will not be really useful for the prediction so I dropped it. I have used the following features:</p><p>Gender, UserAgent, Page, Level and Churn</p><p>Depending on the results, I might engineer some features. As these columns are string, I will use String Indexer to convert them into integer.</p><p>I vectorized the results for each users but did not scale the values as they do not vary in high magnitude due to their meaning. It also happens it was not necessary according to our result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*dMtT9mFMh2dlgCbXcTj-jA.png" /></figure><h4>Splitting:</h4><p>I have splitted the dataset in 80/20 with a seed for replication. I built the model with a maximum iteration of 10 and a pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*_W6lCbrByUM1Tqopm3LDmw.png" /></figure><h4>Tuning:</h4><p>A parameter grid was used to determine the best value of parameters. I have choosen to only tweak one parameter to check quickly if I was heading to the right direction:</p><p>LogisticRegression regularization parameter: [0.0, 0.1]</p><p>I fed into the cross validator object using 3-fold cross-validation, the pipeline and model to get the best model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9FlYZoLD64UlVr8Vaz-z4w.png" /></figure><p>Finally I fit the data into the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/336/1*LuqXVjF88UyQ5t3QE9vD7w.png" /></figure><h4>Step 4: Metrics</h4><p>Results from small dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*EIbbOBdIX_B6rfXVhghkWQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*wslO3zDaZX6inA5gFrBf0g.png" /></figure><p>Results from full dataset:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*zy75gW0SXdCbjlqDbIc-pg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iu-KekXHYxdADPACgZUz8A.png" /></figure><h3>Conclusion</h3><p>From the result obtained I was quite surprised that only a small tuning of the model was able to produce such performance. In this case, the F1 measure was not useful. It reflects that the features choosen was very user specific and the model was able to generalize well.</p><p>It is difficult to see an improvement to be made but we might investigate if adding other features like month, hour, songs liked etc. would deprecate the model or not.</p><p>It was an interesting project for using Spark technologies coupled with the platform of AWS. Churning is a real live questionning for business and a big data challenge that faces all companies.</p><h3>Further readings:</h3><p><a href="https://towardsdatascience.com/handling-imbalanced-datasets-in-machine-learning-7a0e84220f28">Handling imbalanced datasets in machine learning</a> : explain what should be or not done with such datasets</p><p><a href="https://arxiv.org/abs/1904.00690">Customer churn prediction in telecom using machine learning and social network analysis in big data platform</a> : Churn prediction using 4 machine learning techniques</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd36ea15e3ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>