From 716e7b7ee60968bea18734e51e5d7c7ce4c7ed9b Mon Sep 17 00:00:00 2001
From: Svetlnkk <89974865+Svetlnkk@users.noreply.github.com>
Date: Fri, 20 Oct 2023 17:51:44 +0400
Subject: [PATCH] zavrazhnova_svetlana_lab_5 is ready
---
.idea/IIS_2023_1.iml | 8 +
.../inspectionProfiles/profiles_settings.xml | 6 +
.idea/misc.xml | 4 +
.idea/modules.xml | 8 +
.idea/vcs.xml | 6 +
.idea/workspace.xml | 179 ++++++++++++++++++
zavrazhnova_svetlana_lab_5/README.md | 16 ++
zavrazhnova_svetlana_lab_5/fraud_dataset.csv | 87 +++++++++
zavrazhnova_svetlana_lab_5/result.png | Bin 0 -> 3508 bytes
.../zavrazhnova_svetlana_lab_5.py | 41 ++++
10 files changed, 355 insertions(+)
create mode 100644 .idea/IIS_2023_1.iml
create mode 100644 .idea/inspectionProfiles/profiles_settings.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 .idea/workspace.xml
create mode 100644 zavrazhnova_svetlana_lab_5/README.md
create mode 100644 zavrazhnova_svetlana_lab_5/fraud_dataset.csv
create mode 100644 zavrazhnova_svetlana_lab_5/result.png
create mode 100644 zavrazhnova_svetlana_lab_5/zavrazhnova_svetlana_lab_5.py
diff --git a/.idea/IIS_2023_1.iml b/.idea/IIS_2023_1.iml
new file mode 100644
index 0000000..4e6ce24
--- /dev/null
+++ b/.idea/IIS_2023_1.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..3c29c38
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..89e118a
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..54e0d9f
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,179 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1695412818437
+
+
+ 1695412818437
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/zavrazhnova_svetlana_lab_5/README.md b/zavrazhnova_svetlana_lab_5/README.md
new file mode 100644
index 0000000..a1619b5
--- /dev/null
+++ b/zavrazhnova_svetlana_lab_5/README.md
@@ -0,0 +1,16 @@
+# Задание
+Предсказать, является ли транзакция мошеннической или нет на основе других данных о транзакции, таких как сумма транзакции, местоположение, банк, возраст и пол клиента
+### Как запустить лабораторную работу:
+ЛР запускается в файле zavrazhnova_svetlana_lab_5.py через Run, а затем в консоли должны появится вычисления
+
+### Технологии
+Методы PolynomialFeatures и LogisticRegression из библиотеки sklearn
+
+### Что делает лабораторная:
+Обучаются модели логистической и полиномиальной регрессии на обучающих данных и используются эти модели для предсказания мошеннических транзакций на тестовых данных. Оценивается точность каждой модели с помощью метрики accuracy.
+
+### Пример выходных значений:
+![result.png](result.png)
+
+### Вывод:
+Точность полиномиальной регрессии и логистической регрессии равны 1.0, это означает, что обе модели предсказали метки классов на тестовом наборе данных без ошибок. То есть они смогли точно определить, является ли транзакция мошеннической или нет.
\ No newline at end of file
diff --git a/zavrazhnova_svetlana_lab_5/fraud_dataset.csv b/zavrazhnova_svetlana_lab_5/fraud_dataset.csv
new file mode 100644
index 0000000..f23b91d
--- /dev/null
+++ b/zavrazhnova_svetlana_lab_5/fraud_dataset.csv
@@ -0,0 +1,87 @@
+transaction_id,transaction_amount,location,merchant,age,gender,fraud_label
+1,1000.00,New York,ABC Corp,35,M,0
+2,500.00,Chicago,XYZ Inc,45,F,0
+3,2000.00,Los Angeles,ABC Corp,28,M,1
+4,1500.00,San Francisco,XYZ Inc,30,F,0
+5,800.00,Chicago,ABC Corp,50,F,0
+6,3000.00,New York,XYZ Inc,42,M,1
+7,1200.00,San Francisco,ABC Corp,55,F,0
+8,900.00,Los Angeles,XYZ Inc,37,M,0
+9,2500.00,Chicago,ABC Corp,33,F,1
+10,1800.00,New York,XYZ Inc,48,M,0
+11,750.00,San Francisco,ABC Corp,29,F,0
+12,2200.00,Chicago,XYZ Inc,51,M,0
+13,900.00,New York,ABC Corp,40,F,0
+14,1600.00,Los Angeles,XYZ Inc,26,M,0
+15,3000.00,San Francisco,ABC Corp,45,F,1
+16,1200.00,Chicago,XYZ Inc,34,M,0
+17,800.00,New York,ABC Corp,47,F,0
+18,1900.00,Los Angeles,XYZ Inc,32,M,0
+19,1100.00,San Francisco,ABC Corp,52,F,0
+20,4000.00,Chicago,XYZ Inc,38,M,1
+21,900.00,New York,ABC Corp,31,F,0
+22,1700.00,Los Angeles,XYZ Inc,49,M,0
+23,1000.00,San Francisco,ABC Corp,36,F,0
+24,2300.00,Chicago,XYZ Inc,27,M,1
+25,950.00,New York,ABC Corp,41,F,0
+26,1400.00,Los Angeles,XYZ Inc,54,M,0
+27,2800.00,San Francisco,ABC Corp,39,F,1
+28,1100.00,Chicago,XYZ Inc,44,M,0
+29,750.00,New York,ABC Corp,30,F,0
+30,2000.00,Los Angeles,XYZ Inc,46,M,0
+31,1250.00,San Francisco,ABC Corp,35,F,0
+32,2100.00,Chicago,XYZ Inc,43,M,0
+33,950.00,New York,ABC Corp,56,F,0
+34,1800.00,Los Angeles,XYZ Inc,29,M,0
+35,3200.00,San Francisco,ABC Corp,48,F,1
+36,1300.00,Chicago,XYZ Inc,37,M,0
+37,900.00,New York,ABC Corp,51,F,0
+38,2000.00,Los Angeles,XYZ Inc,33,M,0
+39,1050.00,San Francisco,ABC Corp,42,F,0
+40,2400.00,Chicago,XYZ Inc,26,M,0
+41,800.00,New York,ABC Corp,45,F,0
+42,1500.00,Los Angeles,XYZ Inc,31,M,0
+43,2800.00,San Francisco,ABC Corp,50,F,1
+44,1350.00,Chicago,XYZ Inc,28,M,0
+45,920.00,New York,ABC Corp,47,F,0
+46,2000.00,Los Angeles,XYZ Inc,36,M,0
+47,1125.00,San Francisco,ABC Corp,52,F,0
+48,1900.00,Chicago,XYZ Inc,38,M,1
+49,850.00,New York,ABC Corp,32,F,0
+50,1750.00,Los Angeles,XYZ Inc,49,M,0
+51,950.00,San Francisco,ABC Corp,27,F,0
+52,2300.00,Chicago,XYZ Inc,41,M,0
+53,850.00,New York,ABC Corp,54,F,0
+54,1600.00,Los Angeles,XYZ Inc,39,M,0
+55,3000.00,San Francisco,ABC Corp,46,F,1
+56,1250.00,Chicago,XYZ Inc,35,M,0
+57,800.00,New York,ABC Corp,56,F,0
+58,2200.00,Los Angeles,XYZ Inc,29,M,0
+59,1050.00,San Francisco,ABC Corp,48,F,0
+60,4000.00,Chicago,XYZ Inc,37,M,1
+61,950.00,New York,ABC Corp,30,F,0
+62,1700.00,Los Angeles,XYZ Inc,49,M,0
+63,1000.00,San Francisco,ABC Corp,36,F,0
+64,2800.00,Chicago,XYZ Inc,27,M,1
+65,900.00,New York,ABC Corp,41,F,0
+66,1400.00,Los Angeles,XYZ Inc,54,M,0
+67,3200.00,San Francisco,ABC Corp,39,F,1
+68,1100.00,Chicago,XYZ Inc,44,M,0
+69,750.00,New York,ABC Corp,30,F,0
+70,2000.00,Los Angeles,XYZ Inc,46,M,0
+71,1250.00,San Francisco,ABC Corp,35,F,0
+72,2100.00,Chicago,XYZ Inc,43,M,0
+73,950.00,New York,ABC Corp,56,F,0
+74,1800.00,Los Angeles,XYZ Inc,29,M,0
+75,3200.00,San Francisco,ABC Corp,48,F,1
+76,1300.00,Chicago,XYZ Inc,37,M,0
+77,900.00,New York,ABC Corp,51,F,0
+78,2000.00,Los Angeles,XYZ Inc,33,M,0
+79,1050.00,San Francisco,ABC Corp,42,F,0
+80,2400.00,Chicago,XYZ Inc,26,M,0
+81,800.00,New York,ABC Corp,45,F,0
+82,1500.00,Los Angeles,XYZ Inc,31,M,0
+83,2800.00,San Francisco,ABC Corp,50,F,1
+84,1350.00,Chicago,XYZ Inc,28,M,0
+85,920.00,New York,ABC Corp,47,F,0
+86,2000.00,Los Angeles,XYZ Inc,36,M,0
diff --git a/zavrazhnova_svetlana_lab_5/result.png b/zavrazhnova_svetlana_lab_5/result.png
new file mode 100644
index 0000000000000000000000000000000000000000..1081772177bc900bca5bb7c559db9edcb834c8ba
GIT binary patch
literal 3508
zcma)9c{JPG+NNk7MYU*ARjQ?_S$Yf=Ra1&0v?X;Av(!8f5u&ulqSRDVs%BL&6LVv(
zDM-!K5TRz`D5>DmbM9UD-gVddzJK;_uf2ZjdH3_~=Xv+LBlL71vM}*5(a_MaXlkfE
zrlFyYJeh+S&zy{V`}S!k>qt#C<)^-|^^5~3`{?D)gT3^tdRJ)aia?mLT#`V77VQ^l
zFazKWF49n(p*y?%?tZ3D+w%uo7jbH5tQo&7EBU||wPCI4iYeS#bPj>28{;VfKgQup
z3h}^-u^H+)Wwy2?|7;Z9$(Jt^B*19-L=VkIUk11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>3IwXtEHQ-}T{#TZ
zrE+h(cb(i|{fSM9?^(vWB}G@|IEJ?dRd
zrCT^xN1hpqW?RVNHzOwGrub4og1IkFnlRs|d!sRNWCU1?_QccM2@tjJC2j!2|9Z##
eUuNz;rnPBiTo*WQ&^dXH(P*mcs$o>jgZ}|nN&b}p
literal 0
HcmV?d00001
diff --git a/zavrazhnova_svetlana_lab_5/zavrazhnova_svetlana_lab_5.py b/zavrazhnova_svetlana_lab_5/zavrazhnova_svetlana_lab_5.py
new file mode 100644
index 0000000..0f10b11
--- /dev/null
+++ b/zavrazhnova_svetlana_lab_5/zavrazhnova_svetlana_lab_5.py
@@ -0,0 +1,41 @@
+import pandas as pd
+from sklearn.model_selection import train_test_split
+from sklearn.preprocessing import PolynomialFeatures
+from sklearn.linear_model import LogisticRegression
+from sklearn.metrics import accuracy_score
+
+# Чтение данных из файла CSV
+data = pd.read_csv('fraud_dataset.csv')
+
+# Разделение данных на признаки (X) и целевую переменную (y)
+X = data[['transaction_amount', 'location', 'merchant', 'age', 'gender']]
+y = data['fraud_label']
+
+# Преобразование категориальных признаков в числовые с помощью One-Hot Encoding
+X = pd.get_dummies(X, columns=['location', 'merchant', 'age', 'gender'])
+
+# Разделение данных на обучающую и тестовую выборки
+X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
+
+# Применение полиномиальной регрессии
+poly = PolynomialFeatures(degree=2)
+X_train_poly = poly.fit_transform(X_train)
+X_test_poly = poly.transform(X_test)
+
+poly_reg = LogisticRegression(max_iter=1000)
+poly_reg.fit(X_train_poly, y_train)
+
+# Применение логистической регрессии
+log_reg = LogisticRegression(max_iter=1000)
+log_reg.fit(X_train, y_train)
+
+# Предсказание меток классов на тестовом наборе данных
+y_pred_poly = poly_reg.predict(X_test_poly)
+y_pred = log_reg.predict(X_test)
+
+# Вычисление точности предсказания
+accuracy_poly = accuracy_score(y_test, y_pred_poly)
+accuracy = accuracy_score(y_test, y_pred)
+
+print('Точность полиномиальной регрессии:', accuracy_poly)
+print('Точность логистической регрессии:', accuracy)
\ No newline at end of file