Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 27

Name: Nguyễn Thị Phương Thoa

Student’s ID: 31211025778

Table of Contents
Chapter 1: DIAGNOSING THE SEX OF CRABS........................................................1
Abstract.......................................................................................................................1
I. Introduction..............................................................................................................1
1.Data visualization..................................................................................................1
2.ANN......................................................................................................................1
II.Methodology............................................................................................................2
III. Implementation......................................................................................................4
IV.Result.....................................................................................................................5
V. Conclusion..............................................................................................................7
Chapter 2: SUCCESS DEPENDS ON: AGE OR INTEREST.......................................7
Abstract.......................................................................................................................7
I.Introduction...............................................................................................................7
1.Data visualization..................................................................................................7
2.ANN......................................................................................................................7
II.Methodology............................................................................................................8
III. Implementation....................................................................................................10
IV.Result...................................................................................................................11
V. Conclusion............................................................................................................12
Chapter 3: TIMDIAGNOSTIC RISK OF DEATH IN PERSONS WITH HEART HF
......................................................................................................................................12
Abstract.....................................................................................................................12
I.Introduction.............................................................................................................13
1.Data visualization................................................................................................13
2.ANN....................................................................................................................13
II.Methodology..........................................................................................................14
III.Implemetation.......................................................................................................16
IV.Result...................................................................................................................17
V. Conclusion............................................................................................................19

1
Chapter 4: MODEL OF FORECAST DECISIONS FOR LOAN CUSTOMERS.......19
Abstract.....................................................................................................................19
I.Introduction.............................................................................................................20
1.Data visualization................................................................................................20
2.ANN....................................................................................................................20
II.Methodology..........................................................................................................20
III.Implemetation.......................................................................................................23
IV.Result...................................................................................................................24
V. Conclusion............................................................................................................26

Chapter 1: DIAGNOSING THE SEX OF CRABS

Abstract
This report presents the implementation of data visualization and perceptron in a
specific task of determining the sex of crabs. data visualization with histogram, pair
plot, and countplot to see the data distribution and the correlation between the data
dimensions in pairs. Perceptron with multi-layer to make a diagnosis The most
accurate through training and StandardSscale. The use of the above two algorithms,
helps us to know which factors affect/determine the sex of crabs as well as the
accuracy of the sex determination process.

I.Introduction

1. Data visualization
Data visualization is concerned with the design, development, and application of
Computer-generated graphical representation of the data. It provides effective data
representation of data originating from different sources. This enables decision-
makers to see analytics in visual form and makes it easy for them to make sense of the
data. It helps them discover patterns, comprehend information, and form an opinion.
visualization is the use of computer-supported, visual representation of data. Unlike
static data visualization, interactive data visualization allows users to specify the
format used in displaying data.

2. ANN
An artificial neural network (ANN) is a biologically inspired computational model
formed from hundreds of single units, artificial neurons, connected with coefficients

2
(weights) which constitute the neural structure. There are many different types of
ANNs, some of which are more popular than others. When neural networks are used
for data analysis, it is important to distinguish between ANN models (the network’s
arrangement) and ANN algorithms (computations that eventually produce the network
outputs). Some of the earliest AI work aimed to create artificial neural networks.
(Other names for the field include connectionism, parallel distributed processing, and
neural computation.) Figure 18.19 shows a simple mathematical model of the neuron
devised by McCulloch and Pitts (1943). Roughly speaking, it “fires” when a linear
combination of its inputs exceeds some (hard or soft) threshold—that is, it implements

II.Methodology
Single-layer feed-forward neural networks (perceptrons)
A network with all the inputs connected directly to the outputs is called a single-
layer neural network, or a perceptron network. Figure 18.20 shows a simple two-input,
two-output PERCEPTRON NETWORK perceptron network. With such a network,
we might hope to learn the two-bit adder function, for example. Here are all the
training data we will need:

The first thing to notice is that a perceptron network with m outputs is really m
separate networks, because each weight affects only one of the outputs. Thus, there
will be m separate training processes. Furthermore, depending on the type of
activation function used, the training processes will be either the perceptron learning
rule or gradient descent rule for the logistic regression
3
4
sp: species of crab
FL - Frontal lobe width: This is the width of the front part of the carapace (the hard
upper shell of the crab) that covers the eyes. In male crabs, the FL is wider than in
female crabs.
RW - Rear width: This is the width of the rear part of the carapace. In male crabs, the
RW is also wider than in female crabs.
CL - Carapace length: This is the length of the carapace. In some species of crabs, the
CL is larger in males than in females.
CW - Carapace width: This is the width of the carapace at its widest point. Like the
FL and RW, the CW is wider in male crabs than in female crabs.
BD - Abdominal flap shape: This refers to the shape of the flap on the underside of the
crab's body that covers the abdomen. In male crabs, the BD is long and narrow, while
in female crabs, it is broad and rounded.

III. Implementation
import pandas as pd
data=pd.read_csv('/content/drive/MyDrive/AI | week 4/data_crab.csv')
data.head()
replace_dict={'sex':{'F':0,'M':1},'sp':{'B':0,'O':1}}
data.replace(replace_dict,inplace=True)
data = data.drop(['index'], axis=1)
print(data)

5
import seaborn as sns
sns.pairplot(data)
data.hist()
correlation=data.corr()
sns.heatmap(correlation,annot=True)
from sklearn import datasets
from sklearn.linear_model import Perceptron
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.preprocessing import StandardScaler
x= data.loc[:,['FL','RW','CL','CW','BD']]
y= data.loc[:,['sex']]
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.3)
sc=StandardScaler()
sc.fit(x_train)
x_train_std=sc.transform(x_train)
x_test_std=sc.transform(x_test)
model=Perceptron(max_iter=1000,eta0=0.3,random_state=0)
model.fit(x_train,y_train)
y_pred=model.predict(x_test)
print(y_pred)
print('Do chinh xac chua scale:',accuracy_score(y_test,y_pred))
x1=[[8.1,6.7,16.1,19,7],[8.8,7.7,18.1,20.8,7.4],[11.1,9.9,23.8,27.1,9.8],
[12.6,10,27.7,31.7,11.4]]
y1=model.predict(x1)
print(y1)
model=Perceptron(max_iter=100000,eta0=0.6,random_state=0)
model.fit(x_train_std,y_train)
y_pred=model.predict(x_test_std)
print('do chinh xac da scale:', accuracy_score(y_test,y_pred))
x1=[[15,11.9,32.5,37.2,13.6],[15.2,12.1,32.3,36.7,13.6]]
y1=model.predict(x1)
print(y1)

IV.Result
After removing the factors that do not affect the sex determination process: “sp”,
“index”. For the evaluation of data visualization. We can see the correlation between
the factors

6
Fig 1: Heat map showing the correlation between factors in the sex determination
process of crabs
Based on the image above, we can see that the FL: Frontal lobe width factor is the
factor that has the most influence on the sex-determination process of the crab.

Fig 2a Fig 2b
Show the accuracy of the gender determination process training accuracy (Figure 2a)
and test accuracy (Figure 2b).

7
V. Conclusion
In short, the evaluations have shown that the data visualization and perceptron
network learning algorithm with the task of determining the sex of crabs with multiple
inputs through hidden layers to make a final decision about sex with high accuracy.
(usually test accuracy>training accuracy). As a result, it has made the process of
determining the sex of crabs as well as related fields easy, and accurate, saving time as
well as making decisions as objectively as possible, avoiding relying on feelings, and
errors.

Chapter 2: SUCCESS DEPENDS ON: AGE OR INTEREST

Abstract
This report presents the implementation of data visualization and perceptron in a
specific task of classification. Visualize data with histograms, pair charts, and count
charts so you can see the distribution of the data and the correlation between the
paired data sizes. Perceptron with multilayer to standardize Most Accurate Predictions
through training and StandardScaler. With the use of the above two algorithms, it
helps us to know which factors affect/determine the success and accuracy of the
identification process.

I.Introduction

1.Data visualization
Data visualization is concerned with the design, development, and application of
computer-generated graphical representation of the data. It provides effective data
representation of data originating from different sources. This enables decision makers
to see analytics in visual form and makes it easy for them to make sense of the data. It
helps them discover patterns, comprehend information, and form an opinion.
isualization is the use of computer-supported, visual representation of data. Unlike
static data visualization, interactive data visualization allows users to specify the
format used in displaying data.

2.ANN
An artificial neural network (ANN) is a biologically inspired computational model
formed from hundreds of single units, artificial neurons, connected with coefficients
(weights) which constitute the neural structure. There are many different types of
ANNs, some of which are more popular than others. When neural networks are used
for data analysis, it is important to distinguish between ANN models (the network’s
arrangement) and ANN algorithms (computations that eventually produce the network

8
outputs). Some of the earliest AI work aimed to create artificial neural networks.
(Other names for the field include connectionism, parallel distributed processing, and
neural computation.) Figure 18.19 shows a simple mathematical model of the neuron
devised by McCulloch and Pitts (1943). Roughly speaking, it “fires” when a linear
combination of its inputs exceeds some (hard or soft) threshold—that is, it implements

II.Methodology
Single-layer feed-forward neural networks (perceptrons)
A network with all the inputs connected directly to the outputs is called a single-
layer neural network, or a perceptron network. Figure 18.20 shows a simple two-input,
two-output PERCEPTRON NETWORK perceptron network. With such a network,
we might hope to learn the two-bit adder function, for example. Here are all the
training data we will need:

The first thing to notice is that a perceptron network with m outputs is really m
separate networks, because each weight affects only one of the outputs. Thus, there
will be m separate training processes. Furthermore, depending on the type of
activation function used, the training processes will be either the perceptron learning
rule or gradient descent rule for the logistic regression

9
10
Age: the number of years that a person has lived or a thing has existed
Interest: passion,concern about something or someone

III. Implementation
import pandas as pd
data=pd.read_csv('/content/drive/MyDrive/AI | week 4/classification.csv')
data.head()
import seaborn as sns
sns.pairplot(data)
data.hist()
correlation=data.corr()
sns.heatmap(correlation,annot=True)
from sklearn import datasets
from sklearn.linear_model import Perceptron
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.preprocessing import StandardScaler
x=data.loc[:,['age','interest']]
y =data.loc[:,['success']]
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2)
sc=StandardScaler()
sc.fit(x_train)
x_train_std=sc.transform(x_train)

11
x_test_std=sc.transform(x_test)
model=Perceptron(max_iter=100,eta0=0.2,random_state=0)
model.fit(x_train,y_train)
y_pred=model.predict(x_test)
print(y_pred)
print('Do chinh xac chua scale:',accuracy_score(y_test,y_pred))
x1=[[23.6578,18.85992],[22.57373,17.96922]]
y1=model.predict(x1)
print(y1)
model=Perceptron(max_iter=100000,eta0=0.6,random_state=0)
model.fit(x_train_std,y_train)
y_pred=model.predict(x_test_std)
print('do chinh xac da scale:', accuracy_score(y_test,y_pred))
x1=[[22.39584,96.52037],[12.43218,21.97437]]
y1=model.predict(x1)
print(y1)

IV.Result
For the elvaluation of data visualization.We can see the similarity between the two
factors

Fig 3: Heat map showing the correlation between two factors in successful diagnosis
12
Based on the picture above, we can see that the factor of interest is the factor that
affects the diagnosis of success. Because passion is the strongest motivation to help us
overcome all barriers including age to succeed.

Fig 4a Fig 4b
Show the accuracy of the successful diagnosis between training accuracy (Figure 4a)
and test accuracy (Figure 4b).

V. Conclusion
In short, the evaluations have shown that the data visualization and perceptron
network learning algorithm with the task of correctly predicting success with two
inputs through hidden layers to make a final decision on the task (usually test
accuracy). >training accuracy). With an accuracy rating of 0.9 - high, it has helped
people trust and believe in their abilities more.

Chapter 3: TIMDIAGNOSTIC RISK OF DEATH IN PERSONS WITH HEART HF

Abstract
This report presents the implementation of data visualization and perceptron in a
specific task of determining the sex of crabs. data visualization with histogram,
pairplot and countplot to see the data distribution and the correlation between the data
dimensions in pairs. Perceptron with multi-layer perceptron to make a diagnosis The
most accurate through training and StandardSscale. The use of the above two
algorithms, helps us to know the risk of death in people with heart failure depending
on different cases of underlying disease, depending on different levels. Play an
important role in assessing the patient's health status and providing effective

13
treatment. Knowing the mortality rate, healthcare providers can make more accurate
decisions in guiding treatment and preventing disease from getting worse.

I. Introduction

1. Data visualization
Data visualization is concerned with the design, development, and application of
computer generated graphical representation of the data. It provides effective data
representation of data originating from different sources. This enables decision makers
to see analytics in visual form and makes it easy for them to make sense of the data. It
helps them discover patterns, comprehend information, and form an opinion.
isualization is the use of computer-supported, visual representation of data. Unlike
static data visualization, interactive data visualization allows users to specify the
format used in displaying data.

2. ANN
An artificial neural network (ANN) is a biologically inspired computational model
formed from hundreds of single units, artificial neurons, connected with coefficients
(weights) which constitute the neural structure. There are many different types of
ANNs, some of which are more popular than others. When neural networks are used
for data analysis, it is important to distinguish between ANN models (the network’s
arrangement) and ANN algorithms (computations that eventually produce the network
outputs). Some of the earliest AI work aimed to create artificial neural networks.
(Other names for the field include connectionism, parallel distributed processing, and
neural computation.) Figure 18.19 shows a simple mathematical model of the neuron
devised by McCulloch and Pitts (1943). Roughly speaking, it “fires” when a linear
combination of its inputs exceeds some (hard or soft) threshold—that is, it implements

14
II.Methodology
Single-layer feed-forward neural networks (perceptrons)
A network with all the inputs connected directly to the outputs is called a single-
layer neural network, or a perceptron network. Figure 18.20 shows a simple two-input,
two-output PERCEPTRON NETWORK perceptron network. With such a network,
we might hope to learn the two-bit adder function, for example. Here are all the
training data we will need:

The first thing to notice is that a perceptron network with m outputs is really m
separate networks, because each weight affects only one of the outputs. Thus, there
will be m separate training processes. Furthermore, depending on the type of
activation function used, the training processes will be either the perceptron learning
rule or gradient descent rule for the logistic regression

15
- age: Advanced age
- anaemia: lack of blood
- CR(creatinine_phosphokinase):a basic indicator to assess muscle damage
- diabetes:
- ER(ejection_fraction):This is the percentage of blood pumped out of the heart
- HB(high_blood_pressure)
- platelets
16
- SR(serum_creatinine):This indicator reflects the patient's kidney function
- sex
- smoking
- time: follow - up time

III.Implemetation
import pandas as pd
data=pd.read_csv('/content/drive/MyDrive/AI | week
4/heart_failure_clinical_records_dataset.csv')
data.head()
import seaborn as sns
sns.pairplot(data)
print(data)
data.hist()
correlation=data.corr()
sns.heatmap(correlation,annot=True)
from sklearn import datasets
from sklearn.linear_model import Perceptron
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.preprocessing import StandardScaler
x= data.iloc[:, 0:12]
y= data.loc[:,['DEATH_EVENT']]
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.3)
sc=StandardScaler()
sc.fit(x_train)
x_train_std=sc.transform(x_train)
x_test_std=sc.transform(x_test)
model=Perceptron(max_iter=1000,eta0=0.35,random_state=0)
model.fit(x_train,y_train)
y_pred=model.predict(x_test)
print(y_pred)
print('Do chinh xac chua scale:',accuracy_score(y_test,y_pred))
x1=[[75,0,582,0,20,1,265000,1.9,130,1,0,4],[55,0,7861,0,38,0,263358,1.1,136,1,0,6]]
y1=model.predict(x1)
print(y1)
model=Perceptron(max_iter=100000,eta0=0.6,random_state=0)
model.fit(x_train_std,y_train)
y_pred=model.predict(x_test_std)
print('do chinh xac da scale:', accuracy_score(y_test,y_pred))

17
x1=[[50,1,159,1,30,0,302000,1.2,138,0,0,29],[57,1,129,0,30,0,395000,1,140,0,0,42]]
y1=model.predict(x1)
print(y1)

IV.Result
For the evaluation of data visualization. We have seen similarities between elements

Fig 5: Heat map showing correlation between risk factors for mortality in people with
heart failure

18
Fig 6a Fig 6b
Demonstrate the accuracy of the process of diagnosing the risk of death in people with
heart failure training accuracy (Figure 6a) and test accuracy (Figure 6b).

V. Conclusion
In summary, the evaluations have shown that the data visualization and perceptron
network learning algorithms for diagnosing the risk of death for people with heart
failure with many information inputs through hidden layers to give make the final
decision on the limit. calculated with high accuracy (normal test accuracy > training
accuracy). That helps both the patient and the doctor. For patients, this prediction
helps them understand their health condition better and take preventive measures to
minimize the risk of death. If patients know the severity of the disease, they can
prepare mentally and financially for long-term treatments. Moreover, this prediction
also helps patients understand the impact of various factors on their health, so they can
make necessary changes in their diet, lifestyle, and exercise regimen.

For doctors, predicting the mortality rate in heart failure patients helps them make
treatment decisions and monitor the patient's condition effectively. This prediction can
help doctors increase the accuracy of prescribing medication and treatment methods,
thereby improving the quality of life of patients and reducing the risk of death.
Additionally, this prediction helps doctors make forecasts about high-risk patients, so
they can monitor and implement early preventive measures to reduce the mortality
rate.

Chapter 4: MODEL OF FORECAST DECISIONS FOR LOAN CUSTOMERS

Abstract
This report presents the implementation of data visualization and perceptron in a
specific task of forecast decisions for loan customers data visualization with
histogram, pairplot and countplot so that the distribution of the data can also be seen.

19
correlation between data dimensions in pairs.Perceptron with multi-layer perceptron to
give the most accurate diagnosis through training and StandardSscale. The use of the
above two algorithms, it helps us to know which factors affect/determine the loan
diagnosis as well as the accuracy of the diagnostic process. Besides, reducing risks for
credit institutions ,Improve credit for customers,Enhance the competitiveness of credit
institutions

I. Introduction

1. Data visualization
Data visualization is concerned with the design, development, and application of
computer generated graphical representation of the data. It provides effective data
representation of data originating from different sources. This enables decision makers
to see analytics in visual form and makes it easy for them to make sense of the data. It
helps them discover patterns, comprehend information, and form an opinion.
isualization is the use of computer-supported, visual representation of data. Unlike
static data visualization, interactive data visualization allows users to specify the
format used in displaying data.

2.ANN
An artificial neural network (ANN) is a biologically inspired computational model
formed from hundreds of single units, artificial neurons, connected with coefficients
(weights) which constitute the neural structure. There are many different types of
ANNs, some of which are more popular than others. When neural networks are used
for data analysis, it is important to distinguish between ANN models (the network’s
arrangement) and ANN algorithms (computations that eventually produce the network
outputs). Some of the earliest AI work aimed to create artificial neural networks.
(Other names for the field include connectionism, parallel distributed processing, and
neural computation.) Figure 18.19 shows a simple mathematical model of the neuron
devised by McCulloch and Pitts (1943). Roughly speaking, it “fires” when a linear
combination of its inputs exceeds some (hard or soft) threshold—that is, it implements

20
II.Methodology
Single-layer feed-forward neural networks (perceptrons)
A network with all the inputs connected directly to the outputs is called a single-
layer neural network, or a perceptron network. Figure 18.20 shows a simple two-input,
two-output PERCEPTRON NETWORK perceptron network. With such a network,
we might hope to learn the two-bit adder function, for example. Here are all the
training data we will need:

The first thing to notice is that a perceptron network with m outputs is really m
separate networks, because each weight affects only one of the outputs. Thus, there
will be m separate training processes. Furthermore, depending on the type of
activation function used, the training processes will be either the perceptron learning
rule or gradient descent rule for the logistic regression

21
22
- CreditScore: The number of points that customers get
- Age: The age of the customer
- Tenure: The amount of property that the customer has (property)
- Balance: The balance in the account
- Num of Products
- HasCrCard: Do you have CreditCard?
- IsActiveMember: is an active member or not
- EstimatedSalary: Estimated current salary
-

III.Implemetation

import pandas as pd

data=pd.read_csv('/content/drive/MyDrive/AI | week 4/Churn_Modelling.csv')

data.head()

data = data.drop(['Gender','RowNumber','CustomerId','Surname','Geography'], axis=1)

print(data)

import seaborn as sns

23
sns.pairplot(data)

data.hist()

correlation=data.corr()

sns.heatmap(correlation,annot=True)

from sklearn import datasets

from sklearn.linear_model import Perceptron

from sklearn.model_selection import train_test_split

from sklearn.metrics import accuracy_score

from sklearn.preprocessing import StandardScaler

x= data.iloc[:,0:8]

y= data.loc[:,['Exited']]

x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.3)

sc=StandardScaler()

sc.fit(x_train)

x_train_std=sc.transform(x_train)

x_test_std=sc.transform(x_test)

model=Perceptron(max_iter=10000,eta0=0.1,random_state=0)

model.fit(x_train,y_train)

y_pred=model.predict(x_test)

print(y_pred)

print('Do chinh xac chua scale:',accuracy_score(y_test,y_pred))

x1=[[619,1,42,2,0,1,1,101348.9],[608,1,41,1,83807.86,0,1,112542.6]]

y1=model.predict(x1)

print(y1)

24
model=Perceptron(max_iter=1000000,eta0=0.5,random_state=0)

model.fit(x_train_std,y_train)

y_pred=model.predict(x_test_std)

print('do chinh xac da scale:', accuracy_score(y_test,y_pred))

x1=[[574,1,43,3,141349.4,1,1,100187.4],[582,0,41,6,70349.48,2,1,178074]]

y1=model.predict(x1)

print(y1)

IV.Result
After removing the factors that do not affect forecast decisions for loan customers. For
the evaluation of data visualization. We can see the correlation between the factors

25
Fig 7: Heat map showing correlation between factors in forecast decisions for loan
customers

Fig 8a Fig 8b
Accurately represent forecasting decisions to borrowers' training accuracy (Figure 8a)
and test accuracy (Figure 8b).

V. Conclusion
In short, the evaluations have shown that the data visualization and perceptron
network learning algorithm with the task of determining the sex of crabs with multiple
inputs through hidden layers to make a final decision about sex with high accuracy.
(usually test accuracy>training accuracy). But in this case ( test accuracy < training
accuracy ). Thanks to that, helping to make a more accurate loan decision based on the
relevant factors of the customer helps credit institutions make the correct loan
decision. more, based on the customer's ability to pay. This helps to reduce risks for
credit institutions and increases the chances of customers getting loans. Improve
customer experience: Predicting loan rates also improve customer experience by
offering a better customer experience. Make loan decisions faster and more
accurately. This helps increase customer satisfaction and lays the foundation for a
better relationship between the customer and the credit institution.

26
27

You might also like