AIYA Pre-Requisites Session 3
AIYA Pre-Requisites Session 3
Pre-Requisites
Module 3 – Introduction to Python Libraries
Reading Material:
- Load a simple CSV file containing some data with columns like 'Name', 'Age', 'Gender'.
What is NumPy?
Introduction to NumPy for numerical computing in Python
Creating and manipulating arrays using NumPy
dot_product = Performs
np.dot(arr2, arr3) the dot
dot_product product
between
both the
arrays
Pandas for Data Manipulation
Introduction to Pandas
Overview of Pandas for data manipulation and analysis
Working with DataFrames in Pandas
mean_age = Finding
df['Age'].mean( mean of the
) column
named ‘Age’
filtered_data = Creating a
df[df['Age'] > new
25] dataframe
filtered_data with filtered
data
Pandas for Data Manipulation
Introduction to Pandas
Overview of Scikit-Learn for machine learning in Python
Basics of supervised learning and classification
Code Explanation
from sklearn.model_selection import Importing required libraries
train_test_split
from sklearn.tree import
DecisionTreeClassifier
from sklearn.metrics import accuracy_score
from sklearn.datasets import
make_classification
X, y = Creating a fummy dataset with 1000
make_classification(n_samples=1000, samples, 20 features and classified into 2
n_features=20, n_classes=2, classes
random_state=42)
X_train, X_test, y_train, y_test = Splitting the data into test and train
train_test_split(X, y, test_size=0.2,
random_state=42)
model = DecisionTreeClassifier() Creating a decision tree model
predictions = model.predict(X_test) Predictions from the model
accuracy = accuracy_score(y_test, Predict the accuracy of the model
predictions)