PR Report37
PR Report37
Problem analysis:
The Bayesian decision theorem is a mathematical framework that can be used to make
decisions under uncertainty. In many real-world scenarios, it is difficult or impossible to have
complete or perfect information about the consequences of different actions. The Bayesian
decision theorem provides a way to take into account the available information, as well as
any prior knowledge, in order to choose the best course of action.
To apply the Bayesian decision theorem, we need to start by defining a set of possible
outcomes or states of nature that could result from our decision. We also need to define a
set of possible actions or strategies that we could choose. For each combination of outcome
and strategy, we need to assign a utility or payoff that represents how desirable or valuable
that outcome would be, given that we have chosen that particular strategy.
Source code:
import pandas as pd
dataset=pd.read_excel("book1.xlsx")
dataset
dataset.head(5)
for index,row in dataset.iterrows():
p_a=row['P(A)']
p_b=row['P(B)']
p_b_given_a=row['P(B|A)']
p_a_given_b=(p_b_given_a*p_a)/p_b
print(f"P(A|B) for row {index + 1}:{p_a_given_b}")
Probability that a sample with brightness=4 and weight=6 came from Class=4: 0.00
Remarks:
The Bayesian Decision Theorem is a statistical decision-making framework that takes into
account prior knowledge and new evidence to make optimal decisions. It involves updating
prior beliefs (in the form of probabilities) with new data using Bayes' theorem, and then using
these updated probabilities to choose the action or decision that maximizes expected utility
or minimizes expected loss. The theorem is widely used in fields such as machine learning,
artificial intelligence, and decision analysis, among others.
MSE is commonly used as a loss function during model training, where the goal is to
minimize the MSE value by adjusting the model's parameters through techniques like
gradient descent. It is a popular metric for evaluating regression models in machine
learning, statistics, and other fields.
Source code:
import numpy as np
import matplotlib.pyplot as plt
Y_True = [2,5,6,5,6,8,10,6,5,5]
Y_Pred = [1.5,4.75,6.23,4.58,6.60,7.20,9.50,7.45,4.80,4.5]
X=[0,1,2,3,4,5,6,7,8,9]
MSE = np.square(np.subtract(Y_True,Y_Pred)).mean()
print(MSE)
plt.plot(X,Y_True)
plt.plot(X,Y_Pred)
Prepare the data: Split the dataset into training and testing sets. The training set is used to
train the model, and the testing set is used to evaluate its performance.
Train the model: Use a regression algorithm, such as linear regression or decision trees, to
fit the training data and create a model that predicts the target variable.
Make predictions: Use the trained model to make predictions on the testing set.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
data = pd.read_excel('dataset.xlsx')
print (data)
Remarks: