Artificial Intelligence Lecture Notes PDF
Document Details
Uploaded by BestChrysoprase353
Kafr El Sheikh University
Tags
Related
- Artificial Intelligence with Machine Learning (Unit 1) PDF
- Artificial Intelligence (AI) PDF
- Artificial Intelligence and Machine Learning Applications in Smart Production (PDF)
- Introduction to Artificial Intelligence PDF
- DST301 Artificial Intelligence Applications Lecture 02 - Machine Learning PDF
- CPCS-335 Introduction to Artificial Intelligence Lecture 8 PDF
Summary
Lecture notes on Arificial Intelligence covering machine learning and its applications. They include the Iris dataset as a dataset of samples of Iris flowers with various measurements and classifications. The lecture also covers code snippets and functions.
Full Transcript
# ARTIFICIAL INTELLIGENCE ## Agenda - Machine Learning and its Applications ## Iris Dataset The dataset contains 150 samples. There are 50 samples for each of the three species of Iris flowers. The dataset has 4 features (attributes) for each sample: - Sepal Length - Sepal Width - Petal Length...
# ARTIFICIAL INTELLIGENCE ## Agenda - Machine Learning and its Applications ## Iris Dataset The dataset contains 150 samples. There are 50 samples for each of the three species of Iris flowers. The dataset has 4 features (attributes) for each sample: - Sepal Length - Sepal Width - Petal Length - Petal Width There are 3 classes: - Iris-setosa - Iris-versicolor - Iris-virginica Each class has 50 samples. ### Table of Data | Sepal Length | Sepal Width | Petal Length | Petal Width | Species | |---|---|---|---|---| | 5.1 | 3.5 | 1.4 | 0.2 | Iris-setosa | | 4.9 | 3.0 | 1.4 | 0.2 | Iris-setosa | | 4.7 | 3.2 | 1.3 | 0.2 | Iris-setosa | | 6.3 | 3.3 | 6.0 | 2.5 | Iris-virginica | | 5.8 | 2.7 | 5.1 | 1.9 | Iris-virginica | ## Classification model - **Import Libraries:** Import the necessary libraries from scikit-learn. - **Load Dataset:** Load the Iris dataset, which is included in scikit-learn. - **Split Dataset:** Split the dataset into training and testing sets using. - **Create SVM Classifier:** Create an SVM classifier with a linear kernel. - **Train Classifier:** Train the classifier using the training data. - **Make Predictions:** Use the trained classifier to make predictions on the test data. - **Evaluate Model:** Calculate the accuracy of the model and print it, along with the predicted and actual labels. ## Install the necessary libraries `! pip install scikit-learn` ## Import necessary libraries ```python from sklearn import datasets from sklearn.model_selection import train_test_split from sklearn.svm import SVC from sklearn.metrics import accuracy_score ``` ## Load the Iris dataset ```python iris = datasets.load_iris() X = iris.data # Features y = iris.target # Labels ``` ## Split the dataset into training and testing sets ```python X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42) ``` ## Create an SVM classifier ```python svm_classifier = SVC(kernel='linear') ``` ## Train the classifier ```python svm_classifier.fit(X_train, y_train) ```