Compare commits

...

2 Commits

Author SHA1 Message Date
f5a1911aa6 for kurs work 2023-12-07 17:17:35 +04:00
269cb7af87 for kursach 2023-12-07 11:46:31 +04:00
4 changed files with 88 additions and 12 deletions

View File

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4"> <module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.8 (venv)" jdkType="Python SDK" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

View File

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (venv)" project-jdk-type="Python SDK" /> <component name="Black">
<option name="sdkName" value="Python 3.9" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9" project-jdk-type="Python SDK" />
<component name="PyCharmProfessionalAdvertiser"> <component name="PyCharmProfessionalAdvertiser">
<option name="shown" value="true" /> <option name="shown" value="true" />
</component> </component>

View File

@ -5,7 +5,10 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="0ceb130e-88da-4a20-aad6-17f5ab4226ac" name="Changes" comment=""> <list default="true" id="0ceb130e-88da-4a20-aad6-17f5ab4226ac" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/IIS_2023_1.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/IIS_2023_1.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/senkin_alexander_lab_4/senkin_alexander_lab_4.py" beforeDir="false" afterPath="$PROJECT_DIR$/senkin_alexander_lab_4/senkin_alexander_lab_4.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -22,7 +25,7 @@
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY"> <option name="RECENT_BRANCH_BY_REPOSITORY">
<map> <map>
<entry key="$PROJECT_DIR$" value="main" /> <entry key="$PROJECT_DIR$" value="senkin_alexander_lab_3" />
</map> </map>
</option> </option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@ -34,25 +37,58 @@
&quot;associatedIndex&quot;: 2 &quot;associatedIndex&quot;: 2
}</component> }</component>
<component name="ProjectId" id="2VlZqWiOX68aCf0o2y0AtYJWURS" /> <component name="ProjectId" id="2VlZqWiOX68aCf0o2y0AtYJWURS" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" />
</component>
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent">{ <component name="PropertiesComponent"><![CDATA[{
&quot;keyToString&quot;: { "keyToString": {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;, "RunOnceActivity.OpenProjectViewOnStart": "true",
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;, "RunOnceActivity.ShowReadmeOnStart": "true",
&quot;last_opened_file_path&quot;: &quot;D:/ulstukek/Course4/IIS/labs&quot;, "WebServerToolWindowFactoryState": "false",
&quot;settings.editor.selected.configurable&quot;: &quot;reference.settings.ide.settings.new.ui&quot; "git-widget-placeholder": "senkin__alexander__lab__4",
"last_opened_file_path": "D:/ulstukek/Course4/IIS/labs",
"node.js.detected.package.eslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "reference.settings.ide.settings.new.ui",
"vue.rearranger.settings.migration": "true"
} }
}</component> }]]></component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<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_3" />
<recent name="D:\ulstukek\Course4\IIS\IISLabs\IIS_2023_1\zavrazhnova_svetlana_lab_1" /> <recent name="D:\ulstukek\Course4\IIS\IISLabs\IIS_2023_1\zavrazhnova_svetlana_lab_1" />
</key> </key>
</component> </component>
<component name="RunManager" selected="Python.zavrazhnova_svetlana_lab3_2"> <component name="RunManager">
<configuration name="senkin_alexander_lab_4" type="PythonConfigurationType" factoryName="Python" 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="SDK_NAME" value="Python 3.9 (PyCharmProjects)" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/senkin_alexander_lab_4" />
<option name="IS_MODULE_SDK" value="false" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/senkin_alexander_lab_4/senkin_alexander_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_lab3_2" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true"> <configuration name="zavrazhnova_svetlana_lab3_2" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="IIS_2023_1" /> <module name="IIS_2023_1" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
@ -65,6 +101,7 @@
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_3/zavrazhnova_svetlana_lab3_2.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_3/zavrazhnova_svetlana_lab3_2.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
@ -86,6 +123,7 @@
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_2/zavrazhnova_svetlana_lab_2.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_2/zavrazhnova_svetlana_lab_2.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
@ -107,6 +145,7 @@
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" /> <option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" /> <option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_3/zavrazhnova_svetlana_lab_3_1.py" /> <option name="SCRIPT_NAME" value="$PROJECT_DIR$/zavrazhnova_svetlana_lab_3/zavrazhnova_svetlana_lab_3_1.py" />
<option name="PARAMETERS" value="" /> <option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" /> <option name="SHOW_COMMAND_LINE" value="false" />
@ -134,9 +173,13 @@
<option name="number" value="Default" /> <option name="number" value="Default" />
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1695412818437</updated> <updated>1695412818437</updated>
<workItem from="1701875017793" duration="3313000" />
</task> </task>
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties"> <component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES"> <option name="TAB_STATES">
<map> <map>
@ -148,4 +191,8 @@
</map> </map>
</option> </option>
</component> </component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/PyCharmProjects$senkin_alexander_lab_1.coverage" NAME="senkin_alexander_lab_1 Coverage Results" MODIFIED="1697744262965" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/senkin_alexander_lab_1" />
<SUITE FILE_PATH="coverage/IIS_2023_1$senkin_alexander_lab_4.coverage" NAME="senkin_alexander_lab_4 Coverage Results" MODIFIED="1701889758996" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/senkin_alexander_lab_4" />
</component>
</project> </project>

View File

@ -1,6 +1,9 @@
import pandas as pd import pandas as pd
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from sklearn.cluster import DBSCAN from sklearn.cluster import DBSCAN
from minisom import MiniSom
from sklearn.preprocessing import MinMaxScaler
import numpy as np
# Загрузка данных из csv-файла # Загрузка данных из csv-файла
data = pd.read_csv('us_tornado_dataset_1950_2021.csv') data = pd.read_csv('us_tornado_dataset_1950_2021.csv')
@ -8,7 +11,7 @@ data = pd.read_csv('us_tornado_dataset_1950_2021.csv')
# Выбираем 10000 данных () # Выбираем 10000 данных ()
data_subset = data.head(10000) data_subset = data.head(10000)
# Выделяем признаки (карат и глубина) # Выделяем признаки (фатальные исходы и магнитуда)
features = data_subset[['fat', 'mag']] features = data_subset[['fat', 'mag']]
# Создание модели DBSCAN # Создание модели DBSCAN
@ -25,3 +28,26 @@ plt.xlabel('Фатальные исходы (fat)')
plt.ylabel('Магнитуда (mag)') plt.ylabel('Магнитуда (mag)')
plt.title('Кластеризация данных о фаматльных исходах и магнитуде торнадо') plt.title('Кластеризация данных о фаматльных исходах и магнитуде торнадо')
plt.show() plt.show()
# Нормализуйте признаки
scaler = MinMaxScaler()
features_normalized = scaler.fit_transform(features)
# Задайте параметры SOM
grid_size = (10, 10) # Размер сетки SOM
som = MiniSom(grid_size[0], grid_size[1], features.shape[1], sigma=0.5, learning_rate=0.5)
# Инициализируйте веса SOM случайным образом
som.random_weights_init(features_normalized)
# Обучите SOM
som.train_random(features_normalized, 10000)
# Визуализация карты и кластеров
plt.figure(figsize=(10, 8))
for i, x in enumerate(features_normalized):
winner = som.winner(x)
plt.plot(winner[0]+0.5, winner[1]+0.5, 'o', markerfacecolor='None', markersize=10, markeredgecolor='r', markeredgewidth=2)
plt.title('SOM Clustering')
plt.show()