Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

Python Question Bank

Q 1 :- One-Way and Two-Way Anova ?


Ans :- A one-way ANOVA only involves one factor or independent
variable, whereas there are two independent variables in a two-way
ANOVA.
One-Way ANOVA : One- Way ANOVA in statistics stands for Analysis
of Variance is a test that is used to difference between the mean values
of more than one group.
Two-Way ANOVA: Two-Way ANOVA in statistics stands for Analysis of
Variance is a test that is used to difference between the mean value of at
least three groups.

Step 1: Enter the data.

First, we’ll create a pandas DataFrame that contains the following three
variables:

 water: how frequently each plant was watered: daily or weekly


 sun: how much sunlight exposure each plant received: low,
medium, or high
 height: the height of each plant (in inches) after two months

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 2 :- Explain Regression in Python ?
Ans :- A regression is a statistical technique that relates a dependent
variable to one or more independent variables.

Linear Regression :- Linear regression is a statistical method that is used to


predict a continuous dependent variable on one or more independent variables.

Types of Linear Regression


 Simple linear regression: Dependent variable based on a single independent
variable.
 Multiple linear regression: Dependent variable based on multiple independent
variables.

Implement Simple Linear Regression in Python


Step 1: Import the required python packages. ...
Step 2: Load the dataset. ...
Step 3: Data analysis. ...
Step 4: Split the dataset into dependent/independent variables. ...
Step 4: Split data into Train/Test sets. ...
Step 5: Train the regression model. ...
Step 6: Predict the result.

Make By :- Youtuber Technical Saurabh


Python Question Bank
Regression Plot :- Regression plots as the name suggests creates
a regression line between 2 parameters and helps to visualize their
linear relationships. Kinds of plots in seaborn that can be change the
size, aspect, ratio etc.

Implement Multiple Linear Regression in Python


 Step 1: Import the required python packages. ...
 Step 2: Load the dataset. ...
 Step 3: Data analysis. ...
 Step 4: Split the dataset into dependent/independent
variables. ...
 Step 5: One-Hot Encoding of categorical data. ...
 Step 6: Split data into Train/Test sets. ...
 Step 7: Train the regression model.

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 3 :- Least Square Method in Python ?
Ans :- The least squares method is a form of regression analysis that
provides the overall rationale for the placement of the line of best fit
among the data points being studied.

Make By :- Youtuber Technical Saurabh


Python Question Bank

Substituting these values in the normal equations,

10a + 62b = 72….(1)

62a + 468b = 503….(2)

(1) × 62 – (2) × 10,

620a + 3844b – (620a + 4680b) = 4464 – 5030

-836b = -566

b = 566/836

b = 283/418

b = 0.677

Make By :- Youtuber Technical Saurabh


Python Question Bank
Substituting b = 0.677 in equation (1),

10a + 62(0.677) = 72

10a + 41.974 = 72

10a = 72 – 41.974

10a = 30.026

a = 30.026/10

a = 3.0026

Therefore, the equation becomes,

y = a + bx

y = 3.0026 + 0.677x

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 4 :- Dummy Variables ?
Ans :- In regression analysis, a dummy variable is a regressor that can
take only two values: either 1 or 0.
Dummy variables are typically used to encode categorical features.

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 5 :- Outliers In Python ?
Ans :- Outliers may indicate a non-linear relationship or the presence of
influential points that violate this assumption leading to skewed
predictions.

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 6 :- Correlation Coefficient ?
Ans :- The correlation coefficient is a statistical concept which helps
in establishing a relation between predicted and actual values obtained in
a statistical experiment. The calculated value of the correlation coefficient
explains the exactness between the predicted and actual values.

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 7 :- Maximum likelihood estimation ?
Ans :- The method of maximum likelihood was first introduced by R. A.
Fisher, a geneticist and statistician, in the 1920s.
Maximum likelihood estimation (MLE) is a method of estimating the
parameters of an assumed probability distribution, given some observed data.

Make By :- Youtuber Technical Saurabh


Python Question Bank

Make By :- Youtuber Technical Saurabh


Python Question Bank

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 8 :- Logistic Regression ?
Ans :- Logistic regression is a process of modeling the probability of a
discrete outcome given an input variable.

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 9 :- Confusion Matrix ?
Ans :- A confusion matrix is a table that is used to define the
performance of a classification algorithm. A confusion matrix visualizes
and summarizes the performance of a classification algorithm.

EXAMPLE :-

Make By :- Youtuber Technical Saurabh


Python Question Bank

Make By :- Youtuber Technical Saurabh


Python Question Bank

7. TPR,FPR,FNR,TNR

True Positive Rate(TPR): True Positive/positive

False Positive Rate(FPR): False Positive /Negative

False Negative Rate(FNR): False Negative/Positive

True Negative Rate(TNR): True Negative/Negative

Make By :- Youtuber Technical Saurabh


Python Question Bank

8. Z Test & F Test


A z-test is used for testing the mean of a population versus a standard, or
comparing the means of two populations.
An F-test is used to compare 2 populations’ variances. The samples can
be any size.

Make By :- Youtuber Technical Saurabh


Python Question Bank

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 10 :- Euclidean Distance ?
Ans :- Euclidean distance is the shortest between the 2 points
irrespective of the dimensions.

import numpy as np
point1 = np.array((1, 2, 3))
point2 = np.array((1, 1, 1))
dist = np.linalg.norm(point1 - point2)
print(dist)

Q 11 :- RMSE in Python ?
Ans :- RSME (Root mean square error) calculates the transformation
between values predicted by a model and actual values.
Using RSME, we can easily measure the efficiency of the model.

Make By :- Youtuber Technical Saurabh


Python Question Bank

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 12 :- Clustering – k means clustering
Ans :- The task of grouping data points based on their similarity with
each other is called Clustering or Cluster Analysis.

Make By :- Youtuber Technical Saurabh


Python Question Bank
K-Means Clustering is an unsupervised learning algorithm that is used to
solve the clustering problems in machine learning or data science.

Step-1: Select the number K to decide the number of clusters.

Step-2: Select random K points or centroids.

Step-3: Assign each data point to their closest centroid.

Step-4: Calculate the variance.

Step-5: Repeat the third steps

Step-6: If any reassignment occurs, then go to step-4 else go to FINISH.

Step-7: The model is ready.

Make By :- Youtuber Technical Saurabh


Python Question Bank

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 13 :- Measures of variability
Ans :- Three Measures of Variability:
• The Range
• The Variance
• The Standard Deviations

1. The Range :- The distance covered by the scores in a


distribution – From smallest value to highest value.

Range = URL for Xmax - LRL for Xmin

Example: For a set of scores: 7, 2, 7, 6, 5, 6, 2


Range = Highest Score minus Lowest score = 7 - 2 = 5

2. The Variance :- Variance equals mean (average) squared


deviation (distance) of the scores from the mean.
Where,

Make By :- Youtuber Technical Saurabh


Python Question Bank
3. Standard Deviation :- Most important measure of variability is
the standard deviation. Calculation differs for population and
samples.

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 14 :- Consider randomly selecting a student at a certain university,
and let A denote the event that the selected individual has a Visa
credit card and B be the analogous event for a MasterCard. Suppose
that ( ) 0.5, ( ) 0.5 and ( ) 0.25. Calculate and
interpret each of the following probabilities

a. ( ⁄ ) b. ( ⁄ ) c. ( ⁄ )

d. Given that the selected individual has at least one card,

what is the probability that he or she has a Visa card?

Ans :- let A denote the event that the selected individual has a Visa credit
card and B be the analogous event for a MasterCard
( ) 0.5, ( ) 0.5 and ( ) 0.25.

( )
a. ( ⁄ ) ( )

( ) ( ) ( )
b. ( ⁄ ) ( ) ( )

( ) ( ) ( )
c. ( ⁄ ) ( ) ( )

( ( )
d. ( ⁄ ) ( )
= ( )
= = 0.67
( ) ( )

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 15 :- A certain shop repairs both audio and video components. Let
A denote the event that the next component brought in for repair is
an audio component, and let B be the event that the next component
is a compact disc player (so the event B is contained in A). Suppose
that ( ) and P( ) .

What is ( ⁄ )?

Ans :- Let A denote the event that the next component brought in for
repair is an audio component
and
Let B be the event that the next component is a compact disc player
P(A) = 0.6 and P(B) = 0.05

and given that


From sets operations
then P( ) = P (B) = 0.05

( )
( ⁄ ) =
( )

Q 16 :- At a certain gas station, 40% of the customers use regular gas ( ),


35% use plus gas ( ), and 25% use premium ( ). Of those customers using
regular gas, only 30% fill their tanks (event B). Of those customers using plus,
60% fill their tanks, whereas of those using premium, 50% fill their tanks.

a. What is the probability that the next customer will regular gas and fill the
tank?

b. What is the probability that the next customer will request plus gas and fill
the tank?

c. What is the probability that the next customer will request premium gas and
fill the tank?

Make By :- Youtuber Technical Saurabh


Python Question Bank
Ans :- Probabilities of customers using regular gas
( )
Probabilities of customers using plus gas
( )
Probabilities of customers using premium gas
( )
Also given with conditional probabilities of full gas tank

( ⁄ )

( ⁄ )

( ⁄ )

(a) The probability that next customer will require regular gas and fill
the tank is ( ) ( ) ( ⁄ )

(b) The probability that next customer will require plus gas and fill the tank

is ( ) ( ) ( ⁄ )

c) The probability that next customer will require premium gas and fill the

tank is ( ) ( ) ( ⁄ )

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 17 :- At a certain gas station, 40% of the customers use regular
gas ( ), 35% use plus gas ( ), and 25% use premium ( ). Of those
customers using regular gas, only 30% fill their tanks (event B). Of
those customers using plus, 60% fill their tanks, whereas of those
using premium, 50% fill their tanks.

What is the probability that the next customer fills the tank?

Ans :- Probabilities of customers using regular gas


( )

Probabilities of customers using plus gas

( )

Probabilities of customers using premium gas

( )
Also given with conditional probabilities of full gas tank

( ⁄ )

( ⁄ )

( ⁄ )

The probability of next customer filling the tank is

( ) ( ) ( ⁄ ) ( ) ( ⁄ ) ( ) ( ⁄ )

( ) ( ) ( )

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 18 :- A person has undertaken a mining job. The probabilities of
completion of the job on time with and without rain are 0.42 and
0.90 respectively. If the probability that it will rain is 0.45, then
determine the probability that the mining job will be completed on
time.

Ans :- P(B) = 0.45,


P(no rain) = P(B′) = 1 − P(B) = 1 − 0.45 = 0.55
By multiplication law of probability,
P(A|B) = 0.42
P(A|B′) = 0.90
P(A) = P(B) P(A|B) + P(B′) P(A|B′)
=0.45 × 0.42 + 0.55 × 0.9
= 0.189 + 0.495 = 0.684

Q 19 :- Tree Diagram Total Probability ?

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 20 :- At a certain gas station, 40% of the customers use
regular gas ( ), 35% use plus gas ( ), and 25% use
premium ( ). Of those customers using regular gas, only
30% fill their tanks (event B). Of those customers using plus,
60% fill their tanks, whereas of those using premium, 50% fill
their tanks.

What is the probability that the next customer fills the tank?
Ans :- Probabilities of customers using regular gas
( )
Probabilities of customers using plus gas
( )
Probabilities of customers using premium gas
( )
Also given with conditional probabilities of full gas tank

( ⁄ )

( ⁄ )

( ⁄ )

The probability of next customer filling the tank is

( ) ( ) ( ⁄ ) ( ) ( ⁄ ) ( ) ( ⁄ )

( ) ( ) ( )

Make By :- Youtuber Technical Saurabh


Python Question Bank
Q 21 :- An office has 4 secretaries handling respectively
20%, 60%,15% and 5% of the files of all government reports.
The probability that they misfile such reports are
respectively 0.05, 0.1, 0.1 and 0.05. Find the probability that
the misfiled report can be blamed on the first secretary.

Q 22 :- Sample spaces, sample sets and events


Ans :- A sample space is a collection or a set of possible outcomes of
a random experiment. The sample space is represented using the
symbol, “S”. The subset of possible outcomes of an experiment is called
events.

Make By :- Youtuber Technical Saurabh


Python Question Bank

Technical Saurabh

आपका एक सब्सक्राइबर मेरे को बहुत ज्यादा मोटिवेि कर सकता


है मैं आपसे आशा करता हूं टक आप एक सब्सक्राइब करके मेरे को
सपोिट कर सकते हैं ………………………

Make By :- Youtuber Technical Saurabh

You might also like