0% found this document useful (0 votes)
12 views16 pages

Data Science Programs and Exercises

Uploaded by

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

Data Science Programs and Exercises

Uploaded by

mdharamnarayan
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Index

Sno Program
1 Program 1: Write about yourself(Introduction).
2 Program 2:- Calculate MSE and RMSE values for the data given below using MS Excel.
3 Program 3: Given a confusion matrix, calculate Precision, Recall, F1 score and Accuracy.
4 Program 4:- Create Binary Art: Recreating Images with 0s and 1s
5 Program 5: write a program to create a dataframe and display its attributes
6 Program 5:- Write Python code to create a Pandas DataFrame using any sequence data type.
a) Display the DataFrame.
b) Display first 5 records.
c) Display last 10 records.
d) Display the number of missing values in the dataset.
7 Program 7: Write a Python program to perform Linear Regression.
8 Program 8:- Download dataset in the form of CSV from any public open-source website.
a) Read CSV File and convert it into Pandas DataFrame.
b) Perform statistical functions on the dataset to check the data, checking missing values, filling missing data etc.
9 Program 8:- Write a python Program to evaluate a Machine Learning model using accuracy and confusion matrix.
10 Program 10:- Write a python Program for Model Evaluation using Linear Regression.
11 Program 11:- Perform step wise procedure of Data Visualization using the Orange Data Mining Tool.
12 Program 12:- Perform Classification with Orange Data Mining.
13 Program 13:- Write down steps to visualize word frequencies with Word Cloud using the Orange Data Mining tool.
14 Program 14:- create a Data Story using all steps of Data Storytelling.
Program 1: Write about yourself(Introduction).
Program 2:- Calculate MSE and RMSE values for the data given below using MS Excel.

1. Enter the Data


In Column A, input the actual values.
In Column B, input the predicted values.
Fill in the data under the respective columns.
2. Calculate Squared Errors
Label Column C as Squared Error.
In Cell C2, enter the formula: =(𝐴2−𝐵2)2
Drag this formula down to fill all rows (C2:C11). This calculates the squared error for each row.
3. Calculate the Mean Squared Error (MSE)
In an empty cell (e.g., D1), label it MSE.
In D2, use the formula: =𝐴𝑉𝐸𝑅𝐴𝐺(𝐶2:𝐶11)
This computes the average of all squared errors.
[Link] the Root Mean Squared Error (RMSE)
In an empty cell (e.g., E1), label it RMSE.
In E2, use the formula: =𝑆𝑄𝑅(𝐷2)
This takes the square root of the MSE to compute the RMSE.
For the given data:
MSE = 58.0
RMSE = 7.62
Program 3: Given a confusion matrix, calculate Precision, Recall, F1 score and Accuracy.
Program 4:- Create Binary Art: Recreating Images with 0s and 1s
Step 1: Choose an Image
● Select any image to work with.
Step 2: Resize the Image
● To simplify the activity, resize the image to smaller dimensions (recommended size: width and height between 200 to
300 pixels).
Step 3: Convert to Grayscale
● Transform the image into grayscale so it contains only shades of gray (1 channel).
Step 4: Extract Pixel Values
● The grayscale image needs to be converted into numerical pixel values (e.g., 0 and 1 for black and white tones).
Step 5: Copy the Pixel Values
● Once the pixel values are extracted, select all the values from the tool and copy them.
Step 6: Paste into a Word Document
● Open a Word document (Google Docs or Microsoft Word).
● Paste the copied pixel values into the document.
Step 7: Adjust the Font Size
● Select all the pasted pixel values in the document.
● Change the font size to 1 for better visualization.
● Observe the image formation as 0s and 1s recreate the original grayscale image.
Program 5: write a program to create a dataframe and display its attributes

Output
Program 6:- Write Python code to create a Pandas DataFrame using any sequence data type.
a) Display the DataFrame.
b) Display first 5 records.
c) Display last 10 records.
d) Display the number of missing values in the dataset.
Ans:-

Output:-
Program 7: Write a Python program to perform Linear Regression.

Output

Coefficient (Slope): 0.6


Intercept: 2.2
Predicted score for 6 hours of study: 5.8
Program 8:- Download dataset in the form of CSV from any public open-source website.
a) Read CSV File and convert it into Pandas DataFrame.
b) Perform statistical functions on the dataset to check the data, checking missing values, filling missing data etc.
Ans:-

Output:-
Program 9:- Python Program to evaluate a Machine Learning model using accuracy and confusion matrix.

Output:-
Program 10:- Write a python Program for Model Evaluation using Linear Regression.

output
Program 11:- Perform step wise procedure of Data Visualization using the Orange Data Mining Tool.
Ans:- Prepare (install & open Orange)
Visit the Orange Website:
 Go to the official Orange website using the link: [Link]
Download the Installer:
 Click on the respective download link to initiate the download process.
Install the Software:
 Once the download is complete, locate the downloaded file and run it.
● For Windows:
Double-click the installer file and follow the on-screen instructions to install Orange on your system.
Launch Orange:
 After installation is complete, launch the Orange tool from your system's applications menu or by double-clicking
its icon.

Step 1 — Create a new workflow


1. In the Orange app, click File → New (or use the templates on the Welcome screen).

Step 2 — Select the Data Widge


1. Load the Iris Dataset, Drag the "File" widget from the widget panel onto the blank canvas

Step 3 — Select the Data Widget


1. Double Click on the "File" widget and select the iris data set.
2. Change the Role of the column “iris” which has the values of flowers as “target”.

Step 4 — - Display the Dataset in a Data Table


1. Drag and drop the "Data Table" widget onto the canvas.
2. Connect the output of the "File" widget to the input of the "Data Table" widget by dragging the connector
from one widget to the other..

Step 5 —Explore the dataset


1. Double-click on the "Data Table" widget to open it.
2. It will show tabular view of the iris dataset, displaying 150 samples of iris flower dimensions, including the
length and width of the sepal and petal.

Step 6 — Visualize the Data with a Scatter Plot


1. Drag and drop the "Scatter Plot" widget onto the canvas.
2. Connect the output of the "File" widget to the input of the "Scatter Plot" widget.

Step 7 — Interpret the Scatter Plot


1. The scatter plot will display the relationship between two selected variables, such as sepal length and
sepal width, with each point representing an individual iris sample.)

Output:-
Program 12:- Perform Classification with Orange Data Mining.
Step 1: Prepare Testing Data in Spreadsheet
 Create columns in a new spreadsheet for sepal length, sepal width, petal length, and petal width, matching the
field names in the training data.
 Enter the measured dimensions of the petals and sepals for each iris sample, ensuring consistency with the units
used in the training data
Step 2: Classification with Orange Data Mining
 Launch the Orange data mining software.
 Drag the "Tree" widget from the widget panel onto the blank canvas.
 Connect the "Tree" widget to the "File" widget containing the training data by dragging a connector from the
output of the "File" widget to the input of the "Tree" widget
Step 3: Perform Classification
 Drag and drop the "Predictions" widget onto the canvas.
 Connect the output of the "File" widget (containing the training data) to the input of the "Predictions" widget.
 Drag another "File" widget onto the canvas and upload the iris testing dataset created in the spreadsheet.
 Connect the output of the second "File" widget (containing the testing data) to the input of the "Predictions"
widget.
Step 4: Interpret Results
 Click on the prediction widget
 The "Predictions" widget displays the predicted class labels for each iris sample in the testing dataset, allowing to
assess the accuracy of the classification model.
Program 13:- Write down steps to visualize word frequencies with Word Cloud using the Orange Data Mining tool.
Ans:- Step 1: Install Text Add-On
 install the Text add-on
 Navigate to the "Options" menu, select "Addons," and choose "Text."
 Restart Orange Data Mining to activate the add-on.

Step 2: Load or Create Textual Data


 Drag and drop the "Corpus" widget to load data (or) use the "Create Corpus" widget to input text.
 Double-click on the "Create Corpus" widget to add textual data.
 input any text

Step 3: Visualize Text with Corpus Viewer


 Add the "Corpus Viewer" widget to the canvas
 connect it with the output of the "Create Corpus" widget
 The Corpus Viewer allows to browse through the text and search for specific words, which it highlights within the
corpus

Step 4: Visualize Word Frequencies with Word Cloud


 Connect the output of the "Corpus" widget to the "Word Cloud" widget
 The Word Cloud visually represents word frequencies in a cloud format, with more frequent words appearing
larger.

Step 5: Preprocess Text


 Preprocess the text to remove noise and irrelevant information(Use the "Preprocess Text" widget)
 Connect this widget to the output of the “Corpus” widget.
 “Preprocess text” widget performs text normalization by converting text to lowercase, tokenizing it into individual
words, removing punctuation, and filtering out stop words.

Step 6: Visualize Cleaned Text with Word Cloud


 Connect the output of the "Preprocess Text" widget to the "Word Cloud" widget to visualize the cleaned text data.
Program 14:- create a Data Story using all steps of Data Storytelling.

Ans:- If the data collected is represented in just a series of graphs and charts, it will not serve the purpose to any
organization. It should be communicated well with proper narrative, with proper context and meaning, relevance and
clarity. The narrative should be able to take the focus of the audience to the correct spot and not miss out on important
facts. To find compelling stories in data sets, the following steps are to be followed:
 Collect the data and organize it.
 Use proper visualization tools to visualize the data.
 Then observe the relationships between the data.
 Finally create a simple narrative which is hidden in the data to be communicated to the audience.

You might also like