Artificial Intelligence
Contents will be incrementally added and updated
45 flashcards · Computer Science · by claudehsu
What is the purpose of Artificial Intelligence?
To let computers act more and more like humans.
Currently do we have a multipurpose AI or AIs are good at one thing?
Currently AIs are good at one thing, meaning we may have one AI being good at chess, another one being good at recognizing items on a phote.
Recall the relationship among AI, Machine Learning and Deep Learning.
Machine Learning is like a subdomain of AI, and it is an approach to try and achieve AI thru systems that can find patterns in a set of data. Deep Learning or deep neural networks is one of the techniques for implementing machine learning
Recall the relationship between AI and Data Science
AI is the ability of machines to mimic human intelligence Data science is the process of extracting insights from data
Recall the steps in a full machine learning project.
Problem definition (what problem do we try to resolve?) Data (what data do we have?) Evaluation (What defines success?) Features (What features should we model?) Modeling (What kind of model should we use?) Experiments (What have we tried? What else can we try?)
Machine Learning Categories Supervised Learning (with 'labels') Unsupervised Leaning Reinforcement Learning
Recall two types of Supervised learning
classification - whether this is an apple or an orange? whether to hire this engineer based on inputs regression - predict stock prices
Recall two types of Unsupervised learning
clustering - group things into different groups association rule learning - associate different things to predict what a customer might buy in the future
Recall two types of Reinforcement learning
skill acquisition - process of an agent learning to perform a task by trial and error. For example, training robots to perform a variety of tasks, such as picking and placing objects or training agents to play video games real time learning - the ability of an agent to learn and adapt to a changing environment in real time. This is in contrast to traditional reinforcement learning, in which the agent learns from a set of pre-collected data. For example, robots must be able to learn and adapt to…
Recall the turkey diagram showing the difference between the regular algorithm and ML.
Normal algorithms follow the instructions to produce the desired output ML algorithms take both 'original' input and output as its input to figure out 'how'
What the difference between Data Analysis and Data Science?
Data analysis is the process of inspecting, cleaning, transforming, and modeling data with the goal of discovering useful information, informing conclusions, and supporting decision-making. Data analysts typically use statistical and graphical techniques to identify patterns and trends in data. Data science is a broader field that encompasses data analysis, but also includes other areas such as machine learning, artificial intelligence, and big data.
Refer to above diagram and fill in the blanks Problem: what problem are we trying to solve? Usually there are two types supervised: data with label unsupervised: data without label Data: what kind of data do we have? structured: like db tables and excel sheets unstructured: like images and audios Evaluation: what defines success? The metrics may not be accurate at the beginning and we may change it over time. Features: what do we already know about the data? numerical feature: data in number ca…
How to understand the sentence: ML is NOT the solution to every problem?
If a simple hand-coded instruction based system work, you should favor the simpler system over the ML solution.
Compare supervised learning with unsupervised learning.
Supervised learning: you have both data and labels. A ML algorithm tries to use the data to predict a label. If it guesses the label wrong, the algorithm corrects itself and tries again. This act of correction is why it is called supervised. Classification - is this sample one thing or another? If there are only two options, then it is called binary classification. For more than 2 cases, we call them multi-class classification. Regression - try to predict number, like how many people will buy t…
What is transfer learning?
Leverages what one ML model has learned in another ML. We can turn the model of deciphering the different types of car into the one that predicts the dog breed. So why this approach is valuable? Because to train a ML model is usually expensive. To find the pattern, ML algorithm may execute millions of times.
What is reinforcement learning?
It involves having a computer program perform some actions within a defined space and rewarding it for doing it well or punishing it for doing poorly. One good example is teaching a ML algorithm play chess. The chess board is the defined space and actions are moving pieces. For reward and punishment, these things can be as simple as updating a score.
Regarding to data, what's the difference between static data and streaming data? Figure out examples.
static data - data which does not change over time. CSV is one common format for static data. streaming data - constantly changed over time. For instance, news headlines stating the stock price.
Recall the data science workflow sample shown in the diagram
Think about the heart disease example, what data can be the feature?
For example weight gender heart rate chest pain
In predicting heart disease example, if only 10% records have the information of most eaten food on the patient, what should we do to that feature?
A ML algorithm learns best when all samples have similar information. In that case, we have two options leave that feature out collect more info before using the feature
Before really stepping in to the model part, we usually spit data into three parts. What are those parts and what is the corresponding purpose for each?
training data: choosing and training a model validation data: tuning a model test data: testing and comparing different models
What is the corresponding percentage of those data sets? training dataset: 70% ~ 80% validation dataset: 10% ~ 15% test dataset: 10% ~ 15%
What is generalization? Why do we need to pay attention to it?
Generalization is the ability for a ML model to perform well on data it hasn't seen before. We don't make the model like memorization machine. Otherwise, it will perform poorly on the data that it hasn't seen before.
Usually regarding to model, which thing are we supposed to do? a.) figuring out which model to use from the existing model, and tune it b.) creating our own model from scratch Answer: a
Training a model may take a while. Some models work better than others on different problems. One goal when training the model is to minimize time between Experiments. Recall two best practices to help on this point
use a small portion of data first begin with a less complicated model
Experiments step involves tuning a model and usually the validation dataset will be used. Recall the roast chicken analogy.
Notice the Temperature(hyperparameter) is changed.
Recall some real cases of tuning Random Forest Neural Network
Random Forest - change how many trees we'd like to split Neural Networks - try different number of layers
Once we feel we get the model built and tuned, what should we do next?
We need to evaluate its generalization with test dataset. A good model will yield similar results on the training, validation and test sets. A good example is like Training - 98%(performance) Test - 96%(performance)
What is underfitting?
Underfitting: The training set performance is even poor. For example Training - 65% (performance) Test - 50% (performance) Green dots represent test data samples and red line is the model
What is overfitting?
Overfitting: the test set perfromance is much lower than the training set while training set itself has a good performance. For example Trainging - 93% (performance) Test - 69% (performance) Green dots represent test data samples and red line is the model
What causes the underfitting and overfitting?
Underfitting - model is underfitting the training data when the model performs poorly on the training data. This is because the model is unable to capture the relationship between the input examples and output values. Overfitting - model is overfitting your training data when you see that the model performs well on the training data but does not perform well on new data. This is because the model is memorizing the data it has seen and is unable to generalize to unseen examples. Overfitting happ…
Usually, how to fix the underfitting issue?
try a more advanced model increase model hyperparameters, meaning to tune the model reduce amount of features, so that it'll be easier to find a pattern which may perform better training longer
Usually, how to fix the overfitting issue?
pause training process earlier, aka, early stopping collect more data, so that more generalized data is there and it's not easy to find the 'overfitting' model in the training data set try a less advanced model (not very common, but it's still an approach)
Given below models, which one should we choose?
It really depends on our goal. If we want a model with fast prediction time and the accuracy of the model is also important, then model 2 may be the best choice among the three.
Why do we use CONDA?
CONDA helps us build the environment we need. You can have multiple environments built on the same machine and in each environment, different versions of tools can be installed When there is new team members onboard, it's easy to share the environment with CONDA.
Once MINICONDA is installed, start the CONDA prompt. By default, we are in the base environment (base) C:\Users\Administrator> Now let's navigate to the desired workspace and create CONDA environment (base) c:\Sandbox>cd c:\sandbox\myfancyai We'd like to create an environment with below libs installed pandas numpy matplotlib scikit-learn In addition, we'd like to put all the environment files under a directory called 'env' under the 'MyFancyAI' directory. (base) c:\Sandbox\MyFancyAI> conda crea…
To list the available environments on the machine (base) c:\Sandbox\MyFancyAI>conda env list # conda environments: # base * C:\ProgramData\miniconda3 c:\Sandbox\MyFancyAI\env The asterisk indicates the environment we are currently using. It corresponds to the one notated in the parentheses at the head of the line. If we'd like to use the other one, we use command (base) c:\Sandbox\MyFancyAI>conda activate .\env (c:\Sandbox\MyFancyAI\env) c:\Sandbox\MyFancyAI>
We use relative path in the activation, and we can also use the full path. Notice after the activation, the command prompt changes to indicate the environment we're currently using.
After the environment is created, we notice that we forgot to add the library jupyter notebook. Let's add it to the desired environment. (c:\Sandbox\MyFancyAI\env) c:\Sandbox\MyFancyAI>conda install jupyter
Suppose we are in the CONDA Powershell prompt. How to check the installed libraries/packages in the current CONDA environment? To show all the installed libs/packages we run (C:\sandbox\MyFancyAI\env) PS C:\sandbox\MyFancyAI> conda list To check whether jupyter notebook is installed, we run (C:\sandbox\MyFancyAI\env) PS C:\sandbox\MyFancyAI> conda list | where-object {$_ -imatch "jupyter"}
For the last blank, notice the type of the object passing from pipe is string. (using get-member to, you can know the type)
Recall how to share the CONDA environment with others.
to share the enire project directory. The environment is already set up in the project directory and can run anywhere. simple approach, but an environment folder can be quite large to share to share a .yml (pronounced YAM-L) file of your Conda environment .yml is a text file with instructions to tell Conda how to set up an environment we export the environment to form the yml file
Suppose we are under the desired CONDA environment , how do we generate the yml file for the new comer to duplicate our environment? (C:\sandbox\MyFancyAI\env) PS C:\sandbox\MyFancyAI> conda env export --prefix ./env > c:\Sandbox\Temp\my_fancy_env.yml Once another team gets the yml file, s/he can duplicate the environment based on the file with below command conda env create --file my_fancy_env.yml --name easy_env
Some keystrokes for Jupyter Notebook to switch from edit mode to command mode, use esc keystroke to switch from command mode to edit mode, use enter keystroke to change the current cell to markdown type, use m keystroke to change the current cell to code type, use y keystroke to execute the current code cell, use shift+enter to add one cell above the current cell, use a keystroke to add one cell below the current cell, use b keystroke to delete the current cell, use d d keystroke to save the no…
Once Jupyter Notebook is installed, how to start it? (C:\sandbox\MyFancyAI\env) PS C:\sandbox\MyFancyAI> jupyter notebook [I 20:03:47.091 NotebookApp] Writing notebook server cookie secret to C:\Users\Administrator\AppData\Roaming\jupyter\runtime\notebook_cookie_secret
Suppose we have downloaded an image file called 'printer_cleaner.jpg' from internet. How to display it in one notebook? upload the image file to the desired working directory (we can use the upload function of Jupyter Notebook) change the cell type to markdown type to display the image, key in content 
If we'd like to quickly run some OS terminal commands, what do we do? For instance, if we'd like to use the dir command to check the files under c:\ driver. make sure the cell type is code key in content !dir c:\ and then run the cell