for kursach

This commit is contained in:
Mamoru777 2023-12-07 11:46:31 +04:00
parent 8a51aacfb2
commit 269cb7af87
4 changed files with 87 additions and 11 deletions

View File

@ -2,7 +2,7 @@
<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="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,6 +1,9 @@
<?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" />
<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">
<option name="shown" value="true" />
</component>

View File

@ -5,7 +5,10 @@
</component>
<component name="ChangeListManager">
<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$/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>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -22,7 +25,7 @@
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>
<entry key="$PROJECT_DIR$" value="main" />
<entry key="$PROJECT_DIR$" value="senkin_alexander_lab_3" />
</map>
</option>
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
@ -34,25 +37,58 @@
&quot;associatedIndex&quot;: 2
}</component>
<component name="ProjectId" id="2VlZqWiOX68aCf0o2y0AtYJWURS" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="1" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;D:/ulstukek/Course4/IIS/labs&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;reference.settings.ide.settings.new.ui&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"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">
<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_1" />
</key>
</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">
<module name="IIS_2023_1" />
<option name="INTERPRETER_OPTIONS" value="" />
@ -65,6 +101,7 @@
<option name="IS_MODULE_SDK" value="true" />
<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$/zavrazhnova_svetlana_lab_3/zavrazhnova_svetlana_lab3_2.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
@ -86,6 +123,7 @@
<option name="IS_MODULE_SDK" value="true" />
<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$/zavrazhnova_svetlana_lab_2/zavrazhnova_svetlana_lab_2.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
@ -107,6 +145,7 @@
<option name="IS_MODULE_SDK" value="true" />
<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$/zavrazhnova_svetlana_lab_3/zavrazhnova_svetlana_lab_3_1.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
@ -134,9 +173,13 @@
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1695412818437</updated>
<workItem from="1701875017793" duration="3313000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
@ -148,4 +191,8 @@
</map>
</option>
</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>

View File

@ -1,6 +1,9 @@
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.cluster import DBSCAN
from minisom import MiniSom
from sklearn.preprocessing import MinMaxScaler
import numpy as np
# Загрузка данных из csv-файла
data = pd.read_csv('us_tornado_dataset_1950_2021.csv')
@ -24,4 +27,27 @@ plt.scatter(data_subset['fat'], data_subset['mag'], c=data_subset['cluster'], cm
plt.xlabel('Фатальные исходы (fat)')
plt.ylabel('Магнитуда (mag)')
plt.title('Кластеризация данных о фаматльных исходах и магнитуде торнадо')
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()