Transcript:
Hey, everyone, and welcome back to this class. The numpy stack in Python in this lecture. I want to give you a small update on the syntax For converting a panda’s data frame into a numpy array in a recent versions of pandas, you may have noticed that a warning appears when you attempt to use the as matrix function. Let’s do an example, so let’s start by importing pandas and numpy you now let’s create a data frame doesn’t really matter what’s in it. You now let’s try using AZ matrix to obtain a numpy ray as you can see. It says, as Matrix is deprecated and will be removed in a future version and we should use that values instead, so lets. Try that awesome! It works as expected now. I think this is actually a pretty good change because the function named as matrix is confusing. We know that an umpire Ray is not the same as a numpy matrix, and so we’d expect a function and named as matrix to return a matrix rather than an umpire, Ray. But in fact, the array is more useful to us because that’s what’s normally used in machine. Learning matrices are rare using the actual matrix object is rare. I want to also take this opportunity to discuss something else related to this topic, which I think is very important. Specifically, it’s very important if you are a beginner to programming or machine learning. Luckily, nobody so far has complained that as Matrix is quote/unquote out of date, however. I’ve seen people get scared about similar things in the past, such as when you’re switching from Python to to Python 3 the central message is if you are a beginner. Try not to be afraid of change. Changes happen to libraries pretty much constantly. If you freak out every time, then you will be freaked out all the time, and that won’t really be helpful to your longevity in this field. The important rule. I want you to remember is learn the principles, not the syntax. So repeat after me, learn the principles, not the syntax. Let’s go over some quick examples of how this principle can be applied and where it’s been useful for me. In the past, One great example, is tensor flow tensor flow at one point around 2017 to 2018 was releasing new versions pretty much every month they would make changes. That would break your old code now. If you look at this from a beginner perspective, then every time this happened, you would freak out and not know what to do. Of course you’re not going to just throw away all your old code and start over having to relearn everything about tensor flow. Instead, you learn the principles, not the syntax. So one boilerplate line That changed was TF dot initialize all variables, which was changed to TF dot global variables initializer. If you only learn the syntax, then you’d be very worried because the syntax you previously thought was correct is no longer correct, but if you learn the principles, then you’d be safe. You know that both of these are doing the same thing. Some kind of variable initialization another great example is going from Python to to Python. 3 beginners always get very scared about this because some code, which works in Python 2 no longer works in Python 3 but the differences are so trivial. It always surprises me when people have problems as an example, consider a for loop using the X range function in Python 2 we would use X range because the range function returns a list which is slow and unnecessary in Python 3 X ranges were moved and the range function takes its role. So if you’re a beginner and you’re too worried about the syntax, you’d get scared because X range doesn’t work anymore, and now you can’t get your code running if you learn the principles instead of the syntax, you realize, wait a minute. Both of these are just for loops and we want to use a generator rather than instantiate a list in memory. The principle is important, not the syntax. This leads us to our final, and I think most important example, which is learning different computer programming languages at this point, 90% of the court. I write is in Python, but I would be very comfortable, Writing in at least a handful of other languages – such as Ruby Javascript, C C++ and Java. Well, how can that be that I have to sit down and learn each of these languages from scratch do? I have to constantly practice them so that I don’t forget how they work. The answer is no. I’ve saved myself a lot of time by understanding the principles of computer programming instead of trying to understand the syntax, the syntax between these languages is similar, but not equivalent. And so if you let tiny differences in syntax, be a heavy burden, you will spend significantly more effort trying to learn different languages as an example. Here’s how you would print out all the elements of an array in Python C++ and Java. As you can see, the basic pattern is the same. The flow of code is the same. The only difference is miners and tactical details. But I hope you can see that. Once you learn one language learning, another similar language would become easier because you would hopefully learn to recognize the patterns that appear across all the languages you learned and those patterns you see are the core principles they are called principles because they are fundamental constants, which are unchanging by learning principles rather than simply memorizing syntax. You make yourself. More resilient to minor changes and as you’ve seen with tensor flow in a few other libraries, change is to be expected in this new and rapidly growing field, a lot of the libraries we use in data. Science are version 0.1 a version 0.5 alpha version and so forth. So you can already tell that they are in a state where nothing is set in stone. Once you learn to recognize the principles, you’ll have a much easier time, learning new concepts and adapting to new versions, new libraries and even new languages.