Scarica Machine and Deep Learning e più Dispense in PDF di Tecniche Di Intelligenza Artificiale solo su Docsity!
MACHINE AND DEEP LEARNING NOTES
INTRO
- Artificial Intelligence
- Python
- Install Python
- Install Packages
- Virtual Environment
- Miniconda
- Numpy
- Pandas
- PIL
- Scikit-learn
- PyTorch
- Machine Learning categories MACHINE LEARNING
- Workflow
- Feature engineering
- Training and Evaluation
- Performance evaluation
- Bayesian learning
- Non parametric learning
- Density estimation
- KNN
- Decision tree
- Linear models
- LDA
- Logistic regression
- SVM
- SVR
- Ensemble Method
- Bagging
- Boosting
- Multiclass decomposition
- Unsupervised learning
- Artificial Neural Network DEEP LEARNING
- How a Neural Network work
- Backpropagation
- History of Neural Networks
- Neuron
- Learning slowdown
- Vanishing gradient
- Overfitting
- Covariate shift
- Multilayer perceptron
- Convolutional Neural Network
- Backbone history
- Transfer learning
- Segmentation
- Object detection
- Generative Adversarial Network
- Recurrent Neural Network
- Attention
- Transformers
- Bibliography
1.Artificial Intelligence (AI):
AI is a broad field of computer science focused on creating systems or machines that can
perform tasks that typically require human intelligence. AI systems can be rule-based or data-
driven and aim to replicate human-like decision-making and problem-solving abilities.
2.Machine Learning (ML):
ML is a subset of AI that focuses on developing algorithms and models that allow computers
to learn and make predictions or decisions from data without being explicitly programmed.
ML models improve their performance through experience and exposure to training data.
3.Deep Learning (DL):
DL is a subfield of ML that uses artificial neural networks, inspired by the structure and
function of the human brain, to solve complex problems.
Example:
1. AI: distinguish fruits
2. ML: feed the computer with a dataset of various fruits with labeled names and features, and
the machine learns patterns to identify fruits based on this input
3. DL: creating a complex neural network that can automatically extract hierarchical features
from the fruit images, improving accuracy without explicit programming for each feature
Artificial Intelligence
Scripting language, not typed
- value1, value2, ...: The values or expressions to be printed.
- sep=' ' (optional): The separator between the values. The default is a space.
- end='\n' (optional): The end character at the end of the print statement. The default is a newline.
- file=sys.stdout (optional): Specifies the file where the output will be written. The default is the console.
- flush=False (optional): If True, the output is forcibly flushed. The default is False.
- prompt=None (optional): The message to display before the user input. Python
Main types :
I/
- def: Keyword used to declare a function.
- function_name: The name of the function.
- (parameter1, parameter2, ...): Parameters are inputs to the function. They are optional.
- : : Colon indicates the start of the function’s code block.
- Docstring: Optional documentation string enclosed in triple-quotes. It provides information about the
function’s purpose, parameters, and return values.
- return result: Optional statement that specifies the value to be returned by the function.
Call a function:
Using placeholder to ignore the value:
In case of more argument return:
Functions :
- class MyClass:: Define a class named MyClass.
- Attributes: Variables that store data related to the class.
- Methods: Functions that define behaviors associated with the class. The first parameter of a method is
usually self, which refers to the instance of the class.
Initialize class:
Access attributes and methods:
The init method is a special method (constructor) that is called when an object is created. It initializes the
attributes of the object.
Classes can inherit attributes and methods from other classes. The super() function is often used to call methods
from the parent class.
You can use underscores to indicate private attributes and methods. Private members should not be accessed
directly from outside the class.
Classi
Doest Python do all the job? No. Python is used together with:
- modules: piece of code that may be built upon
- packages: collection of modules
- Importing the entire package/module:
- Importing with an alias:
- Importing specific items from a package/module:
- Importing all items from a package/module (not recommended for large packages):
In this way we can call the functions and modules to be used in our code.
Packages are installed with the package installer for Python (pip command). After the
installation via python.org they will be stored in /usr/local/bin. If a package is installed with
pip before the installation of python, they will be stored in the system python path /usr/
bin.
Install (^) packages
The Virtual environment (venv) is a space where all the package we install are visibile.
When a project is created we have to choose the relative venv in order to define which
packages can be used in our application. At the beginning with only Python installed we
should have this situation
Example of selection of the venv in Visual Studio Code:
*IMPORTANT: the venv of the operating system will be ever visible, and after the
installation of Python will be no longer usable to install packages. This is a correct thing,
but if for any strange reason it is needed to install something on the /usr/bin/python3, it is
possible to create a symbolic link with the command:
sudo ln -sf /usr/bin/python3 /usr/local/bin/python Virtual environment
The new environment will be visible and can be chooses in your different projects:
Example of creation of the venv:
The Python version of the venv will be the same installed via python.org.
We can see that a specific venv is active because before the name in the terminal we
have the venv name surrounded by brackets.
Once activated, every package will be installed into the activated venv.
In order to launch a python script with a specific venv, this specific venv have to be
activated before launching the script.
Miniconda is a convenient venv manager. It is the essential part of the bigger Anaconda
venv manager that is included with a GUI.
When Miniconda is installed, a default venv is created. Once the terminal is running, the
conda environment is the default environment running.
Example checking venv from Visual Studio Code:
Minicando
NumPy is a powerful numerical computing library in Python, providing support for large, multi- dimensional arrays and matrices, along with a collection of mathematical functions to operate on these arrays. The main structure in NumPy is the ndarray (n-dimensional array). The ndarray (n-dimensional array) is the core data structure in NumPy, a numerical computing library in Python. The ndarray is a powerful, flexible, and efficient container for large datasets and numerical operations. Numpy
Pandas is a powerful open-source data manipulation and analysis library for Python. It provides data structures for efficiently storing and manipulating large datasets. The name “Pandas” is derived from the term “Panel Data,” an econometrics term for multidimensional structured data sets. Two primary data structures in Pandas are the DataFrame and the Series. DataFrame:
- A DataFrame is a two-dimensional, labeled data structure with columns that can be of different data types. It can be thought of as an Excel spreadsheet or SQL table.
- Each column in a DataFrame is a Pandas Series, and they share the same index.
- You can perform various operations on a DataFrame, such as filtering, grouping, merging, and reshaping data. Series:
- A Series is a one-dimensional labeled array capable of holding any data type.
- It is essentially a single column of a DataFrame.
- Series can be created from various data types, such as lists, arrays, or even other Series. Pandas