<?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 Iyi Obiechina on Medium]]></title>
        <description><![CDATA[Stories by Iyi Obiechina on Medium]]></description>
        <link>https://medium.com/@iyi_bobby?source=rss-b992c9d07a87------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*hkM5oF8U_h5iI8t3Q3FV3Q.jpeg</url>
            <title>Stories by Iyi Obiechina on Medium</title>
            <link>https://medium.com/@iyi_bobby?source=rss-b992c9d07a87------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 06:01:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iyi_bobby/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[Observability in Data Engineering]]></title>
            <link>https://medium.com/@iyi_bobby/observability-in-data-engineering-0db90e4fcfbe?source=rss-b992c9d07a87------2</link>
            <guid isPermaLink="false">https://medium.com/p/0db90e4fcfbe</guid>
            <category><![CDATA[analytics-engineering]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[dataops]]></category>
            <dc:creator><![CDATA[Iyi Obiechina]]></dc:creator>
            <pubDate>Tue, 28 May 2024 21:50:03 GMT</pubDate>
            <atom:updated>2024-05-29T08:34:54.730Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*mIaiSyDazn6zfyr3" /></figure><p>In recent years, observability has become an important part of DevOps and software engineering. Devops — a methodology based on the principles of agile software development — aims to shorten the development lifecycle and deliver reliable software applications to customers. DevOps achieves this by automating the software development and deployment process, and by breaking down silos between different business teams. However, to maximise Devops’ benefits, it is important that engineers use observability tools to gain insight into the health of software infrastructure.</p><p>Due to the success of DevOps, its principles have gained traction among data driven organizations, who implement them across the entire data lifecycle, from data collection to insight delivery. As a result, observability is important to ensure data pipelines are reliable and healthy.</p><h4><strong>What is Observability?</strong></h4><p>Observability is a concept that originates from control theory, a field of applied mathematics that studies systems. In that field, Observability describes how well the internal state of a system can be inferred from its external outputs. For instance, it may be difficult to know exactly how fast a chemical reaction is occurring, but by measuring temperature we can build models to better understand the process.</p><p>In DevOps, observability describes the current state of a software system based on the data generated by endpoints and services in the computing environment. Observability is especially critical in distributed cloud computing, where the probability for failure increases with the number of disparate components. For example, some services run using hundreds of microservices that handle different phases of a request lifecycle, and communicate with each other.</p><p>There are 3 commonly listed<em> </em>pillars of observability in DevOps:</p><p>· Metrics: measurements gathered <strong>over a period. </strong>e.g. the number of customer requests</p><p>· Logs: detailed records of system activities or <strong>discrete events</strong>. These can be in multiple formats such as plain text and JSON records.</p><p>· Traces: visualizing the lifecycle of requests as they move between systems.</p><p>Observability works when the data from these 3 pillars is transformed into insight by engineers.</p><h4><strong>Data Observability</strong></h4><p>Data observability describes the health of data across multiple resources in a company’s system. While DevOps observability tools may be employed in ensuring the reliability of the distributed systems that store, process and deliver this data, data observability is solely concerned with the health of the data itself.</p><p>The aim of data observability is to prevent the system from producing bad quality (inaccurate, partial, erroneous or missing) data. Bad quality data can be<a href="https://www.aporia.com/blog/unity-software-ml-fault-causes-stock-drop/"> especially costly</a> since the insight derived from it is key in decision making. Like DevOps, data engineering makes use of observability tools to continuously assess data health.</p><p>There are 5 commonly listed<em> </em>pillars of data observability; <strong>freshness, lineage, volume, schema and distribution</strong>. But in this article, we’ll consider a paradigm that takes more direct inspiration from the DevOps pillars and simultaneously covers the earlier mentioned pillars. We’ll examine 4 pillars of data observability:</p><ul><li>Metrics</li><li>Metadata</li><li>Lineage</li><li>Logs</li></ul><p><strong>Metrics</strong></p><p>These are the internal characteristics of the data, including summary statistics like the mean, standard deviation and distribution. They are important in detecting anomalies and outliers over a given period, especially if the data is expected to conform to a certain range or pattern.</p><p><strong>Metadata</strong></p><p>These are external characteristics of the data. It could also be understood as “data about data“ but is independent of the data itself. This includes schema, volume and data freshness. Data schema is the organization of our data and any changes to the schema could lead to broken pipelines. For instance, if a retail chain begins to collect customer phone numbers as part of a loyalty program, a sudden introduction of a phone_number column to the schema without updating the data pipeline could cause some extraction and transformation processes to fail.</p><p>Data freshness describes how up-to-date your data tables are, as well as how frequently they are updated. For an e-commerce platform, sales data may need to be refreshed every hour, if data ingestion is behind this target the impressions or conclusion drawn on the sales performances are effectively false.</p><p>Volume tracks the amount of data flowing through the system, detecting drops or spikes which could indicate problems like missing or duplicate data<strong>. </strong>If a social media app processing 10gb worth of customer interactions daily suddenly drops to 2gb, it could indicate a failure in the data extraction process. Conversely, if a spike from a 2gb average to 10gb happened, it could be signs of duplicate data or even a bug in the data source.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/0*l4UCsRBGBn0fX9xb" /><figcaption>Metadata for a table in the intermediate layer showing its current schema</figcaption></figure><p><strong>Lineage</strong></p><p>Data lineage tracks the flow and transformation of data from source systems to the delivery layer. This shows the dependency of downstream datasets on upstream datasets and the level of abstraction between tables and columns in source and destination systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*yMvkAD6z_UhN2cgZ" /><figcaption>Data lineage map showing the table dependencies from source system to data mart.</figcaption></figure><p>You may have noticed the similarities between data lineage and traces in that they both visualize relationships between units of a system. However, while traces focus on real time individual requests to monitor application performance, data lineage provides a high-level representation of data movement and transformation in the data pipeline. The data lineage map provides the exact point in the data lifecycle where bad quality originates.</p><p><strong>Logs</strong></p><p>Like metadata that captures the external state of data, logs describe how data interacts with external systems. This includes information on discrete time events like when models are created or run. It also provides information on the attributes of operations such as model runtime. This information helps engineers monitor the efficiency of replications or transformations and understand how models are performing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*heFDrj3N_OflQUoS" /><figcaption>Logs displaying model runtimes and fail rate</figcaption></figure><p>By analyzing logs, engineers can track the sequence of operations and identify possible bottlenecks or points of failure. While lineage can track failure in terms of lifecycle, logs track failure in terms of runtime.</p><h4><strong>Monitoring vs Observability</strong></h4><p>Although most data observability tools offer features for monitoring, they are not the same.</p><p>Data monitoring involves constantly checking data using pre-defined metrics and alerting engineers when those metrics cross acceptable thresholds. Monitoring begins with the assumption that you know where failure could occur, hence the predetermined metrics and their thresholds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*jYZx7QnzirK0B6yo" /><figcaption>Monitoring dashboard with an overview of preconfigured tests.</figcaption></figure><p>Data observability tools provide the data to <em>discover </em>failure and understand <em>why </em>it occurred. The discoveries made from observability engineering can then be used to design the metrics and thresholds for monitoring the system. Data observability acts as the starting point for good data monitoring. But how does this benefit organizations in the wild?</p><p>Before 2022, the analytics engineers at <a href="https://seatgeek.com/">SeatGee</a>k could only find out about bad-quality data in their pipelines if business users contacted them. The engineering team had limited capacity to identify failure before it became apparent at delivery.</p><p>The director of engineering decided to integrate observability into their data engineering process by setting up <a href="https://www.montecarlodata.com/">Monte Carlo</a> for the data platform and analytics engineering teams. As a result, the analytics engineering team can detect and resolve root cause issues quickly within the development environment. Monte Carlo was able to identify that there was a schema change in the data coming from a 3rd party system they had no control over. Consequently, the engineering team could reliably inform the stakeholders of the changes they could expect to their data.</p><p>With data observability, the team discovered they had lost connection to some of their marketing data sources. As a result of Monte Carlo’s data lineage map, they can keep track of all their data sources and dependencies. In addition to identifying problems, data observability has helped the team understand where problems are most likely to occur, and as a result, they have invested effort into testing and monitoring these points.</p><p>Embracing data observability offers significant advantages to any organization. But most importantly, it builds trust in the data delivered to business users and enables confident decision-making.</p><p><em>(Images provided are from elementary-data, an open source dbt-native data observability platform. The data models observed in those images were built on dbt and can be viewed </em><a href="https://github.com/obie-china/data-observability-dbt"><em>here</em></a><em>)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0db90e4fcfbe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data warehouse Analytics Requirements: Wide table vs dimensional modelling]]></title>
            <link>https://medium.com/@iyi_bobby/data-warehouse-analytics-requirements-wide-table-vs-dimensional-modelling-a46ae6f61807?source=rss-b992c9d07a87------2</link>
            <guid isPermaLink="false">https://medium.com/p/a46ae6f61807</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[data-modelling]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-warehousing]]></category>
            <dc:creator><![CDATA[Iyi Obiechina]]></dc:creator>
            <pubDate>Sun, 05 May 2024 17:47:38 GMT</pubDate>
            <atom:updated>2024-05-05T17:47:38.926Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*9mGkCRDRNzh8ePfU" /></figure><p>There’s a lot to consider when modelling a cloud data warehouse — performance and storage optimization, cost management, maintainability, and scalability. As is common with software architecture there is hardly a <em>best</em> design, but instead the data architect is left to decide the <em>least bad</em> combination of trade-offs to suite the unique business objectives.</p><p>On the issue of modelling an analytics warehouse, the relevance of Kimball’s dimensional model has been<a href="https://youtu.be/3OcS2TMXELU"> called into question by members of the data community</a>. With the improvements in data compression techniques and the falling cost of storage, cloud data warehouses are very different compared to when Kimball wrote his book. As an alternative, the use of denormalized multipurpose big tables known as Wide Tables has been pushed because of its speed and ease of use.</p><p>In this article, we’ll look at both the Kimball dimensional model and Wide Table and assess the trade-offs involving both in modelling data for analytics.</p><h3><strong>Dimensional Modelling</strong></h3><p>Ralph Kimball’s dimensional modelling is a data modelling technique used to model data for analytics. It involves breaking up the data into facts and dimension tables to describe the entities of a business within a data warehouse. Fact tables consist of quantitative data usually pertaining to business operations and events like transactions, while dimension tables contain qualitative data to describe the fact tables.</p><p><strong>Dimensional schemas</strong></p><p>A database schema is comprised of all the tables in a database and the relationships that exist between them. The schema is a logical representation of how the data is stored within the database. With dimensional modelling there are 3 main schema design patterns: star schema, snowflake schema and galaxy schema.</p><p>The Star Schema has a fact table at its centre, with one or more dimension tables connected forming a star-like shape. All data ingested into the warehouse, will either be added to a current fact or dimension table or will lead to the creation of new ones.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*-vnOJCuLTUx1qyn7" /><figcaption>The star Schema</figcaption></figure><p>The Snowflake schema is like the star schema, but its dimensions are <em>normalized</em> into multiple related tables. This means that data in some dimension tables is further split into smaller units to reduce redundancy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*j3NfBC94f2NeI2an" /><figcaption>The snowflake schema</figcaption></figure><p>The galaxy schema is a collection of fact tables sharing some dimension tables. It can also be viewed as a collection of star schemas, hence its name. Like the snowflake schema, it is an extension of the star schema.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*VK__xfNqh0wXLQkY" /><figcaption>Galaxy Schema</figcaption></figure><p>There are 2 main reasons Kimball argues for dimensional modelling in the data warehouse:</p><p>· Simplicity: The dimensional model is much easier for business professionals to comprehend and therefore easier for them to query.</p><p>· Performance: Due to their simpler design, they require fewer joins than relational schemas to produce data for reporting.</p><p>While Online Transaction Processing (OLTP) systems aim to minimize redundancy and inconsistency in operational data, dimensional models place more emphasis on providing historical data for analytics and decision-making.</p><p><strong>Creating a Star Schema</strong></p><p>Seeing as the star schema is the foundational dimensional modelling schema, we will theoretically translate data from an OLTP system into a star schema. For this exercise, we’ll make use of the Microsoft Northwind Trader Database, available for download<a href="https://code.google.com/archive/p/northwindextended/"> here</a>. This database contains 13 tables; <em>region, territories, employeeterritories, employees, shippers, orders, customers, order details, products, customerdemographics, customercustomerdemo, suppliers </em>and<em> categories.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*q2ChlXQHVxg2Ohrd" /><figcaption>Microsoft Northwind Logical schema</figcaption></figure><p>To begin this process, we will take the following steps:</p><p><strong>Step 1: Select the business process</strong></p><p>A business process is a primary activity performed by the business like sales, orders, inventory etc. In this example, it’s the orders or in plainer terms, its <em>sales.</em></p><p><strong>Step 2: Declare the grain</strong></p><p>Declaring the grain means specifying what each row of a fact table represents. This step determines the level of detail associated with measurements from the fact table. In our case, its each individual sale made.</p><p><strong>Step 3: Identify the dimensions</strong></p><p>Dimensions are qualifiers for the facts, they describe the data resulting from the key business processes. Aside <em>orders</em> and <em>order details</em>, every other table is a dimension to describe each sale. We will combine data from various related tables in the original model to reduce the number of joins required during querying. Our dimensions are now <em>dim_shippers, dim_customers, dim_employees </em>and<em> dim_products.</em></p><p><strong>Step 4: Identify the Facts</strong></p><p>Facts are the measurable data that have been defined in step 1 and 2. Seeing as individual orders or sales are the declared grain, we join the <em>order details</em> and <em>orders</em> tables to form a single <em>fact_orders</em> table at the centre of the schema.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/0*YiKgGvplRII-Dtzd" /><figcaption>A star schema of the Northwind database</figcaption></figure><p>This transformation process results in a denormalized, subject-oriented schema optimized for data warehousing and analytical querying, offering improved performance and easier comprehension for business users. In this process, it is normal to drop columns that are not useful in report production (like employee photo or customer fax), but these decisions must be validated with the business users.</p><h3><strong>Wide Tables</strong></h3><p>In this design approach, all the data from the OLTP relational schema is joined into one wide denormalized table. As a result, this approach is commonly called the “One Big Table”. This design takes advantage of the benefits of columnar databases like Snowflake and Google Big Query and makes it easier to query since all tables have been pre-joined.</p><p>Creating a single wide table from the OLTP from our previous example would result in a single table like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/0*hGn1T_GlIQkVZnXA" /><figcaption>A Wide Table made from the Northwind database</figcaption></figure><p>This results in a single denormalized fact table with all the dimensions as columns.</p><p><strong>Considering The Trade-offs</strong></p><p>According to<a href="https://www.fivetran.com/blog/star-schema-vs-obt"> a study from Fivetran</a>, Wide Tables are 25–50% faster than Star Schema in Redshift, Bigquery and Snowflake. As a result, these tables make use of less compute resources, costing less to query.</p><p>Wide Tables are also more suitable for business users who may not necessarily understand joins. This is important because bad joins do not only affect the performance of the data warehouse but could also produce data that skews analysis.</p><p>Why is there a debate if the Wide Table beats the dimensional model for both performance and simplicity? Because those are not the only variables to consider when building an analytics warehouse.</p><p>Wide Tables are more inflexible to change and are harder to maintain than the star schema. If the number of data sources increases, the whole table must be rebuilt. It also doesn’t handle changes in dimensions well, unlike star schema that can capture both the latest values and values at any given point in time.</p><p>There is no universal best model, it mostly depends on the business needs, data and tools used. If the data architect is pressed for time and with relatively small data, a wide table is faster to build and will buy the engineers time to gradually migrate if the circumstances change. In some more complex situations, investing time in a dimensional model would be worth it. Some data teams make use of both dimensional models and Wide tables; using the dimensional model in a staging layer to build the Wide table that is then accessible to users in a presentation layer — this way, the wide table inherits the dimension changes from the dimensional model.</p><p>Warehouse modelling is a complex concept and there are no easy steps to getting the best results. These models are tools intended to achieve business objectives, and we should be willing to adapt them to meet those goals.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a46ae6f61807" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conceptual Data Modelling: How to Use Data to Drive Business Growth]]></title>
            <link>https://medium.com/@iyi_bobby/conceptual-data-modelling-how-to-use-data-to-drive-business-growth-9d245198bf9d?source=rss-b992c9d07a87------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d245198bf9d</guid>
            <category><![CDATA[data-architecture]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[data-modelling]]></category>
            <dc:creator><![CDATA[Iyi Obiechina]]></dc:creator>
            <pubDate>Sun, 14 Apr 2024 15:42:38 GMT</pubDate>
            <atom:updated>2024-04-14T15:42:38.693Z</atom:updated>
            <content:encoded><![CDATA[<p>It’s easy to be surprised by how well experienced data administrators understand the databases in their care, knowing the relationships between all the tables and their various constraints. For a lot of administrators, this is simply familiarity built by years of managing these databases. But how does a data engineer new to the business, adjust quickly enough to the databases?</p><p>Ideally the entire data infrastructure would be documented from ideation, to deployment and maintenance. The databases would all have been documented using data models that capture tables and their relationships. However, a lot of businesses do not have data models that could help new engineers, or even act as reliable reference material for current engineers. And with increasing data volumes and more complex queries, data models are becoming increasingly important to better manage storage and processing costs.</p><p><strong>What are Data Models</strong></p><p>I think it’s important we understand the primary function of models in general. Models are visual representations of complex systems used to simplify how they work. A city, for instance, consists of intricately linked systems including roads, sewage and electrical systems. Although these systems operate in the same physical territory, they require different models to simplify them. For example, a road map is a simplification of a geographical terrain that represents only transport links to make it easier for travelers to navigate the roads. The road map sacrifices geographical detail as it does not simplify navigation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aHm2lmQS-HqaskvrJ6Yzhw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qaMCgQoGZ6s_w0J3xLOQ0A.png" /><figcaption><em>Satellite image of the Niger Bridge area vs a simple road map of Niger Bridge area.</em></figcaption></figure><p>Similarly, a data model is a representation of an organizations data entities and the relationships between them. A good data model should closely resemble business operations. There are different types of data models; Conceptual, Logical and Physical data models, each more specific and detailed than the former. In this post, let’s explore the conceptual model and its importance in acquainting the engineer with the database landscape and the business model.</p><p><strong>The Conceptual Data Model</strong></p><p>Conceptual modelling is the process of identifying and visually mapping the entities of a business operation. Before defining data structures, we need to understand the business model that generates them. A conceptual model should be a good description of the organization’s operating model as it lays the foundations for the entire database landscape.</p><p>Usually, conceptual modelling is a collaborative process between the business and the data team, where the entities — objects, people or events relevant to the business for which the organisation wants to store information — are discussed and agreed upon before data about these entities can be collected and stored. The model is important to the data engineer because it provides information on the basic principles of the business model and the data it stores in the simplest terms. This phase lays the foundation and provides information for further stages of design and analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9cBBVxEGdUMLw2CAQZGGVA.jpeg" /><figcaption><em>Conceptual model for a library loan system.</em></figcaption></figure><p>This basic conceptual diagram describes a simple library database with three entities; their registered members, all the books that have been loaned and the people they’ve been loaned to, and all the books in the library. The diagram also shows the relationship between these entities.</p><p><strong>How to Model An Existing Database in Reverse</strong></p><p>Even though our use case is one where the database landscape already exists (and is possibly very complex), conceptual modelling can help simplify the data system just as it does when starting a new one.</p><p>For this exercise, we’ll make use of the Retailer database from <a href="http://www.mysqltutorial.org/">mysqltutorial.org</a>. This database contains 8 tables; <em>offices</em>, <em>employees</em>, <em>customers</em>, <em>products</em>, <em>productlines</em>, <em>orders</em>, <em>orderdetails</em> and <em>payments</em>.</p><p>The techniques we’ll be using are from the book The Data Warehouse Toolkit, which at this point has become the blueprint for database design. Kimball’s approach (named after one of the authors Ralph Kimball) , although widely recognized, is not the only methodology for creating data models.</p><p>According to the Kimball approach, the four key decisions made during the model design include:</p><ol><li>Select the business process</li><li>Declare the grain</li><li>Identify the dimensions</li><li>Identify the facts</li></ol><p>But since we’ll be modelling in reverse, our steps will be as follows:</p><ol><li>Identify the facts</li><li>Identify the dimensions</li><li>Establish the relationship</li><li>Validate the business processes</li></ol><p><strong>Identify the facts</strong></p><p>We start by classifying the existing tables into facts and dimensions. Fact tables record facts of the business process such as manufacturing, selling or buying, or support functions like registration and inventory. They store quantitative data. On inspection, the <em>orders</em>, <em>payments</em> and <em>orderdetails</em> tables satisfy these criteria.</p><p><strong>Identify the dimensions</strong></p><p>Dimension tables contain descriptive information but not quantitative measurements. <em>offices</em>, <em>employees</em>, c<em>ustomers</em>, <em>products</em> and <em>productlines</em> are all dimension tables.</p><p>Now that we’ve identified the facts and dimensions, the result looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vaxcWEqgwBbjAnl7nER85w.png" /><figcaption><em>Facts and dimensions identified from the physical schema.</em></figcaption></figure><p><strong>Establish the relationships</strong></p><p>This step could be easy depending on how well best practices were observed in designing the physical schema. For example, if primary and foreign keys have been declared, then they would easily be accessible from the information schema or by reading the table declarations. Using the following query, we can view the constraints on the customer table:</p><pre>SHOW CREATE TABLE customers;</pre><p>Where constraints are not clearly defined, we may need to rely on column naming to guess relationships. Using the employee table, we can assume the “employeeNumber” column is the primary key. We can test this assertion using the following query</p><pre>SELECT employeeNumber, COUNT(*)<br>FROM employees <br>GROUP BY employeeNumber <br>HAVING COUNT(*) &gt; 1;</pre><p>The query should return no result if the column is a primary key. Nevertheless, these are only assumptions and only the business users can conclusively confirm if they are true. Once primary key candidates have been assumed, we have to look for instances of the primary key columns in other tables. Columns with the same structure and meaning across multiple tables are known as conformed dimensions. For example, the ”employeeNumber” column in the employees table is a conformed dimension of “salesRepEmployeeNumber” in “customers” if both columns share the same data type and values.</p><p>Once the relationships have been identified, we attempt to establish their cardinality and optionality. Cardinality defines how many instances of an entity are related to instances of another entity, while optionality describes whether one entity must be joined to another. Although the data can be an indicator, and the table constraints give us clues about the nature of the relationship, only the business team can confirm the reality.</p><p>Now that we have established the relationships, the result looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*unI9LVwIQu6leUk7SsJB1g.jpeg" /><figcaption><em>A conceptual model of the physical schema</em></figcaption></figure><p>Having come up with our conceptual model, we can now begin dialogue with the various business stakeholders responsible for these business processes to validate our model.</p><p><strong>Validate the business processes</strong></p><p>The data model we have designed carries with it a lot of assumptions about the business operations and they must now be validated with the various business teams. Based on the input of the business teams, the conceptual model can then be adjusted to reflect the reality of the business operations. The review of this conceptual model could even result in changes to the physical model if the business owners or experts feel it has deviated with time.At the end of the review, we now have a clear and accurate conceptual data model that fully captures the business it is documenting, laying the foundation for accurate logical and physical models.</p><p>Every organisation needs a good conceptual model. Besides providing a better understanding of the current data system, a good conceptual model will act as a layout for the evolution of the business in the long term. As the data grows in size and complexity, the model saves engineers from dealing with a complicated failure-prone database landscape, and management from paying heavily for cloud computing. Conceptual modelling is the data team’s most important step to optimising cost for value.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d245198bf9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[World Cup 2018: A Bird’s eye view]]></title>
            <link>https://medium.com/@iyi_bobby/world-cup-2018-a-birds-eye-view-a0aa383249f1?source=rss-b992c9d07a87------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0aa383249f1</guid>
            <dc:creator><![CDATA[Iyi Obiechina]]></dc:creator>
            <pubDate>Mon, 16 Mar 2020 23:00:41 GMT</pubDate>
            <atom:updated>2020-03-16T23:00:41.622Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WleJt71J0zrJNbmJGrSxZA.jpeg" /></figure><p>In 2018, Russia played host to the biggest footballing event on the planet; the FIFA World cup, and football fans across the globe joined in the despair and jubilations as their favorite footballers and national teams took to the field to grace the ultimate stage. While the players and their management teams engaged in physical and tactical duels on the pitch, viewers expressed their thoughts on the beautiful game on Twitter.</p><p>The opinions expressed via tweets usually have sentiments attached to them i.e. positive, negative or neutral. Analysis of these sentiments may reveal useful insight on the topic in question. So in order to get understand the 2018 World Cup better, I decided to perform sentiment analysis on twitter data to get a rough idea of how the English ‘twittosphere’ viewed the world cup. The data contains a random collection of 530k tweets containing any references to FIFA or the World Cup, starting from the round of 16 till the final on the 15 July 2018.</p><p><strong>Performing Sentiment Analysis</strong></p><p>Sentiment analysis or opinion mining, is the process of determining the emotional tone behind a series of words in order to gain understanding of attitudes towards a certain topic. The applications of sentiment analysis are numerous and powerful. Social media has proven to be a treasure trove for organizations looking to gain insight into social attitudes towards their brand or products. To successfully perform sentiment analysis on the tweets we need to follow a few steps:</p><p>1. Get the data</p><p>2. Generate Tokens</p><p>3. Build Model</p><p>4. Train and test model</p><p>5. Run the model</p><p><strong>Get the data</strong></p><p>In order to perform sentiment analysis on the tweets using machine learning, you need to find the right data with which to train your model. That is, you need to find data containing already classified sentences or groups of words. For this model, I made use of the Stanford sentiment treebank data. The data is a large corpus of movie reviews with sentiment scores between 0 (very negative) and 1 (very positive), but for the purpose of our model all values less than 0.5 will be considered negative while those greater than or equal to 0.5 will be regarded as positive. For example,</p><blockquote>“This movie sucks!” — Negative</blockquote><blockquote>“The acting was excellent, the script even better” — Positive</blockquote><p>Afterwards, the model is trained using this data.</p><p><strong>Generate Tokens</strong></p><p>After cleaning and preprocessing the data, the next step is to generate sequence of tokens for the text in the data. Generating tokens or tokenization is simply the extraction of numerical representations for words so the model can learn. In order to account for the variable length of token sequences, shorter sequences are filled with tokens (usually 0) to fit them to a select length (usually the length of the longest sequence) so as to create a matrix for efficient learning.</p><pre>def get_tokens(text, max_words):<br>    tokenizer = Tokenizer(num_words=num_words, lower=False)<br>    tokenizer.fit_on_texts(text)<br>    X = tokenizer.texts_to_sequences(text)<br>    X = pad_sequences(X, maxlen=max_words)<br>    <br>    return X</pre><pre>X = get_tokens(text, max_words)</pre><p><strong>Build the model</strong></p><p>In order to tackle this classification problem, I’ll be making use of a type of Recurrent Neural Network known as LSTM (Long Short Term Memory). You can read more about RNNs and LSTMs <a href="https://en.wikipedia.org/wiki/Long_short-term_memory">here</a>. The main advantage of LSTMs is that unlike the normal RNN were the memory of the first input gradually fades, the LSTM contains an additional state that enables it ‘remember’ or learn what to store in the long term, what to discard and what to read. So for instance you could have a movie review that begins with “This movie was excellent,” but the rest of the review lists the negatives of the movie. The normal RNN could easily forget the first part and consequently misinterpret the review while the LSTM is less likely to do so because of its long term memory. The layers of the model include:</p><p>1. Input Layer: An embedding layer of a vector size of 5000, taking the sequence of words as input</p><p>2. Dropout layer: A regularization layer to help prevent overfitting</p><p>3. Bidirectional LSTM layer: Computes the inputs using LSTM units. Bidirectional LSTMs train two LSTMs on the input sequence. The first on the input sequence as it is, while the second on a reversed copy of the input sequence.</p><p>4. Dropout layer: A regularization layer to help prevent overfitting</p><p>5. Output layer: Computes the probability of the class of the sequence, whether negative or positive.</p><pre>def create_model(num_words, max_words):<br>    model=Sequential()<br>    <br>    #Add Input Embedding Layer<br>    model.add(Embedding(num_words, 128, input_length=max_words))<br>    <br>    #Add Hidden layers <br>    model.add(Dropout(0.5))<br>    model.add(Bidirectional(LSTM(100, dropout=0.5, recurrent_dropout=0.5)))<br>    model.add(Dropout(0.5))<br>    <br>    #Add Output Layer<br>    model.add(Dense(2, activation=&#39;sigmoid&#39;))<br>    model.compile(loss=&#39;binary_crossentropy&#39;, optimizer=&#39;adam&#39;, metrics=[&#39;accuracy&#39;])<br>    print(model.summary())<br>    <br>    return model</pre><p><strong>Train and test the model</strong></p><p>The model is trained on 60% percent of the data while the remaining is divided equally for validation and testing. The model on the test set of 2 class sentiment classification provides a result of 79.87%.</p><pre>model.fit(X_train, y_train, validation_data=(X_val, y_val), batch_size=64, epochs=20)</pre><pre>model.evaluate(X_test, y_test, verbose=2, batch_size=32)</pre><p><strong>Run the model</strong></p><p>Now that the model has been trained, the next step is to use the trained model on the world cup data. In order to do this you will need to tokenize the input data like we did the training data. Afterwards, we feed the model the input data and have it predict their classes.</p><pre>predictor = get_tokens(tweets, max_words)</pre><pre>sentiment = model.predict_classes(predictor)</pre><p><strong>Visualization of results</strong></p><p>The visualization of the results should help drive insights into fan opinions about the World Cup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ocq64WM9VcvfttGEaJlWdg.png" /></figure><p>The chart shows the number of tweets recorded on different dates, while the bars are split by sentiment, were the percentages indicate how much of the day’s tweets were negative or positive. July 15, which was the date of the finals, saw the highest amount of tweets and a more even split between positive and negative tweets, compared to the other dates which were skewed more towards positive tweets. Perhaps it’s safe to say the events of the final split opinions more than usual. There were no games on the June 29, July 2 and July 4, so the low tweet count is understandable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*qPZPk1S1wBaEa4SCwbspVg.png" /></figure><p>The plots above consider tweets mentioning France and Croatia. I also took into consideration some possible variants of these names like “FRAAAAAANCEEEEEE”, “CROCROCROATIA” or “FrancevsCroatia”. From the image, it’s clear that there are far less English tweets mentioning Croatia than there are mentioning France. Meanwhile, the split in opinions for both category of tweets shows the same trend, opinions are generally positive up until the final where the number of tweets expressing negative opinions slightly outweigh those with positive opinions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6ERkTSB6frAkmcNkoSgEVA.png" /></figure><p>Here are the words most frequently tweeted. This can also be used to see what is driving a lot of the negative or positive opinions in the data or the most discussed topics.</p><p>(Complete code and data are available <a href="https://github.com/obie-china/FIFA-Sentiment-Analysis">here</a>)</p><p>(All visualiZations were done on Tableau)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0aa383249f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generating YouTube Titles using LSTMs]]></title>
            <link>https://levelup.gitconnected.com/generating-youtube-titles-using-lstms-19baa1948088?source=rss-b992c9d07a87------2</link>
            <guid isPermaLink="false">https://medium.com/p/19baa1948088</guid>
            <dc:creator><![CDATA[Iyi Obiechina]]></dc:creator>
            <pubDate>Sun, 16 Feb 2020 23:01:37 GMT</pubDate>
            <atom:updated>2020-02-28T14:36:13.793Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Generating YouTube Video Titles using LSTMs</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6DwzipLk8ygjP4zzhrgzuA.jpeg" /></figure><p>Text generation is a type of language modeling problem and is a core problem for a number of natural language processing tasks including text summarization, speech to text, and conversational systems. A language model can learn the likelihood of a word occurring, using previously occurring words in the sequence as context. In this article, I will use the YouTube trending videos data set to train a text generation language model using a Recurrent Neural Network, which will be used to generate YouTube video titles.</p><h4><strong>Generating Sequence of N-gram Tokens</strong></h4><p>Language modeling requires input data as a sequence of tokens. The first step after data cleaning and transformation is generating a sequence of n-gram tokens. An n-gram is an adjacent sequence of n items from a given sample of text or speech corpus. The items can be words, syllables, phonemes, letters or base pairs. In this case, the n-grams are a sequence of words from a corpus of YouTube titles. Tokenisation is the process of extracting tokens from the corpus.</p><pre>tokenizer = Tokenizer()</pre><pre>def get_sequence_of_tokens(corpus):<br>  #get tokens<br>  tokenizer.fit_on_texts(corpus)<br>  total_words = len(tokenizer.word_index) + 1<br> <br>  #convert to sequence of tokens<br>  input_sequences = []<br>  for line in corpus:<br>  token_list = tokenizer.texts_to_sequences([line])[0]<br>  for i in range(1, len(token_list)):<br>  n_gram_sequence = token_list[:i+1]<br>  input_sequences.append(n_gram_sequence)<br> <br>  return input_sequences, total_words</pre><pre>inp_sequences, total_words = get_sequence_of_tokens(corpus)</pre><p>From the output, the tokens [1, 88], [1, 88, 4064], [1, 88, 4064, 70] and so on, represent the n-gram phrases generated from the input data. Each integer in the output corresponds to a particular word in the vocabulary of words in the text. For instance</p><blockquote>Title: we want to talk about marriage</blockquote><blockquote>(N-grams : tokens)</blockquote><blockquote>we want : [1, 88]</blockquote><blockquote>we want to: [1, 88, 4064]</blockquote><blockquote>we want to talk: [1, 88, 4064, 70]</blockquote><blockquote>we want to talk about: [1, 88, 4064, 70, 368]</blockquote><blockquote>we want to talk about marriage: [1, 88, 4064, 70, 368, 1313]</blockquote><h4><strong>Padding the sequences and obtaining the predictors and targets</strong></h4><p>Since the sequences can be of variable length, it is important that the sequence lengths are made equal. When using neural networks, we usually feed an input into the network expecting an output. In practice, it is more efficient to process data in batches and not one by one. This is done by using matrices [batch size x sequence length], where the sequence length corresponds to the longest sequence. In this case, we fill sequences with a token (usually 0) to fit the matrix size. This process of filling sequences with tokens is called padding. To input the data into a learning model, I need to create predictors and labels. I will create n-gram sequences as predictors and the next word of the n-gram as a label. For instance</p><blockquote>Title: Fried chicken recipe for everybody</blockquote><blockquote>(predictor: label)</blockquote><blockquote>fried: chicken</blockquote><blockquote>fried chicken: recipe</blockquote><blockquote>fried chicken recipe: for</blockquote><blockquote>fried chicken recipe for: everybody</blockquote><pre>def generate_padded_sequences(input_sequences):<br>  max_sequence_len = max([len(x) for x in input_sequences])<br>  input_sequences = np.array(pad_sequences(input_sequences,  maxlen=max_sequence_len, padding=’pre’))<br>  predictors, label = input_sequences[:,:-1], input_sequences[:, -1]<br>  label = ku.to_categorical(label, num_classes = total_words)<br>  return predictors, label, max_sequence_len</pre><pre>predictors, label, max_sequence_len = generate_padded_sequences(inp_sequences)</pre><h4><strong>Long short term memory (LSTM)</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-_gfwZVFm7uLNZyXqvAxA.png" /><figcaption>LSTM</figcaption></figure><p>In Recurrent Neural networks, activation outputs are propagated in both directions, that is, from input to output and from outputs to inputs, unlike feed-forward neural networks where activation outputs are only propagated in one direction. This creates loops in the neural network architecture which acts as a ‘memory state’ of the neurons. As a result, the RNN preserves some state across time steps or ‘remembers’ what has been learned over time. The memory state comes with its advantages but it has disadvantages also. Vanishing gradient is one of them. In this problem, while learning with a large number of layers, it becomes really hard for the network to learn and tune the parameters of the earlier layers. To address this problem, a new type of RNN was developed; LSTM (Long Short Term Memory).</p><p>The LSTM contains an additional state (the cell state) which essentially enables the network learn what to store in the long term state, what to discard and what to read from it. The LSTM in this model contains three layers</p><p>1. Input layer: takes the sequence of words as input</p><p>2. LSTM layer: computes the output using lstm units.</p><p>3. Dropout layer: a regularization layer to help prevent overfitting</p><p>4. Output layer: computes the probability of the possible next word as output</p><pre>def create_model(max_sequence_len, total_words):<br>  input_len = max_sequence_len — 1<br>  model = Sequential()<br> <br>  # Add Input Embedding Layer<br>  model.add(Embedding(total_words, 10, input_length=input_len))<br> <br>  # Add Hidden Layer 1 — LSTM Layer<br>  model.add(LSTM(100))<br>  model.add(Dropout(0.1))<br> <br>  # Add Output Layer<br>  model.add(Dense(total_words, activation=’softmax’))</pre><pre>  model.compile(loss=’categorical_crossentropy’, optimizer=’adam’)<br> <br>  return model</pre><pre>model = create_model(max_sequence_len, total_words)</pre><pre>model.fit(predictors, label, epochs=20, verbose=5)</pre><p><strong>Generating the text</strong></p><p>Now that the model architecture is ready and its been trained using the data, its time to predict a YouTube title based on the input word. The input word is first tokenized, the sequence is then padded before being passed into the trained model to return the predicted sequence.</p><pre>def generate_text(seed_text, next_words, model, max_sequence_len):<br>  for _ in range(next_words):<br>  token_list = tokenizer.texts_to_sequences([seed_text])[0]<br>  token_list = pad_sequences([token_list], maxlen=max_sequence_len-1,  padding=’pre’)<br>  predicted = model.predict_classes(token_list, verbose=0)<br> <br>  output_word = “”<br>  for word,index in tokenizer.word_index.items():<br>  if index == predicted:<br>  output_word = word<br>  break<br>  seed_text += “ “+output_word</pre><pre>  return seed_text.title()</pre><p><strong>Results</strong></p><p>Time to view some of the results. Here’s the input:</p><pre>print(generate_text(“spiderman”, 5, model, max_sequence_len))</pre><pre>print(generate_text(“lose”, 5, model, max_sequence_len))</pre><pre>print(generate_text(“Dave”, 3, model, max_sequence_len))</pre><pre>print(generate_text(“episode”, 4, model, max_sequence_len))</pre><pre>print(generate_text(“fast”, 6, model, max_sequence_len))</pre><p>Where the integer indicated the desired length of the title besides the input word.</p><p>And here are the generated titles:</p><pre>Spiderman The Voice 2018 Blind Audition</pre><pre>Lose The Item Behind The Wall</pre><pre>Dave Chappelle Equanimity Clip</pre><pre>Episode 11 Albeet Alkebeer Woods</pre><pre>Fast Food Restaurants To Get A Snowman</pre><p>I’d say the model did a fair job.</p><p>(<em>Complete code and data available </em><a href="https://github.com/obie-china/Generating-Youtube-Titles-with-LSTM"><em>here</em></a>)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19baa1948088" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/generating-youtube-titles-using-lstms-19baa1948088">Generating YouTube Titles using LSTMs</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Corona virus: The Story So Far]]></title>
            <link>https://medium.com/@iyi_bobby/corona-virus-the-story-so-far-ba8ff6fe5af7?source=rss-b992c9d07a87------2</link>
            <guid isPermaLink="false">https://medium.com/p/ba8ff6fe5af7</guid>
            <dc:creator><![CDATA[Iyi Obiechina]]></dc:creator>
            <pubDate>Sat, 08 Feb 2020 00:33:25 GMT</pubDate>
            <atom:updated>2020-02-08T00:33:25.757Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Corona virus: The Data So Far</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/440/1*aX8tOvUp5PluZjqChQmVWQ.jpeg" /></figure><p>The new decade was ushered in with fears of human extinction, either by way of global warfare or epidemic. While tensions between the United States and Iran may have simmered down to allay some of those fears, the spread of Coronavirus doesn’t seem to be letting up.</p><p>The Wuhan Coronavirus outbreak was identified in Wuhan, the capital of Hubei province in China in early December 2019, after 41 people developed pneumonia without any known cause. Since then, the virus has gone on to infect thousands of people within China and across the globe. As of February 2020, there are no known vaccines yet, but antivirals are still being investigated. In this article, I’ll be exploring data made available by the World Health Organization, to give insight on the spread of the virus so far. The data contains daily level information on the number of confirmed Coronavirus cases, deaths and recoveries, from the 22nd of January 2020 to the 4th of February 2020.</p><p><strong>The Epidemic</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qhJ1y-j5ZwluB1QYcQeqSA.png" /><figcaption>Map showing the spread of the Coronavirus by country and density</figcaption></figure><p>The Wuhan Coronavirus has spread far beyond its titular city, to several locations across the globe, including North America, Europe, other parts of Asia and Australia. As expected countries surrounding China, mostly those off China’s coasts are considerably affected. With 176 cases, Thailand has the most confirmed cases outside of China. Japan, Hong Kong and Singapore all have over a 100 confirmed cases (143, 130 and 137 respectively). Countries outside Asia (excluding Australia) who have been more recently hit, have far less confirmed cases of people infected by the virus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7ihqtzkro_Vuje-heSmXMA.png" /><figcaption>Map showing China’s provinces and the density of confirmed cases</figcaption></figure><p>Looking more closely at China, Hubei province where the virus was discovered, has the most number of confirmed cases not just in the country but also in the world with 78,176 confirmed cases. Guangdong, which is off the south coast, has the second most with 4,841 cases.</p><p><strong>Effects</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/908/1*4nZUg94_t6pLakApU3Suzw.png" /><figcaption>The rising death toll as a result</figcaption></figure><p>The number of deaths by the virus has risen steadily since the collection of the data began. While the total death toll numbers in the thousands, only 5 of those have occurred outside of China (4 in the Philippines and 1 in Hong Kong). The death toll in Hubei alone accounts for 96% of the total deaths across the globe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KaGAyFNlasX1ol_DDkf3ZA.png" /></figure><p>The percentage increase in deaths between the various days has also dropped steadily, which may present some hope. There was a 44.4% increase in deaths between the 23rd and 24th of January, which steadily dropped to 15.4% between the 3rd and 4th of February.</p><p>The total number of recovered cases equally continues to rise, indicating that there may be some progress in the form of treatment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/917/1*rjORXJAr43x8syWzDz-tjA.png" /></figure><p><strong>Conclusion</strong></p><p>Even though the Wuhan Coronavirus continues to spread, data seems to indicate that there may be hope because of the successes recorded in the continued increase in recovered cases and the daily percentage reduction in deaths. Light at the end of the tunnel perhaps.</p><p>(All visualizations were done on Tableau)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ba8ff6fe5af7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Check The Rhyme: Quantifying Assonance in Rap Lyrics]]></title>
            <link>https://medium.com/@iyi_bobby/check-the-rhyme-quantifying-assonance-in-rap-lyrics-7feaa4d9d7e8?source=rss-b992c9d07a87------2</link>
            <guid isPermaLink="false">https://medium.com/p/7feaa4d9d7e8</guid>
            <dc:creator><![CDATA[Iyi Obiechina]]></dc:creator>
            <pubDate>Mon, 27 Jan 2020 17:45:53 GMT</pubDate>
            <atom:updated>2020-01-28T16:57:01.946Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*eCdEAaEl7J3_DRUkgFLybA.jpeg" /></figure><p>A lot of the statistical analysis done on rap lyrics usually deals with words. Although the content and vocabulary of lyrics are interesting features, they are more literal than they are musical. An important musical feature in rap music is rhyme. Alongside rhythm, it is one of the two things that make the often spoken word in rap a musical experience. Rappers often use rhymes to create recognizable patterns and emphasize the rhythm of their lyrics. There are several types of rhymes but this model is focused on just assonance; rhymes involving vowel sounds between words.</p><p>When rappers create patterns or rhyme schemes they do so in one or both of two ways; by rhyming words within the bar (internal rhymes) or by rhyming words between the bars (link rhymes). For those of us that aren’t familiar with the term, a bar is a measure used in writing music. Each bar contains the same amount of beats (which for a lot of rap music is four). For the demonstrations in this article, each line of lyrics will represent a bar of the music.</p><p><strong>Link Rhymes</strong></p><p>Link rhymes in rap music range from the simple to incredibly complex. Take for instance these 2 lines from “That’s the joint” by The Funky Four plus One More:</p><blockquote><em>Jeff is the rhythm and Kay is the </em><strong><em>bass</em></strong></blockquote><blockquote><em>Sha-Rock shocking the whole darn </em><strong><em>place</em></strong></blockquote><p>(Rhyming syllables are displayed using the same font style)</p><p>This is a simple case where the two lines are linked by a single rhyming syllable at the end of the bar. Now consider this from, MF DOOM on “One beer”:</p><blockquote><strong><em>Tempt me</em></strong><em>, do a number on the</em> label</blockquote><blockquote><em>Eat up all they </em><strong><em>emcees</em></strong><em> and drink ’em under the </em>table</blockquote><p>Here the artiste creates a more complex pattern by rhyming more syllables between the two bars, with 4 syllables (‘tempt’, ‘me’, ‘la-’ and ‘-bel’)on the first line rhyming with another 4 (‘em-’, ‘-cees’, ‘ta-’, ‘-ble’)on the second line. But it can get even more complex, like Jean Grae on “Imagine”:</p><blockquote><em>I define my </em>place<em> as </em><strong><em>homeost</em>a<em>sis</em></strong></blockquote><blockquote><em>With</em><strong><em> chromeo</em> bass<em> riffs</em></strong><em> and </em><strong><em>homey don’t </em>play<em> this</em></strong></blockquote><p>Here Jean Grae rhymes an incredible 17 syllables, with each rhyming syllable in the first line being linked with at least 2 others in the next line (‘-sis’ is linked with three).</p><p><strong>Internal Rhymes</strong></p><p>Internal rhymes are used to create patterns within the bar. Here’s a simple example from Nas on “One love”:</p><blockquote><em>Dear </em><strong><em>Born</em></strong><em>, you’ll be out soon, stay</em><strong><em> strong</em></strong></blockquote><p>On this line there is exactly one rhyme ‘Born’ and ‘strong’. Internal rhymes just like link rhymes can be more complex. Here’s a line from Mos Def from “Astronomy(8th light)”:</p><blockquote><em>Blacker than the </em><strong><em>night time sky</em></strong><em> of Bed-</em><strong><em>Stuy</em></strong><em> in </em><strong><em>July</em></strong></blockquote><p>The line contains the ‘AY’ sound repeatedly rhymed through the line more than once. In other cases the rapper rhymes different syllables with different sounds on the line. Here’s a line by Black Thought from “Clock with no hands”:</p><blockquote><em>The </em>skies<em> was</em><strong><em> overcast</em></strong><em>, when</em> I <em>was </em><strong><em>sober last</em></strong></blockquote><p>Here there are four distinct syllables each rhymed once across the line.</p><p><strong>The Model</strong></p><p>The model used here in rhyme detection is inspired by the one used in <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwian8i6nKTnAhV-DGMBHeNEASEQFjAAegQIAxAB&amp;url=https%3A%2F%2Fwww.researchgate.net%2Fpublication%2F267257092_Using_Automated_Rhyme_Detection_to_Characterize_Rhyming_Style_in_Rap_Music&amp;usg=AOvVaw3S57TX1ujNJ_4z7FB-Y0Le">this paper</a>, which is itself inspired by a technique in bioinformatics used in protein homology detection. A pair of proteins is modeled as sequences of amino acid symbols that are either generated randomly or based on shared ancestry. Using the BLOSUM (BLOcks of amino acid SUbstitution Matrix) local alignment scoring scheme (Henikoff &amp; Henikoff, 1992), the likelihood of a pair of amino acids being matched is assigned log-odd scores. A positive score indicating the pair is likely to co-occur, while a negative score indicates otherwise. In a BLOSUM matrix M, the score for any two amino acid pairs, i and j is calculated as</p><blockquote>M[i, j] = In ( Pr[i, j | H] / Pr[i, j | R] )</blockquote><p>Where</p><p>Pr[i, j | H] is the likelihood of i being matched to j in an alignment of two homologous proteins and,</p><p>Pr[i, j | R] is the likelihood of i and j being matched by chance.</p><p>Likewise, in a log odds scoring matrix for rhyming syllables M, the score for any two syllable pairs, i and j is calculated as</p><blockquote>M[i, j] = In ( Pr[i, j | Rhyme] / Pr[i, j | Random] )</blockquote><p>Where the probability of i matching j in the random model is calculated as the product of the frequencies of i and j</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*2G4vHShLSFeWwqNKk_JW9w.png" /></figure><p>Where Fi is the total number of times the sound i appears in the lyrics. While for the rhyming model, the likelihood of i and j being matched as rhymes is calculated as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*r9bzkblA2c0c0jzPchJI7w.png" /></figure><p>The table below shows the resulting pairwise scoring matrix for vowel sounds. Each value represents the logarithm of the ratio of the probability of the pair matching in a rhyme versus the pair matching by chance</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*3DBFFTIdVnaYHYNx7B5xBA.png" /></figure><p><strong>Quantifying Rhymes</strong></p><p>In order to capture link rhymes in verses, the algorithm collects every possible syllable pair between both lines and counts only those positively matched by the scoring matrix. Taking one of the former examples,</p><blockquote><em>Tempt me, do a number on the label</em></blockquote><blockquote><em>Eat up all they emcees and drink ’em under the table</em></blockquote><p>the ‘EH’ sound in ‘tempt’ will be matched with the first syllable of ‘emcees’ because ‘EH’ according to table gives a positive match of 1.9 when paired with itself, while the ‘IY’ in ‘me’ will be matched positively with both ‘eat’ and the second syllables of ‘emcees’ because the ‘IY’ sound yields a positive score of 2.4 when paired with itself.</p><p>In capturing link rhymes, the algorithm collects every possible syllable pair between the line compared against itself, then subtracts the length of the line (number of syllables) from the result before being divided by 2. The internal rhyme I is calculated as</p><blockquote>I = (Nm — Ns)/2</blockquote><p>Where Nm is the number of positively matched syllables and Ns is the length of the line or number of syllables on the line. The number of matches are subtracted by the length of the line in order to remove non unique matches i.e. matches that come as a result of the two subjects of comparison being exactly the same.</p><p><strong>Data and Analysis</strong></p><p>I collected 40 rap verses from 40 different rappers each in order to model and test the results. The verses come from albums released between the years 1996 till now. In order to capture the rhymes within those verses, I had to clean them up by hand to deal with inconsistencies such as stylized names (e.g. Da$h) and incorrect spelling. The verses were then transcribed using a combination of the Carnegie Mellon University pronunciation dictionary corpus and an English grapheme to phenome translator, after which they were stripped of all consonant sounds. The results were then processed to extract the following features:</p><p>· Link rhymes per syllable</p><p>· Internal rhymes per syllable</p><p>· Link rhymes per line</p><p>· Internal rhymes per line</p><p>· Link rhymes per word</p><p>· Internal rhymes per word</p><p>· Link rhymes per unique word</p><p>· Internal rhymes per unique word</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*8wbc9ONr3pkSCOlM2ybLaA.png" /><figcaption>Comparison of a median internal and link rhyme per syllable values for a sample of rappers</figcaption></figure><p>I hypothesized that the features would show notable differences amongst rappers in terms of both their link and internal rhyming. Having a higher median internal rhyme per syllable would potentially indicate that the rapper typically rhymes more syllables within lines than others, while a higher median link rhyme per syllable would indicate more rhymed syllables between lines. According to the data, Rick Ross and J. Cole rhyme syllables within lines at approximately the same rate (0.75), while the latter typically rhymes more syllables between lines than the former (1.57 to Rick Ross’ 1.48). The values may point to stylistic differences in rappers writing.</p><p>A potential problem with the model was the possibility of repeated words increasing the likelihood of matches. To work around that I used both link and internal rhyme per unique word to find out, with link and internal rhyme per word giving it proper context.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*npTkIisnyFfczCB-75mXzA.png" /><figcaption>Using rhyme per word and rhyme per unique word to detect word repetition in matches</figcaption></figure><p>In the first panel of the above figure, Big K.R.I.T in comparison to Rick Ross is shown to execute more internal rhymes per word, but the second panel reveals that Rick Ross rhymes more unique words than Big K.R.I.T does, or matching the same set of words inflates the latter’s rhyme per words in comparison to the former.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*0tUqxjgWPLboFDmqEPLflg.png" /><figcaption>Every point or circle represents a rapper, Earl Sweatshirt is singled out in read</figcaption></figure><p>According to the data extracted from the model, Earl Sweatshirt has the highest median value on all features amongst the 40 rappers sampled, this would indicate he typically rhymes the most syllables between and within lines amongst those in the sample.</p><p><strong>Limitations of The Model</strong></p><p>Since the model is only capable of comparing consecutive line pairs, it fails to capture larger rhyme motifs i.e. rhymes between non-consecutive lines.</p><p><em>(Code and data are available</em><a href="https://github.com/obie-china/Check-The-Rhyme/blob/master/README.md"><em> here</em></a><em>, all visualizations were made on Tableau)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7feaa4d9d7e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>