is

Practical no 1


Aim: Perform the data classification using classification algorithm using R/Python.


  1. Timeseries


rainfall <- c(799,1174.8,865.1,1334.6,635.4,918.5,685.5,998.6,784.2,985,882.8,1071)

timeseris<-ts(rainfall,start=c(2012,1),frequency = 12)

print(timeseris)

plot(timeseris)


b)  Decision Tree


data(iris)

print(iris)


library(rpart)


model <- rpart(Species ~ ., data = iris, method = "class")


prediction <- predict(model, iris, type = "class")


table(prediction, iris$Species)


new_data <- data.frame(

  Sepal.Length = 5.1,

  Sepal.Width  = 3.5,

  Petal.Length = 1.4,

  Petal.Width  = 0.2

)


new_prediction <- predict(model, new_data, type = "class")


print(new_prediction)



Practical No:2


Aim: Perform the Linear regression on the given data warehouse data using R/Python.


data <- data.frame(

  weight = c(45, 50, 55, 60, 65, 70, 75),

  height = c(150, 155, 160, 165, 170, 175, 180)

)


print(data)


model <- lm(height ~ weight, data = data)


summary(model)


new_weight <- data.frame(weight = 68)


predicted_height <- predict(model, newdata = new_weight)


print(predicted_height)


model1 <- lm(weight ~ height, data = data)


new_height <- data.frame(height = 167)


predicted_weight <- predict(model1, newdata = new_height)


print(predicted_weight)





Practical No:3


Aim: Logistic Regression


data(mtcars)


print(mtcars)


model <- glm(am ~ mpg + hp + wt, data = mtcars, family = binomial)


summary(model)


odds_ratios <- exp(coef(model))

print(odds_ratios)


predicted_prob <- predict(model, type = "response")


predicted_class <- ifelse(predicted_prob > 0.5, 1, 0)


conf_matrix <- table(Predicted = predicted_class,

                     Actual = mtcars$am)


print(conf_matrix)






Practical no 4


Aim: Perform the data clustering using clustering algorithm using R/Python.


data(iris)


head(iris)


newiris <- iris


newiris$Species <- NULL


head(newiris)


kc <- kmeans(newiris, centers = 3)


print(kc)


table(iris$Species, kc$cluster)





Practical 5

Aim: Perform data visualization using Python on any sales data.


import pandas as pd

import matplotlib.pyplot as plt


data = {

    'Month': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'],

    'Sales': [15000, 18000, 17000, 21000, 24000, 23000]

}


df = pd.DataFrame(data)


print(df)


plt.figure(figsize=(8, 5))

plt.plot(df['Month'], df['Sales'], marker='o', linestyle='-', color='blue')


plt.title('Monthly Sales Data')

plt.xlabel('Month')

plt.ylabel('Sales')


plt.grid(True)


plt.show()


Practical 6

Write a Python program to read data from a CSV file, perform simple data analysis, and generate basic insights.



Month

Region

Sales

Jan

North

15000

Fed

south

18000

Mar

east

17000

April

west

21000

May

north

24000

Jun

south

23000



import pandas as pd


df = pd.read_csv('sales_data.csv')


print("First 5 Rows of Dataset:")

print(df.head())


print("\nDataset Information:")

df.info()


print("\nSummary Statistics:")

print(df.describe())


print("\nMissing Values in Each Column:")

print(df.isnull().sum())


if 'Sales' in df.columns:

    total_sales = df['Sales'].sum()

    avg_sales = df['Sales'].mean()

    max_sales = df['Sales'].max()

    min_sales = df['Sales'].min()


    print("\nSales Analysis:")

    print("Total Sales:", total_sales)

    print("Average Sales:", avg_sales)

    print("Maximum Sales:", max_sales)

    print("Minimum Sales:", min_sales)

else:

    print("\n'Sales' column not found in dataset.")


print("\nAnalysis Completed Successfully!")



Practical 7


Apply the what – if Analysis for data visualization. Design and generate necessary reports based on the data warehouse data. Use Excel.





Practical 8

Create the Pivot table and PivotChart.



 Example Data

Month

Region

Sales

Jan

North

15000

Jan

South

12000

Feb

North

18000

Feb

South

14000


 Steps to Create Pivot Table

  1. Select your entire data

  2. Go to Insert tab

  3. Click PivotTable

  4. Choose:

    • “New Worksheet” 

  5. Click OK


Build the Pivot Table

In the PivotTable Fields panel:

  • Drag Month → Rows

  • Drag Region → Columns

  • Drag Sales → Values


 Result

Month

North

South

Jan

15000

12000

Feb

18000

14000


Customizations

  • Change Sum → Average:

    • Click dropdown in “Sum of Sales”

    • Select Value Field Settings

  • Sort data (highest to lowest)

  • Apply filters (e.g., by Month or Region)


2. Pivot Chart in Excel

 Steps

  1. Click anywhere inside the Pivot Table

  2. Go to Insert tab

  3. Click PivotChart

  4. Choose chart type:

    • Column chart (most common)

    • Bar chart

    • Line chart

  5. Click OK


  • X-axis → Months

  • Y-axis → Sales

  • Different colors → Regions


 Customize Chart

  • Add Chart Title

  • Change colors/styles

  • Add Data Labels

  • Use Filters (slicers) for interactivity



Comments