zavrazhnova_svetlana_lab_5 is ready
This commit is contained in:
parent
9644582307
commit
716e7b7ee6
8
.idea/IIS_2023_1.iml
Normal file
8
.idea/IIS_2023_1.iml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.8 (venv)" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
4
.idea/misc.xml
Normal file
4
.idea/misc.xml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (venv)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/IIS_2023_1.iml" filepath="$PROJECT_DIR$/.idea/IIS_2023_1.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
179
.idea/workspace.xml
Normal file
179
.idea/workspace.xml
Normal file
@ -0,0 +1,179 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ChangeListManager">
|
||||||
|
<list default="true" id="0ceb130e-88da-4a20-aad6-17f5ab4226ac" name="Changes" comment="" />
|
||||||
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
|
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||||
|
</component>
|
||||||
|
<component name="FileTemplateManagerImpl">
|
||||||
|
<option name="RECENT_TEMPLATES">
|
||||||
|
<list>
|
||||||
|
<option value="Python Script" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="Git.Settings">
|
||||||
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
|
</component>
|
||||||
|
<component name="MarkdownSettingsMigration">
|
||||||
|
<option name="stateVersion" value="1" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectId" id="2VlZqWiOX68aCf0o2y0AtYJWURS" />
|
||||||
|
<component name="ProjectLevelVcsManager" settingsEditedManually="true" />
|
||||||
|
<component name="ProjectViewState">
|
||||||
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
|
<option name="showLibraryContents" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
|
"keyToString": {
|
||||||
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
|
"last_opened_file_path": "D:/ulstukek/Course4/IIS/IISLabs/IIS_2023_1/zavrazhnova_svetlana_lab_5"
|
||||||
|
}
|
||||||
|
}]]></component>
|
||||||
|
<component name="RecentsManager">
|
||||||
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
|
<recent name="D:\ulstukek\Course4\IIS\IISLabs\IIS_2023_1\zavrazhnova_svetlana_lab_5" />
|
||||||
|
<recent name="D:\ulstukek\Course4\IIS\IISLabs\IIS_2023_1\zavrazhnova_svetlana_lab_4" />
|
||||||
|
<recent name="D:\ulstukek\Course4\IIS\IISLabs\IIS_2023_1\zavrazhnova_svetlana_lab_3" />
|
||||||
|
<recent name="D:\ulstukek\Course4\IIS\IISLabs\IIS_2023_1\zavrazhnova_svetlana_lab_1" />
|
||||||
|
</key>
|
||||||
|
</component>
|
||||||
|
<component name="RunManager" selected="Python.zavrazhnova_svetlana_lab_5">
|
||||||
|
<configuration name="zavrazhnova_svetlana_lab3_2" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="IIS_2023_1" />
|
||||||
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
|
<option name="PARENT_ENVS" value="true" />
|
||||||
|
<envs>
|
||||||
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
|
</envs>
|
||||||
|
<option name="SDK_HOME" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_3" />
|
||||||
|
<option name="IS_MODULE_SDK" value="true" />
|
||||||
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_3/zavrazhnova_svetlana_lab3_2.py" />
|
||||||
|
<option name="PARAMETERS" value="" />
|
||||||
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
|
<option name="EMULATE_TERMINAL" value="false" />
|
||||||
|
<option name="MODULE_MODE" value="false" />
|
||||||
|
<option name="REDIRECT_INPUT" value="false" />
|
||||||
|
<option name="INPUT_FILE" value="" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration name="zavrazhnova_svetlana_lab_2" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="IIS_2023_1" />
|
||||||
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
|
<option name="PARENT_ENVS" value="true" />
|
||||||
|
<envs>
|
||||||
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
|
</envs>
|
||||||
|
<option name="SDK_HOME" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_2" />
|
||||||
|
<option name="IS_MODULE_SDK" value="true" />
|
||||||
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_2/zavrazhnova_svetlana_lab_2.py" />
|
||||||
|
<option name="PARAMETERS" value="" />
|
||||||
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
|
<option name="EMULATE_TERMINAL" value="false" />
|
||||||
|
<option name="MODULE_MODE" value="false" />
|
||||||
|
<option name="REDIRECT_INPUT" value="false" />
|
||||||
|
<option name="INPUT_FILE" value="" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration name="zavrazhnova_svetlana_lab_3_1" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="IIS_2023_1" />
|
||||||
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
|
<option name="PARENT_ENVS" value="true" />
|
||||||
|
<envs>
|
||||||
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
|
</envs>
|
||||||
|
<option name="SDK_HOME" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_3" />
|
||||||
|
<option name="IS_MODULE_SDK" value="true" />
|
||||||
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_3/zavrazhnova_svetlana_lab_3_1.py" />
|
||||||
|
<option name="PARAMETERS" value="" />
|
||||||
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
|
<option name="EMULATE_TERMINAL" value="false" />
|
||||||
|
<option name="MODULE_MODE" value="false" />
|
||||||
|
<option name="REDIRECT_INPUT" value="false" />
|
||||||
|
<option name="INPUT_FILE" value="" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration name="zavrazhnova_svetlana_lab_4" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="IIS_2023_1" />
|
||||||
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
|
<option name="PARENT_ENVS" value="true" />
|
||||||
|
<envs>
|
||||||
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
|
</envs>
|
||||||
|
<option name="SDK_HOME" value="C:\Users\svetlnk\venv\Scripts\python.exe" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_4" />
|
||||||
|
<option name="IS_MODULE_SDK" value="false" />
|
||||||
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_4/zavrazhnova_svetlana_lab_4.py" />
|
||||||
|
<option name="PARAMETERS" value="" />
|
||||||
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
|
<option name="EMULATE_TERMINAL" value="false" />
|
||||||
|
<option name="MODULE_MODE" value="false" />
|
||||||
|
<option name="REDIRECT_INPUT" value="false" />
|
||||||
|
<option name="INPUT_FILE" value="" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<configuration name="zavrazhnova_svetlana_lab_5" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||||
|
<module name="IIS_2023_1" />
|
||||||
|
<option name="INTERPRETER_OPTIONS" value="" />
|
||||||
|
<option name="PARENT_ENVS" value="true" />
|
||||||
|
<envs>
|
||||||
|
<env name="PYTHONUNBUFFERED" value="1" />
|
||||||
|
</envs>
|
||||||
|
<option name="SDK_HOME" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_5" />
|
||||||
|
<option name="IS_MODULE_SDK" value="true" />
|
||||||
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_5/zavrazhnova_svetlana_lab_5.py" />
|
||||||
|
<option name="PARAMETERS" value="" />
|
||||||
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
|
<option name="EMULATE_TERMINAL" value="false" />
|
||||||
|
<option name="MODULE_MODE" value="false" />
|
||||||
|
<option name="REDIRECT_INPUT" value="false" />
|
||||||
|
<option name="INPUT_FILE" value="" />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
<recent_temporary>
|
||||||
|
<list>
|
||||||
|
<item itemvalue="Python.zavrazhnova_svetlana_lab_5" />
|
||||||
|
<item itemvalue="Python.zavrazhnova_svetlana_lab_4" />
|
||||||
|
</list>
|
||||||
|
</recent_temporary>
|
||||||
|
</component>
|
||||||
|
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||||
|
<component name="TaskManager">
|
||||||
|
<task active="true" id="Default" summary="Default task">
|
||||||
|
<changelist id="0ceb130e-88da-4a20-aad6-17f5ab4226ac" name="Changes" comment="" />
|
||||||
|
<created>1695412818437</created>
|
||||||
|
<option name="number" value="Default" />
|
||||||
|
<option name="presentableId" value="Default" />
|
||||||
|
<updated>1695412818437</updated>
|
||||||
|
</task>
|
||||||
|
<servers />
|
||||||
|
</component>
|
||||||
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
<option name="TAB_STATES">
|
||||||
|
<map>
|
||||||
|
<entry key="MAIN">
|
||||||
|
<value>
|
||||||
|
<State />
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
16
zavrazhnova_svetlana_lab_5/README.md
Normal file
16
zavrazhnova_svetlana_lab_5/README.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# Задание
|
||||||
|
Предсказать, является ли транзакция мошеннической или нет на основе других данных о транзакции, таких как сумма транзакции, местоположение, банк, возраст и пол клиента
|
||||||
|
### Как запустить лабораторную работу:
|
||||||
|
ЛР запускается в файле zavrazhnova_svetlana_lab_5.py через Run, а затем в консоли должны появится вычисления
|
||||||
|
|
||||||
|
### Технологии
|
||||||
|
Методы PolynomialFeatures и LogisticRegression из библиотеки sklearn
|
||||||
|
|
||||||
|
### Что делает лабораторная:
|
||||||
|
Обучаются модели логистической и полиномиальной регрессии на обучающих данных и используются эти модели для предсказания мошеннических транзакций на тестовых данных. Оценивается точность каждой модели с помощью метрики accuracy.
|
||||||
|
|
||||||
|
### Пример выходных значений:
|
||||||
|
![result.png](result.png)
|
||||||
|
|
||||||
|
### Вывод:
|
||||||
|
Точность полиномиальной регрессии и логистической регрессии равны 1.0, это означает, что обе модели предсказали метки классов на тестовом наборе данных без ошибок. То есть они смогли точно определить, является ли транзакция мошеннической или нет.
|
87
zavrazhnova_svetlana_lab_5/fraud_dataset.csv
Normal file
87
zavrazhnova_svetlana_lab_5/fraud_dataset.csv
Normal file
@ -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
|
|
BIN
zavrazhnova_svetlana_lab_5/result.png
Normal file
BIN
zavrazhnova_svetlana_lab_5/result.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
41
zavrazhnova_svetlana_lab_5/zavrazhnova_svetlana_lab_5.py
Normal file
41
zavrazhnova_svetlana_lab_5/zavrazhnova_svetlana_lab_5.py
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user