Machine Learning Tutorial #1 Python.

 Hello everyone and welcome to the first machine learning tutorial on my channel. Now you guys have been waiting a long time for this, so I appreciate it and hopefully it's gonna be worth it for all of you. Now, this first video is all gonna be about setup and kind of an introduction to machine learning, so please make sure you watch the entire video because I would hate for you guys to skip onto the next ones and not be able to do anything because you messed up the setup in somehow. 





These steps are very important and skipping over small things like even skipping like 30 seconds of the video, you could miss an important thing. So just keep that in mind as you watch. Now, quickly before I start, I'm just gonna go over kind of the flow of the tutorial, what I'm gonna be doing, what's gonna be happening and like the flow, right? So we're gonna start obviously in this video like setting up, getting our environment set up. We're not gonna write really any code other than like one or two lines just to make sure everything's working. But this is really important, so make sure you follow along in the next videos. We're gonna be going over some standard and very basic machine learning algorithms that you should really understand and learn before moving into deep learning and neural networks. 


So I highly encourage you to watch these beginning videos. I know they are not as exciting as the deep learning and neural network parts, but they are fundamental and if you don't understand them moving into the other stuff, it's just gonna be really complicated and you might be able to do it but you're not gonna understand anything that's going om. In terms of understanding, now, all the stuff that I'm going to be doing, you will understand on a very basic level why these things work.


 Now these basic simple algorithms I can explain to you, but as soon as we go into deep learning and neural networks you have to have a fundamental understanding of linear algebra and calculus to be able to understand like the math behind the the formulas and the computing that actually goes into neural networks because it's actually like math professors and professionals that have kind of created that thing. Now, what we're gonna be doing essentially, machine learning is really like feeding in data and getting some kind of output, right? So you're giving a test data set for a machine to train off of and learn off of and then hopefully based on that data it can use new data that's never seen before to predict certain outcomes or to classify images or to do things along those lines. So that's kind of a basics of what's gonna be going on throughout this tutorial series. 


I have no idea how long it's gonna be, but I hope you guys stick around. If you have any comments or questions along the way you can either join my discord or hit me up on Twitter or something and I'll be happy to help you out. So without further ado. 



Let's get into actually installing and getting working with tensorflow, which is what we're gonna be using throughout the rest of these tutorials. So tensorflow is a library for scientific computing and machine learning in python. Now to install tensorflow is not very easy, unfortunately. If you already have tensorflow installed, skip this video and just go to the next one. If you don't, please follow very carefully. Now, if you have a CUDA enabled GPU, so you have a NVIDIA GPU that is a 1050 Ti or higher-- I believe, don't quote me on that, but I believe that's what it is, you can actually run this on your GPU which will be exponentially faster than running it off of your CPU. If you want to know how to install that, please refer to the video I'm going to put in the top right hand corner here and in the description down below on how to install tensorflow on GPU because this is only gonna be for CPU. Okay, so first thing we need to do is we need to download and install PyCharm, this is the IDE we are gonna be using. We're not using Spyder or any of that stuff. I hate those IDEs. PyCharm is what I use, so that's we're gonna be using for these videos.



 Once you've downloaded install PyCharm-- by the way, it's completely free and I have videos on my channels explaining how to use it if you're confused. We need to download and install Anaconda, I assume most of you probably have this. If you don't, just download any version of Anaconda. 3.7 would be preferable. And once you run through that, PLEASE, when you're installing, click on "Add Anaconda to my PATH". It's gonna say like it's not recommended, please add it to path. Otherwise, this is gonna be much harder than it has to for you. Ok, and all these links are in the description for the installs. Ok, so now that we've done that. we're gonna open up our command prompt and start setting up a virtual environment that we're gonna install all of our tensorflow packages into. So what I'm gonna do now is, first of all, make sure that Conda is installed properly and working. So, I'm just gonna type Conda and hit enter. If you get some output that looks like this and you don't get any error messages, you're good to go. If you get any errors, please fix them before moving on.




 I don't know what your issue is, but leave a comment down below or go on my discord and I'd be happy to help you out. Or, go on the internet because there's answers to pretty-- well everything on there. Now that we've done that we're going to create a Conda environment. We're gonna do this by typing "conda -", actually "create" and then " -n" and then we're gonna give it a name. In this case, I'm gonna call mine tensor you can call whatever you want, but I would recommend naming it something you're gonna remember. And then we are going to type "python=3.6". Now some of you may think 'Oh, I'm gonna be starting smart and do 3.7 because that's the newest version of Python.' Don't do that! If you do that, you will not be able to install tensorflow because it's not supported on python 3.7 as of right now. So 3.6 is the latest version that's supported on, so we're gonna use three six. Okay, now it's gonna solve an environment and it's going to pop up question a second asking us if we want to install. We're going to type Y and hit enter and we're going to wait for this to solve and execute the environment or whatever it's doing and this could take a second. 




Just so you know. Okay, so now that that's happened and we've done that we're going to activate our environment by typing "activate tensor". Now this is what we need to do anytime we want to install new packages into our environment. We need to just go into our command prompt and we don't even have to type Conda or anything, like say we open up a new command prompt just type "activate" and then the name of your virtual environment in this case "tensor". Okay, it should pop up in brackets here showing you you're in a virtual environment and then you know, everything is working. So now what we're gonna do is we're gonna use pip which is pre-installed in all of our tensor or all of our Conda environments To install tensorflow, so we're gonna type "pip install tensorflow" like this and just hit enter. Now, this will take a few minutes. This is a fairly large file and once that's done, I will be right back. Okay, so now the tensorflow is installed we can go ahead and install another package that we're gonna need that's gonna contain a bunch of data sets for us. And this is called Keras. So we're just gonna go-- not install-- "pip install keras" K E R A S, like that. And this one should be a bit faster, but we'll see so I'll be back in a second. Okay. So now that Keras is installed, it's actually time to set up our environment within PyCharm and make sure that we can import tensorflow and everything's working fine for us. So we're gonna close the command prompt now, we're done with all that, and we're going to open up PyCharm. Okay. 




So again, make sure you install PyCharm, it's completely free, and you should have something that looks like-- I'm just gonna remove this-- looks like this, okay? If this is your first time opening it up. If not, just close your project so you can get-- or just create a new project like I'm about to do. Okay, so we're gonna go Create New Project and we're gonna call this whatever you want. In this case, I'm just gonna call mine tensorEnv and just leave the project interpreter for right now. We're gonna change that in a second. Okay? So then we click Create. Okay, so sorry. I just had to restart the recording there because apparently when I launch, what do you call it, PyCharm, my webcam doesn't like that and it lags out and freaks out. So anyways now I'm back in all I did that you guys missed was I created a New File, so a new Python file inside of my project and I'm just gonna try something quickly. I'm gonna type "import" and then "tensorflow" like this. Okay, you should see immediately it's showing you that there's no module named tensorflow. Now, that's because we haven't yet set up the project interpreter and got these packages into PyCharm so to do this we're gonna go to File and go to Settings. We're gonna go to Project Interpreter and then you should see that you have like a default Project Interpreter, we're gonna change this, Now, if you go in this list and for some reason you see your interpreter, click on it and you can use that by just clicking apply and you're done But most likely you guys don't have this, so I'm going to show you how we can add a new interpreter. To do this, we're go to Settings and click Add... so this little gear (Settings). We're going to go to Conda Environment and we're gonna go to Existing environment. We're going to now find the environment that we just created. So,  it should, again, if you do this, I'm not going to show you any interpreters because we haven't yet made one. So we're just gonna click on these little dots. 




We're going to navigate to that environment. Now, most likely your Anaconda installation is in C:\users\your_user and then you should see it showing up. But, if for some reason that's not there, you can find it if you don't know where it is, by going to your file explorer just go to This PC and then type in Anaconda and just search for that and it should find the path. Okay, it's gonna take a few minutes 'cause it's gonna search through all your drives. But once that's done it will show you where it is. Okay, so I'm not gonna do that because I know where it is. Once we do that, we're gonna click Anaconda we're gonna go into the folder envs, standing for environments. and then we're going to select our environment that we just created, in this case tensor. We're gonna go in there and we're gonna click on pythonw.exe, NOT python.exe, pythonw.exe. We're gonna click OK Okay again click Apply and click OK. Okay, so I had to restart the recording again because it keeps lagging every time I do something in PyCharm. But, anyways, It should be doing this like little bar down here saying that it's now kind of getting all the packages setup and everything ready. While that happens, we can actually create a configuration for our projects. We're gonna go to Add Configuration going to click on the plus, Python, we're going to name this-- I'm just gonna name it test, because it's named my file. I'm gonna find our Python file. So, in this case, it should be in tensorEnv and then inside test. So I'm gonna click OK, Apply, and OK, and I'll be back in one second once this has loaded up. Ok So hopefully now, this has finished, this little uploading bar or whatever 'cause it does have to install a few packages and stuff for PyCharm to work properly. 





You should see now that we just have a greyed out statement that says 'Unused import statement'. To make sure that everything is working. We're just gonna run this and ensure that we don't get any errors when we import tensorflow. We're also going to import Keras, like this ok, and make sure that this is working as well. So there we go, awesome. So it says 'Using Tensorflow backend' and if you get any red text messages, but it says like process finished and like it's working fine, that's ok as long as it's like this. Like it's not telling you there's an error, it's just kind of saying what's going on because that's kind of what Keras and Tensorflow do sometimes. 








So anyways, that has been how to set up Tensorflow and get ready to work on actually creating some machines, creating some machine learning algorithms, and all that fun stuff. So, if you guys are excited about the next videos, please make sure you leave a like on this video and subscribe to the channel to be notified when all this content is coming out. One last time, you guys should go follow my Twitter because that's where I'm gonna post a ton of updates. I'm gonna be doing a lot of cool stuff on there, and I'd love to see you guys hopping on there. So with that being said, I will see you guys in the next video.