Exercise 1: Solution
The course is part of this learning path
Learn the ways in which data comes in many forms and formats with the second course in the Data and Machine Learning series.
Traditionally, machine learning has worked really well with structured data but is not as efficient in solving problems with unstructured data. Deep learning works very well with both structured and unstructured data, and it has had successes in fields like translation, and image classification, and many others. Learn and study how to explain the reasons deep learning is so popular. With many different data types, learn about its different formats, and we'll analyze the vital libraries that allow us to explore and organize data.
This course is made up of 8 lectures, accompanied by 5 engaging exercises along with their solutions. This course is part of the Data and Machine Learning learning paths from Cloud Academy.
- Learn and understand the functions of machine learning when confronted with structured and unstructured data
- Be able to explain the importance of deep learning
- It would be recommended to complete the Introduction to Data and Machine Learning course, before starting.
Hey guys, welcome back. Here are the solutions to the exercises of section two. The first thing we need to do is import the standard libraries like numpy, matplotlib, and pandas and also set the matplotlib inline directive. So we do that in the very first cell. Then let's look at the exercise one. The first thing was to load the dataset. Well we've seen how to do this by using the pd dot read csv File it's a csv so I think this should have been pretty easy for you to do. Let's run it, loads pretty fast. Then we were asked to inspect it using the info and heads command. So let's run these. So the info command tells us there are two columns there are 144 values and no new values in either column. The first column is called month and its the second column is called thousand passengers. We can get a sneak peak-- oh we also know that the passengers are an integer whereas the month is a string. We can get a sneak peak of the values by using the head command which shows us the first five rows of the data frame.
So we see that the month is a date as a string with year and month and these are the number of passengers in thousands, so its an integer. Then we were asked to use a function, pd to datetime to change the column type of month to a datetime type. So we do this by using pd to datetime on the month column and we are just reassigning that to the same month so we are overwriting the column month column and then we are using df set index on month because check the recommendation set index takes the key which is the column column label or list of column labels that are gonna be used as index. So we set the month to be the index and with this new data frame with month as index we override the original dataframe. So let's see what it looks like now.
We've set the month column to be the index and notice how it also added the day because now it's interpreted as datetime not as a string. Now if we do df plot it does everything for us in the right way. Shows the right way the year it displays the title of the axis and it shows the legend that tells us what is displayed in the plot. Okay, so if you have any questions about this make sure to post them in the forum. I hope you enjoyed this video, see you in the next.
About the Author
I am a Data Science consultant and trainer. With Catalit I help companies acquire skills and knowledge in data science and harness machine learning and deep learning to reach their goals. With Data Weekends I train people in machine learning, deep learning and big data analytics. I served as lead instructor in Data Science at General Assembly and The Data Incubator and I was Chief Data Officer and co-founder at Spire, a Y-Combinator-backed startup that invented the first consumer wearable device capable of continuously tracking respiration and activity. I earned a joint PhD in biophysics at University of Padua and Université de Paris VI and graduated from Singularity University summer program of 2011.