0% found this document useful (0 votes)
10 views5 pages

PR Report37

Uploaded by

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

PR Report37

Uploaded by

Nazmuj Sakib
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Problem statement: Bayesian Decision Theorem

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}")

Sample input output:

Enter the class value (Salmon: S or Seabass B): 4

Enter the value of brightness: 4

Enter the value of weight: 6

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.

Problem statement: Mean Squared Error (MSE)


Problem analysis:
The Mean Squared Error (MSE) is a metric used to evaluate the accuracy of a model's
predictions. It measures the average squared difference between the predicted values and
the actual values in a dataset.
A higher MSE indicates that the model's predictions are further away from the actual values
and therefore less accurate. Conversely, a lower MSE indicates that the model's predictions
are closer to the actual values and therefore more accurate.

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)

Sample input output:


Remarks:
The algorithm for calculating the Mean Squared Error (MSE) can be summarized in the
following steps:

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.

Problem statement: Adaptive decision boundary


Problem analysis:
An adaptive decision boundary is a concept in machine learning and statistical modeling,
where the decision boundary separating different classes is not fixed but changes depending
on the data. The goal of an adaptive decision boundary is to have a more accurate boundary
that can capture the complex relationships between the input features and the output
variable.
The main problem with fixed decision boundaries is that they might not be able to capture
the true nature of the data, especially when the data is non-linear or when there are
overlapping classes. In such cases, an adaptive decision boundary can help improve the
accuracy of the model.
Source code:

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)

# Extract the features and target variable


X = data[['height', 'weight']].values
y = data['target'].values

# Split the dataset into training and testing sets


X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
X_train

# Train a logistic regression model


model = LogisticRegression()
model.fit(X_train, y_train)

# Evaluate the model on the testing set


accuracy = model.score(X_test, y_test)
print("accuracy:", accuracy)

# Plot the decision boundary


x_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1
y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1
xx, yy = np.meshgrid(np.arange(x_min, x_max, 0.1), np.arange(y_min, y_max, 0.1))
Z = model.predict(np.c_[xx.ravel(), yy.ravel()])
Z = Z.reshape(xx.shape)

plt.contourf(xx, yy, Z, alpha=0.8)


plt.scatter(X[:, 0], X[:, 1], c=y, edgecolors='g')
plt.xlabel('height')
plt.ylabel('weight')
plt.title('Adaptive Decision Boundary')
plt.show()

Sample input output:

Remarks:

An adaptive decision boundary is a concept in machine learning and statistical modeling,


where the decision boundary separating different classes is not fixed but changes depending
on the data. The goal of an adaptive decision boundary is to have a more accurate boundary
that can capture the complex relationships between the input features and the output
variable.

You might also like