Trying to share some code ideas

logo

Category: code Page 2 of 5

Lyrical Success – Getting the Data

To obtain the data I am going to use Beautiful Soup and a few other packages to scrap the content from the websites.

Part 2 of 4

Steps for Getting the Data

  1. Get the Songs Made by the Artists
  2. Extract the List of Songs by the Artist
  3. Scrap the Lyrics for Each Song by the Artist
  4. Extract the Lyrics from Each File
  5. Scrap Rankings by Artists
  6. Parse the Song Rankings Files

The first step is getting the list of the songs by the artist. I am using the website http://www.azlyrics.com to obtain the list of songs and the lyrics for the songs.

Lyrical Success – Preparing the Data

The data created in the previous step needs a little bit of cleaning up before we can get into the model building. It is a common step that needs to be undertaken to ensure that the data can be loaded into models without any issues.

Part 3 of 4

Steps for Preparing the Data

  1. Clean the Rankings
  2. Match the Song Ranks

Lyrical Success – Model Prediction

In this step, I will look at the data to see if we can do any feature engineering. And then I will edit the data for the model, train multiple models, evaluate the best model and then test the model. Let’s get started.

Part 4 of 4

Steps for Creating the Model

  1. Song Summary
  2. Visualizations
  3. Prepare the Lyrics for Analysis
  4. Model Building

Computing the Minimum Number of Flight Segments

Computing the Minimum Number of Flight Segments

If we want to compute the minimum number of flight segments between a starting city and target city, we can construct an undirected graph.  In the graph the nodes represent cities and the edges represent the flight segments.  We can count the number of segments to determine the shortest distance.

The following can be applied to any situation in finding the shortest path.  It is an implementation of the breadth first search algorithm.

See code below.

Modeling and Prediction for Movie Audience Ratings

Modeling and Prediction for Movie Audience Ratings

Synopsis

One of the key issues facing film production companies is, will the production company make a profit from a movie. It is assumed that favorable audience reviews will in-turn lead to higher ticket sales or DVD sales, both items directly affect a movie’s profitability.

The analysis will look at what attributes lead to a higher average audience review score on the public website, Rotten Tomatoes

Spoiler Alert The analysis creates a model that is close, but isn’t 100% confident.

Oracle PL/SQL More Aggregation – Rank

Oracle PL/SQL Aggregation  – Rank

One of the more interesting aggregation functions is RANK.  After doing a standard SELECT and GROUP BY; you can then have SQL rank the results using an aggregated value from another column.

Let’s dive in and look at how RANK works and what can it do for us.

Oracle 12c Limit Rows Returned

Limit Rows Returned

Previous to Oracle 12c limit the number of rows returned usually meant encapsulating the query as a subquery.  It wasn’t particularly nice looking and was out of alignment with other relational database query languages.

MySQL uses the LIMIT operator and Microsoft T-SQL uses the TOP operator. In Oracle 12c, Oracle introduced the FETCH FIRST operator.  Let’s see how it works.

Oracle PL/SQL Subtotal Operators

Oracle PL/SQL Subtotal Operators

There are times when we need not just the total value for the column, but subtotal values depending on different column values.  Oracle supports subtotal operators through the three key operators they are CUBE, ROLLUP, and GROUPING SETS. Below are examples of each one and how best to use them.

Aggregation in Oracle PL/SQL

Aggregation in Oracle PL/SQL

Oracle 12 uses normal SQL statements when doing aggregation.  The standard rules for aggregating in SQL apply.  You need to group by all non aggregated columns and having clause will be evaluated after the group by operator.

Some examples of aggregation in Oracle PL/SQL are below.

Dropping Tables in Oracle PL/SQL

Dropping Tables

Below are some examples of how to create tables in Oracle 12. PL/SQL, for the most part PL/SQL follows standard SQL conventions.

Page 2 of 5

Powered by WordPress & Theme by Anders Norén