0% found this document useful (0 votes)
2 views

Data Science Lab record2025(2)

The document outlines various Python programming exercises, each with a specific aim and algorithm. It covers topics such as data analysis using Pandas, machine learning algorithms like Linear Regression and Support Vector Machine, and concepts in reinforcement learning. Each exercise includes steps for implementation and visualization of results.

Uploaded by

saravanan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Data Science Lab record2025(2)

The document outlines various Python programming exercises, each with a specific aim and algorithm. It covers topics such as data analysis using Pandas, machine learning algorithms like Linear Regression and Support Vector Machine, and concepts in reinforcement learning. Each exercise includes steps for implementation and visualization of results.

Uploaded by

saravanan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 64

Ex.

No Date
Study and usage of Python
1

Aim:

Algorithm:
Program:

Step: 1 Import necessary library

Step: 2 Define the number array

Step: 3 Convert to a Pandas Series for ease of analysis


Step: 4 Evaluate the descriptive Statistics

Step: 5 Evaluate the Measure of Central Tendency


Step:6 Evaluate the Measure of Variability

Step:7 Visualize the Data


Result:
Ex. No Date
Python Packages
2

Aim:

Algorithm:
Program:

Step 1: Import the necessary library for NumPy operations.

Step 2: Perform basic mathematical operations on arrays using NumPy.


Step 3: Perform statistical operations like sum, mean, median, standard deviation,
variance, and max value using NumPy.

Step 4: Import the Pandas library for data manipulation.

Step 5: Create a simple Pandas DataFrame to store and display data.


Step 6: Use the loc attribute to locate specific rows by index in a Pandas DataFrame.

Step 7: Create a Pandas DataFrame with named indexes (days).


Step 8: Load a CSV file into a Pandas DataFrame.

Step 9: View the first and last few rows of a DataFrame using. head () and. tail ()
methods.
Step 10: Create a linear plot using Matplotlib to visualize data.
Result:
Ex. No Date
Find-S Algorithm
3

Aim:

Algorithm:
Program:

Step:1 Initialize the most specific hypothesis to the first positive example

Step:2 Define training data (attribute1, attribute2, ..., target)


Step:3 Find the most specific hypothesis
Result:
Ex. No Date
Linear Regression
4

Aim:

Algorithm:
Program:

Step:1 Import the necessary libraries

Step:2 Define your dataset


Step:3 Convert locality into dummy variables

Step:4 Separate features and target variables.


Step:5 Initialize the Linear Regression Model

Step:6 Test the accuracy of model


Step:7 Make predictions
Result:
Ex. No Date
Logistic Regression
5

Aim:

Algorithm:
Program:

Step:1 Import necessary libraries

Step:2 Load the dataset

Step:3 Filter for binary classification

Step:4 Split the dataset into features and target variable

Step:5 Split the data into training and testing sets


Step:6 Initialize and train the Logistic Regression model

Step:7 Make predictions on the test set

Step:8 Evaluate the model's performance


Step:9 Display accuracy score

Step:10 Make Predictions


Result:
Ex. No Date
Support Vector Machine (SVM)
6

Aim:

Algorithm:
Program:
Step 1: Import necessary libraries

Step 2: Load the dataset (Iris dataset)


Step 3: Preprocess the data

Step 4: Train and classify using SVM


Step 5: Use KMeans to cluster the data

Step 6: Visualize the results


Result:
Ex. No Date
Decision Tree
7

Aim:

Algorithm:
Program:
Step1: Loading The Data Set
Step2: Calculate the Entropy of Target Variable

Step3: Calculate the information gain of each Attribute


Step4: Find the root node by finding maximum information again

Step5: Displaying the Decision Tree based on Entropy Values


Result:
Ex. No Date
K-Means Clustering
8

Aim:

Algorithm:
Program:

Step 1: Import necessary libraries

Step 2: Load and preprocess the dataset


Step 3: Standardize the data

Step 4: Apply K-means clustering


Step 5: Visualize the clusters
Result:
Ex. No Date
Naive Bayes Theorem
9

Aim:

Algorithm:
Program:
Step 1: Import Libraries

Step 2: Create Sample Dataset


Step 3: Converting Categorical value

Step 4: Defining Features and label


Step 5: Splitting the dataset

Step 6: Initialize the Gaussian Naïve Bayes model

Step 7: Making Prediction on test


Step 8: Calculating Accuracy

Step 9: Predict the Class Labels


Result:
Ex. No Date
Hidden Markov Model
10

Aim:

Algorithm:
Program:
Step:1 Import the libraries

Step:2 Generate synthetic data with two hidden states


Step:3 Train the HMM Model

Step:4 Predict the Hidden States

Step:5 Visualize the results


Step:6 Display learned parameters
Result:
Ex. No Date
Bagging and boosting
11

Aim:

Algorithm:
Program:
Step:1 Import the necessary libraries

Step:2 Load the Iris Dataset

Step:3 Initialize the Bagging Classifier


Step:4 Visualize the Confusion Matrix for Bagging
Step:5 Initialize the Gradient Boosting Classifier
Step:6 Compare accuracies of Bagging and Boosting
Result:
Ex. No Date
Reinforcement Learning
12

Aim:

Algorithm:
Program:
Step:1 Import necessary libraries (NumPy, random, Matplotlib).

Step:2 Define a Grid World class to simulate a 5x5 grid with obstacles. The agent
(robot) must navigate from the top-left to the bottom-right corner, avoiding obstacles.
Step:3 Define the Q-learning agent class, where the agent learns the optimal actions
using the Q-learning algorithm. It maintains a Q-table to store the expected future
rewards for each state-action pair.
Step:4 Initialize the environment and obstacles, and train the Q-learning agent over
multiple episodes. The agent learns to navigate the grid by updating its Q-values after
each action.
Step:5 Visualize the agent's learned path, showing how the robot navigates the grid
from start to goal while avoiding obstacles.

You might also like