Posts

Showing posts from July, 2023

Download any dataset and do the following: a. Count number of categorical and numeric features b. Remove one correlated attribute (if any) c. Display five-number summary of each attribute and show it visually

Download any dataset and do the following: a. Count number of categorical and numeric features b. Remove one correlated attribute (if any) c. Display five-number summary of each attribute and show it visually CODE  import pandas as pd import seaborn as sns import matplotlib.pyplot as plt # Load the Iris dataset into a pandas DataFrame iris_df = pd.read_csv('iris.data', header=None,                       names=['sepal_length', 'sepal_width', 'petal_length', 'petal_width', 'class']) # Count the number of categorical and numeric features categorical_features = iris_df.select_dtypes(include=['object']).columns numeric_features = iris_df.select_dtypes(include=['float64']).columns print(f"Number of categorical features: {len(categorical_features)}") print(f"Number of numeric features: {len(numeric_features)}") # Calculate the correlation matrix correlation_matrix = iris_df[numeric_features].corr() # Find the ...

Using Titanic dataset, do the following: a. Find total number of passengers with age less than 30 b. Find total fare paid by passengers of first class c. Compare number of survivors of each passenger class

  Using Titanic dataset, do the following: a. Find total number of passengers with age less than 30 b. Find total fare paid by passengers of first class c. Compare number of survivors of each passenger class CODE import seaborn as sns # Load the Titanic dataset from seaborn titanic = sns.load_dataset('titanic') # Find the total number of passengers with age less than 30 passengers_age_less_than_30 = titanic[titanic['age'] < 30] total_passengers_age_less_than_30 = len(passengers_age_less_than_30) print(f"Total number of passengers with age less than 30: {total_passengers_age_less_than_30}") # Find the total fare paid by passengers of first class total_fare_first_class = titanic[titanic['class'] == 'First']['fare'].sum() print(f"Total fare paid by passengers of first class: {total_fare_first_class}") # Compare the number of survivors of each passenger class survivors_by_class = titanic.groupby('class')['survived...

Load Titanic data from sklearn library, plot the following with proper legend and axis labels: a. Plot bar chart to show the frequency of survivors and non-survivors for male and female passengers separately b. Draw a scatter plot for any two selected features c. Compare density distribution for features age and passenger fare d. Use a pair plot to show pairwise bivariate distribution

 Load Titanic data from sklearn library, plot the following with proper legend and axis labels: a. Plot bar chart to show the frequency of survivors and non-survivors for male and female passengers separately b. Draw a scatter plot for any two selected features c. Compare density distribution for features age and passenger fare d. Use a pair plot to show pairwise bivariate distribution CODE import seaborn as sns import matplotlib.pyplot as plt # Load the Titanic dataset from seaborn titanic = sns.load_dataset('titanic') # Plot bar chart to show the frequency of survivors and non-survivors for male and female passengers separately plt.figure(figsize=(8, 6)) sns.countplot(x='sex', hue='survived', data=titanic) plt.xlabel('Sex') plt.ylabel('Frequency') plt.title('Survivors vs Non-Survivors by Gender') plt.legend(title='Survived', labels=['No', 'Yes']) plt.show() # Draw a scatter plot for any two selected features plt....

Import iris data using sklearn library . Compute mean, mode, median, standard deviation, confidence interval and standard error for each feature ii. Compute correlation coefficients between each pair of features and plot heatmap iii. Find covariance between length of sepal and petal iv. Build contingency table for class feature

Import iris data using sklearn library or (Download IRIS data from: (https://archive.ics.uci.edu/ml/datasets/iris or import it from sklearn.datasets) i. Compute mean, mode, median, standard deviation, confidence interval and standard error for each feature ii. Compute correlation coefficients between each pair of features and plot heatmap iii. Find covariance between length of sepal and petal iv. Build contingency table for class feature CODE  import numpy as np import pandas as pd from sklearn.datasets import load_iris from scipy import stats import seaborn as sns import matplotlib.pyplot as plt # Load the Iris dataset iris = load_iris() data = iris.data feature_names = iris.feature_names target = iris.target target_names = iris.target_names # Convert data to a pandas DataFrame for easier analysis df = pd.DataFrame(data, columns=feature_names) df['class'] = target_names[target] # Compute mean, mode, median, standard deviation, confidence interval, and standard error for each f...

Load a Pandas dataframe with a selected dataset. Identify and count the missing values in a dataframe. Clean the data after removing noise as follows: a. Drop duplicate rows. b. Detect the outliers and remove the rows having outliers c. Identify the most correlated positively correlated attributes and negatively correlated attributes

  Load a Pandas dataframe with a selected dataset. Identify and count the missing values in a dataframe. Clean the data after removing noise as follows: a. Drop duplicate rows. b. Detect the outliers and remove the rows having outliers c. Identify the most correlated positively correlated attributes and negatively correlated attributes CODE import pandas as pd # Load the dataset df = pd.read_csv('your_dataset.csv') # Identify and count missing values missing_values = df.isnull().sum() print("Missing values:") print(missing_values) # Drop duplicate rows df = df.drop_duplicates() # Detect outliers and remove rows with outliers def remove_outliers(df, column):     Q1 = df[column].quantile(0.25)     Q3 = df[column].quantile(0.75)     IQR = Q3 - Q1     lower_bound = Q1 - 1.5 * IQR     upper_bound = Q3 + 1.5 * IQR     return df[(df[column] >= lower_bound) & (df[column] <= upper_bound)] columns_to_check = ['column1', 'c...

Implement queue data structure and its operations using arrays.

 Implement queue data structure and its operations using arrays. #include <iostream> using namespace std; const int MAX_SIZE = 100; class Queue { private:     int front;          // Index of the front element in the queue     int rear;           // Index of the rear element in the queue     int arr[MAX_SIZE];  // Array to store the queue elements public:     Queue() {         front = -1;     // Initialize front to -1 to indicate an empty queue         rear = -1;      // Initialize rear to -1 to indicate an empty queue     }     bool isEmpty() {         return (front == -1);     }     bool isFull() {         return ((rear + 1) % MAX_SIZE == front);     }     void enqueue(int value) {         ...

Implement stack data structure and its operations using singly linked lists.

Implement stack data structure and its operations using singly linked lists.  #include <iostream> using namespace std; class Node { public:     int data;    // Data stored in the node     Node* next;  // Pointer to the next node     // Constructor     Node(int value) {         data = value;         next = nullptr;     } }; class Stack { private:     Node* top;  // Pointer to the top node of the stack public:     // Constructor     Stack() {         top = nullptr;     }     bool isEmpty() {         return (top == nullptr);     }     void push(int value) {         Node* newNode = new Node(value);         newNode->next = top;         top = newNode;         cout << "Pushed ele...

Implement stack data structure and its operations using arrays.

Implement stack data structure and its operations using arrays.  #include <iostream> using namespace std; const int MAX_SIZE = 100; class Stack { private:     int top;            // Index of the top element in the stack     int arr[MAX_SIZE];  // Array to store the stack elements public:     Stack() {         top = -1;       // Initialize top to -1 to indicate an empty stack     }     bool isEmpty() {         return (top == -1);     }     bool isFull() {         return (top == MAX_SIZE - 1);     }     void push(int value) {         if (isFull()) {             cout << "Stack Overflow: Cannot push element " << value << ". Stack is full." << endl;             return;   ...

Implement singly linked lists.

 Implement singly linked lists. #include <iostream> using namespace std; // Node class represents a single node in the linked list class Node { public:     int data;        // Data stored in the node     Node* next;    // Pointer to the next node     // Constructor     Node(int value) {         data = value;         next = nullptr;     } }; // Linked list class represents the entire linked list class LinkedList { private:     Node* head;    // Pointer to the head node public:     // Constructor     LinkedList() {         head = nullptr;     }     // Destructor to free memory     ~LinkedList() {         Node* current = head;         while (current != nullptr) {             Node* next = current->next...

Implement following recursive functions: a. Factorial of a number b. Nth fibonacci number

Implement following recursive functions: a. Factorial of a number b. Nth fibonacci number  #include <iostream> using namespace std; // Recursive function to calculate the factorial of a number int factorial(int n) {     // Base case: factorial of 0 is 1     if (n == 0) {         return 1;     }     // Recursive case: multiply n with factorial of (n-1)     return n * factorial(n - 1); } // Recursive function to calculate the nth Fibonacci number int fibonacci(int n) {     // Base cases: Fibonacci numbers for n = 0 and n = 1 are 0 and 1 respectively     if (n == 0) {         return 0;     }     if (n == 1) {         return 1;     }     // Recursive case: sum of the previous two Fibonacci numbers     return fibonacci(n - 1) + fibonacci(n - 2); } int main() {     int number;     // F...

Implement Insertion sort.

Implement Insertion sort.  #include <iostream> #include <vector> using namespace std; void insertionSort(vector<int>& arr) {     int n = arr.size();     for (int i = 1; i < n; i++) {         int key = arr[i];         int j = i - 1;         // Move elements greater than the key to one position ahead         while (j >= 0 && arr[j] > key) {             arr[j + 1] = arr[j];             j--;         }         // Place the key in its correct position         arr[j + 1] = key;     } } // Function to display the elements of an array void displayArray(const vector<int>& arr) {     for (int i = 0; i < arr.size(); i++) {         cout << arr[i] << " ";     }  ...

Implement matrix addition and multiplication.

Implement matrix addition and multiplication.:-  #include <iostream> #include <vector> using namespace std; // Function to perform matrix addition vector<vector<int>> matrixAddition(const vector<vector<int>>& matrixA, const vector<vector<int>>& matrixB) {     int rows = matrixA.size();     int columns = matrixA[0].size();     vector<vector<int>> result(rows, vector<int>(columns, 0));     for (int i = 0; i < rows; i++) {         for (int j = 0; j < columns; j++) {             result[i][j] = matrixA[i][j] + matrixB[i][j];         }     }     return result; } // Function to perform matrix multiplication vector<vector<int>> matrixMultiplication(const vector<vector<int>>& matrixA, const vector<vector<int>>& matrixB) {     int r...

what is digital inclusion ? why do we need digital empowerment and what are the challenges in digital empowerment

DIGITAL INCLUSION? Digital inclusion refers to the concept of ensuring that all individuals and communities have access to and can effectively use digital technologies. It aims to bridge the digital divide, which is the gap between those who have access to and can use digital technologies and those who do not. Digital inclusion recognizes that in today's increasingly digital world, access to technology and digital literacy skills are essential for participation in society, education, employment, and accessing important services. Digital inclusion encompasses various aspects, including: Access to infrastructure: This refers to the availability of affordable and reliable internet connectivity, such as broadband access, in both urban and rural areas. It also includes access to devices like computers, smartphones, and tablets. Digital literacy: It involves equipping individuals with the necessary skills to navigate and effectively use digital technologies. This includes basic skills li...

The standard deviation and mean of a data are 6.5 and 12.5 respectively. Find the coefficient of variation.

  The standard deviation and mean of a data are 6.5 and 12.5 respectively. Find the coefficient of variation. The coefficient of variation (CV) is a relative measure of variability that expresses the standard deviation as a percentage of the mean. It is calculated by dividing the standard deviation by the mean and multiplying the result by 100. Given that the standard deviation is 6.5 and the mean is 12.5, we can calculate the coefficient of variation as follows: Coefficient of Variation (CV) = (Standard Deviation / Mean) * 100 = (6.5 / 12.5) * 100 = 0.52 * 100 = 52 Therefore, the coefficient of variation is 52%. OR (below answer is solved by using python) To calculate the coefficient of variation (CV) using Python, you can divide the standard deviation by the mean and multiply the result by 100. Here's an example code snippet: CODE:- standard_deviation = 6.5 mean = 12.5 coefficient_of_variation = (standard_deviation / mean) * 100 print("Coefficient of Variation:", coeffi...

Find the variance and standard deviation of the wages of 9 workers given below: ₹310, ₹290, ₹320, ₹280, ₹300, ₹290, ₹320, ₹310, ₹280.

 Find the variance and standard deviation of the wages of 9 workers given below: ₹310, ₹290, ₹320, ₹280, ₹300, ₹290, ₹320, ₹310, ₹280. To find the variance and standard deviation of the wages of the 9 workers, we can follow these steps: Calculate the mean (average) of the wages: Mean = (310 + 290 + 320 + 280 + 300 + 290 + 320 + 310 + 280) / 9 = 2710 / 9 = 301.11 (rounded to two decimal places) Calculate the deviations from the mean for each worker: Deviations = (310 - 301.11), (290 - 301.11), (320 - 301.11), (280 - 301.11), (300 - 301.11), (290 - 301.11), (320 - 301.11), (310 - 301.11), (280 - 301.11) = 8.89, -11.11, 18.89, -21.11, -1.11, -11.11, 18.89, 8.89, -21.11 Calculate the squared deviations: Squared Deviations = (8.89)^2, (-11.11)^2, (18.89)^2, (-21.11)^2, (-1.11)^2, (-11.11)^2, (18.89)^2, (8.89)^2, (-21.11)^2 = 78.9121, 123.4321, 356.7121, 445.0321, 1.2321, 123.4321, 356.7121, 78.9121, 445.0321 Calculate the variance: Variance = Sum of Squared Deviations / (Number of Worke...

A teacher asked the students to complete 60 pages of a record note book. Eight students have completed only 32, 35, 37, 30, 33, 36, 35 and 37 pages. Find the standard deviation and Variance of the pages yet to be completed by them.

  A teacher asked the students to complete 60 pages of a record note book. Eight students have completed only 32, 35, 37, 30, 33, 36, 35 and 37 pages. Find the standard deviation and Variance of the pages yet to be completed by them. To find the standard deviation and variance of the pages yet to be completed by the eight students, we first need to calculate the mean, then the deviations from the mean, and finally the squared deviations. Let's calculate them step by step: Calculate the mean (average) of the pages completed: Mean = (32 + 35 + 37 + 30 + 33 + 36 + 35 + 37) / 8 = 275 / 8 = 34.375 Calculate the deviations from the mean for each student: Deviations = (32 - 34.375), (35 - 34.375), (37 - 34.375), (30 - 34.375), (33 - 34.375), (36 - 34.375), (35 - 34.375), (37 - 34.375) = -2.375, 0.625, 2.625, -4.375, -1.375, 1.625, 0.625, 2.625 Calculate the squared deviations: Squared Deviations = (-2.375)^2, (0.625)^2, (2.625)^2, (-4.375)^2, (-1.375)^2, (1.625)^2, (0.625)^2, (2.625)^2 = ...

Differentiate between Negative, Positive and Symmetric skewed.

 Differentiate between Negative, Positive and Symmetric skewed. Skewness is a measure of the asymmetry of a distribution. It indicates the extent to which a dataset deviates from a symmetric distribution. Skewness can be categorized into three types: negative skewness, positive skewness, and symmetric skewness. Let's differentiate between them: Negative Skewness: Also known as left-skewed or left-tailed distribution. In a negatively skewed distribution, the tail on the left side of the distribution is longer or fatter than the right side. The mean tends to be less than the median and the mode. The left tail of the distribution is stretched or pulled in the negative direction. Negative skewness typically occurs when there are outliers on the lower end of the distribution that pull the mean downward. Positive Skewness: Also known as right-skewed or right-tailed distribution. In a positively skewed distribution, the tail on the right side of the distribution is longer or fatter than t...

The weights of 8 boys in kilograms: 45, 39, 53, 45, 43, 48, 50, 45. Find the mode.

The weights of 8 boys in kilograms: 45, 39, 53, 45, 43, 48, 50, 45. Find the mode. To find the mode, we need to determine the value that appears most frequently in the given set of weights. The weights of the 8 boys are 45, 39, 53, 45, 43, 48, 50, 45. Counting the frequency of each weight, we have: 45: 3 39: 1 53: 1 43: 1 48: 1 50: 1 From the counts, we can see that the weight 45 appears most frequently, with a count of 3. Therefore, the mode of the given set of weights is 45 kilograms. OR (below answer is solved by using python) You can find the mode of the given set of weights using Python. Here's an example code snippet to find the mode using the statistics module: CODE:- from statistics import mode weights = [45, 39, 53, 45, 43, 48, 50, 45] mode_value = mode(weights) print("The mode is:", mode_value) When you run this code, it will output: The mode is: 45 So, the mode of the given set of weights is 45 kilograms.  

The weights of 8 boys in kilograms: 45, 39, 53, 45, 43, 48, 50, 45. Find the median

  The weights of 8 boys in kilograms: 45, 39, 53, 45, 43, 48, 50, 45. Find the median To find the median, we need to arrange the weights in ascending order. Here are the weights of the 8 boys in kilograms: 39, 43, 45, 45, 45, 48, 50, 53 To find the median, we look for the middle value. Since there are 8 weights, the median is the average of the two middle values. In this case, the two middle values are 45 and 45. Therefore, the median weight is: (45 + 45) / 2 = 90 / 2 = 45 So, the median weight of the 8 boys is 45 kilograms. OR Here's how you can find the median of the given weights using Python: CODE:- weights = [45, 39, 53, 45, 43, 48, 50, 45] sorted_weights = sorted(weights) length = len(sorted_weights) if length % 2 == 0:     median = (sorted_weights[length // 2 - 1] + sorted_weights[length // 2]) / 2 else:     median = sorted_weights[length // 2] print("The median weight is:", median) When you run this code, it will output: The median weight is: 45.0 So, th...

In the light of judicial review discuss the power and functions of the supreme court of India

In the light of judicial review discuss the power and functions of the supreme court of India The Supreme Court of India is the highest judicial authority in the country and plays a vital role in upholding the rule of law and ensuring justice. In this discussion, we will explore the power and functions of the Supreme Court of India, particularly in the context of judicial review: Judicial Review: One of the primary powers of the Supreme Court is judicial review. Judicial review refers to the authority of the court to review the constitutionality of laws, executive actions, and government decisions. The Supreme Court has the power to strike down laws and actions that are found to be inconsistent with the provisions of the Indian Constitution. This power ensures the protection of fundamental rights, the enforcement of constitutional principles, and the maintenance of the constitutional balance of power. Constitutional Interpretation: The Supreme Court has the authority to interpret the p...

discuss the power and position of prime minister in indian political system in 500 words

discuss the power and position of prime minister in indian political system in 500 words The power and position of the Prime Minister in the Indian political system are crucial and hold significant influence over the functioning of the government. In this 500-word discussion, we will explore key aspects of the Prime Minister's power and position in India: Executive Authority: The Prime Minister is the head of the government and exercises executive authority. They have the power to lead and direct the functioning of the government, ensuring its smooth operation. The Prime Minister has the authority to appoint and remove members of the Council of Ministers, who assist in governing the country. They can allocate portfolios and reshuffle the cabinet as per their discretion. Policy Formulation and Decision Making: One of the major responsibilities of the Prime Minister is to formulate policies and make important decisions on various matters. They play a crucial role in setting the agend...