Merge pull request 'istyukov_timofey_lab_1 is ready' (#276) from istyukov_timofey_lab_1 into main
Reviewed-on: http://student.git.athene.tech/Alexey/IIS_2023_1/pulls/276
This commit is contained in:
commit
23e62553d2
@ -4,10 +4,9 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</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" />
|
||||
<list default="true" id="0ceb130e-88da-4a20-aad6-17f5ab4226ac" name="Changes" comment="commit 3">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/istyukov_timofey_lab1/lab1.py" beforeDir="false" afterPath="$PROJECT_DIR$/istyukov_timofey_lab1/lab1.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -43,29 +42,50 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"git-widget-placeholder": "senkin__alexander__lab__1",
|
||||
"last_opened_file_path": "D:/ulstukek/Course4/IIS/labs",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "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 name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"git-widget-placeholder": "senkin__alexander__lab__1",
|
||||
"last_opened_file_path": "D:/ulstukek/Course4/IIS/labs",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.sourceCode",
|
||||
"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">
|
||||
<component name="RunManager" selected="Python.lab1">
|
||||
<configuration name="lab1" 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="E:\Programms\Python\python.exe" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/istyukov_timofey_lab1" />
|
||||
<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$/istyukov_timofey_lab1/lab1.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="" />
|
||||
@ -132,13 +152,19 @@
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<list>
|
||||
<item itemvalue="Python.lab1" />
|
||||
<item itemvalue="Python.zavrazhnova_svetlana_lab3_2" />
|
||||
<item itemvalue="Python.zavrazhnova_svetlana_lab_2" />
|
||||
<item itemvalue="Python.zavrazhnova_svetlana_lab_3_1" />
|
||||
</list>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.lab1" />
|
||||
<item itemvalue="Python.zavrazhnova_svetlana_lab_3_1" />
|
||||
<item itemvalue="Python.zavrazhnova_svetlana_lab_2" />
|
||||
<item itemvalue="Python.zavrazhnova_svetlana_lab3_2" />
|
||||
<item itemvalue="Python.zavrazhnova_svetlana_lab3_2" />
|
||||
<item itemvalue="Python.zavrazhnova_svetlana_lab_3_1" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
@ -153,6 +179,35 @@
|
||||
<workItem from="1697735437405" duration="1706000" />
|
||||
<workItem from="1697740229646" duration="3802000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="commit 1">
|
||||
<created>1702203771661</created>
|
||||
<option name="number" value="00001" />
|
||||
<option name="presentableId" value="LOCAL-00001" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1702203771661</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00002" summary="commit 2">
|
||||
<created>1702208133904</created>
|
||||
<option name="number" value="00002" />
|
||||
<option name="presentableId" value="LOCAL-00002" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1702208133904</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00003" summary="create README">
|
||||
<created>1702208193675</created>
|
||||
<option name="number" value="00003" />
|
||||
<option name="presentableId" value="LOCAL-00003" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1702208193675</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00004" summary="commit 3">
|
||||
<created>1702208529340</created>
|
||||
<option name="number" value="00004" />
|
||||
<option name="presentableId" value="LOCAL-00004" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1702208529340</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="5" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@ -169,7 +224,14 @@
|
||||
<entry key="branch">
|
||||
<value>
|
||||
<list>
|
||||
<option value="HEAD" />
|
||||
<option value="istyukov_timofey_lab_1" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="user">
|
||||
<value>
|
||||
<list>
|
||||
<option value="*" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
@ -180,8 +242,43 @@
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="RECENT_FILTERS">
|
||||
<map>
|
||||
<entry key="Branch">
|
||||
<value>
|
||||
<list>
|
||||
<RecentGroup>
|
||||
<option name="FILTER_VALUES">
|
||||
<option value="istyukov_timofey_lab_1" />
|
||||
</option>
|
||||
</RecentGroup>
|
||||
<RecentGroup>
|
||||
<option name="FILTER_VALUES">
|
||||
<option value="HEAD" />
|
||||
</option>
|
||||
</RecentGroup>
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="User">
|
||||
<value>
|
||||
<list>
|
||||
<RecentGroup>
|
||||
<option name="FILTER_VALUES">
|
||||
<option value="*" />
|
||||
</option>
|
||||
</RecentGroup>
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
</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" />
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="commit 1" />
|
||||
<MESSAGE value="commit 2" />
|
||||
<MESSAGE value="create README" />
|
||||
<MESSAGE value="commit 3" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="commit 3" />
|
||||
</component>
|
||||
</project>
|
BIN
istyukov_timofey_lab1/1_linear_regression.png
Normal file
BIN
istyukov_timofey_lab1/1_linear_regression.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
BIN
istyukov_timofey_lab1/2_perceptron.png
Normal file
BIN
istyukov_timofey_lab1/2_perceptron.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
BIN
istyukov_timofey_lab1/3_poly_ridge.png
Normal file
BIN
istyukov_timofey_lab1/3_poly_ridge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 65 KiB |
61
istyukov_timofey_lab1/README.md
Normal file
61
istyukov_timofey_lab1/README.md
Normal file
@ -0,0 +1,61 @@
|
||||
# Лабораторная работа №1. Работа с типовыми наборами данных и различными моделями
|
||||
## 12 вариант
|
||||
___
|
||||
|
||||
### Задание:
|
||||
Используя код из пункта «Регуляризация и сеть прямого распространения», сгенерируйте определенный тип данных и сравните на нем 3 модели (по варианту). Постройте графики, отобразите качество моделей, объясните полученные результаты.
|
||||
|
||||
### Данные по варианту:
|
||||
- make_classification (n_samples=500, n_features=2, n_redundant=0, n_informative=2, random_state=rs, n_clusters_per_class=1)
|
||||
|
||||
### Модели по варианту:
|
||||
- Линейная регрессия
|
||||
- Персептрон
|
||||
- Гребневая полиномиальная регрессия (со степенью 4, alpha = 1.0)
|
||||
|
||||
___
|
||||
|
||||
### Запуск
|
||||
- Запустить файл lab1.py
|
||||
|
||||
### Используемые технологии
|
||||
- Язык программирования **Python**
|
||||
- Среда разработки **PyCharm**
|
||||
- Библиотеки:
|
||||
* numpy
|
||||
* sklearn
|
||||
* matplotlib
|
||||
|
||||
### Описание программы
|
||||
Программа генерирует набор данных с помощью функции make_classification()
|
||||
с заданными по варианту параметрами. После этого происходит вывод в консоль
|
||||
качества данных моделей по варианту и построение графикиков для этих моделей.
|
||||
|
||||
Оценка точности происходит при помощи встроенного в модели метода метода
|
||||
**.score()**, который вычисляет правильность модели для набора данных.
|
||||
|
||||
___
|
||||
### Пример работы
|
||||
|
||||
![Graphics](1_linear_regression.png)
|
||||
```text
|
||||
===> Линейная регрессия <===
|
||||
Оценка точности: 0.4513003751817972
|
||||
```
|
||||
___
|
||||
|
||||
![Graphics](2_perceptron.png)
|
||||
```text
|
||||
===> Персептрон <===
|
||||
Оценка точности: 0.7591836734693878
|
||||
```
|
||||
___
|
||||
|
||||
![Graphics](3_poly_ridge.png)
|
||||
```text
|
||||
===> Гребневая полиномиальная регрессия <===
|
||||
Оценка точности: 0.5312017992195672
|
||||
```
|
||||
|
||||
### Вывод
|
||||
Согласно выводу в консоль оценок точности, лучший результат показала модель **персептрона**
|
101
istyukov_timofey_lab1/lab1.py
Normal file
101
istyukov_timofey_lab1/lab1.py
Normal file
@ -0,0 +1,101 @@
|
||||
# 12 вариант
|
||||
# Данные: make_classification (n_samples=500, n_features=2, n_redundant=0,
|
||||
# n_informative=2, random_state=rs, n_clusters_per_class=1)
|
||||
# Модели:
|
||||
# -- Линейную регрессию
|
||||
# -- Персептрон
|
||||
# -- Гребневую полиномиальную регрессию (со степенью 4, alpha = 1.0)
|
||||
|
||||
import numpy as np
|
||||
from sklearn.datasets import make_classification
|
||||
from sklearn.linear_model import LinearRegression, Perceptron, Ridge
|
||||
from sklearn.model_selection import train_test_split
|
||||
from sklearn.pipeline import make_pipeline
|
||||
from sklearn.preprocessing import PolynomialFeatures
|
||||
from matplotlib import pyplot as plt
|
||||
from matplotlib.colors import ListedColormap
|
||||
|
||||
|
||||
|
||||
cm_bright_1 = ListedColormap(['#7FFFD4', '#00FFFF'])
|
||||
cm_bright_2 = ListedColormap(['#FF69B4', '#FF1493'])
|
||||
|
||||
def main():
|
||||
X, y = make_classification(
|
||||
n_samples=500,
|
||||
n_features=2,
|
||||
n_redundant=0,
|
||||
n_informative=2,
|
||||
random_state=0,
|
||||
n_clusters_per_class=1)
|
||||
rng = np.random.RandomState(2)
|
||||
X += 2 * rng.uniform(size=X.shape)
|
||||
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=10, random_state=40)
|
||||
|
||||
# модели на основе сгенерированных данных
|
||||
my_linear_regression(X_train, X_test, y_train, y_test)
|
||||
my_perceptron(X_train, X_test, y_train, y_test)
|
||||
my_poly_ridge(X_train, X_test, y_train, y_test)
|
||||
|
||||
|
||||
# Линейная регрессия
|
||||
def my_linear_regression(X_train, X_test, y_train, y_test):
|
||||
lin_reg_model = LinearRegression() # создание модели регрессии
|
||||
lin_reg_model.fit(X_train, y_train) # обучение
|
||||
y_pred = lin_reg_model.predict(X_test) # предсказание по тестовым даннным
|
||||
|
||||
# вывод в консоль
|
||||
print()
|
||||
print('===> Линейная регрессия <===')
|
||||
print('Оценка точности: ', lin_reg_model.score(X_train, y_train))
|
||||
|
||||
# вывод в график
|
||||
plt.title('Линейная регрессия')
|
||||
plt.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright_1)
|
||||
plt.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright_2, alpha=0.8)
|
||||
plt.plot(X_test, y_pred, color='red', linewidth=1)
|
||||
plt.savefig('1_linear_regression.png')
|
||||
plt.show()
|
||||
|
||||
|
||||
# Персептрон
|
||||
def my_perceptron(X_train, X_test, y_train, y_test):
|
||||
perceptron_model = Perceptron()
|
||||
perceptron_model.fit(X_train, y_train)
|
||||
y_pred = perceptron_model.predict(X_test)
|
||||
|
||||
# вывод в консоль
|
||||
print()
|
||||
print('===> Персептрон <===')
|
||||
print('Оценка точности: ', perceptron_model.score(X_train, y_train))
|
||||
|
||||
# вывод в график
|
||||
plt.title('Персептрон')
|
||||
plt.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright_1)
|
||||
plt.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright_2, alpha=0.8)
|
||||
plt.plot(X_test, y_pred, color='red', linewidth=1)
|
||||
plt.savefig('2_perceptron.png')
|
||||
plt.show()
|
||||
|
||||
|
||||
# Гребневая полиномиальная регрессия (степень=4, alpha=1.0)
|
||||
def my_poly_ridge(X_train, X_test, y_train, y_test):
|
||||
poly_rige_model = make_pipeline(PolynomialFeatures(degree=4), Ridge(alpha=1.0))
|
||||
poly_rige_model.fit(X_train, y_train)
|
||||
y_pred = poly_rige_model.predict(X_test)
|
||||
|
||||
# вывод в консоль
|
||||
print()
|
||||
print('===> Гребневая полиномиальная регрессия <===')
|
||||
print('Оценка точности: ', poly_rige_model.score(X_train, y_train))
|
||||
|
||||
# вывод в график
|
||||
plt.title('Гребневая полиномиальная регрессия')
|
||||
plt.scatter(X_train[:, 0], X_train[:, 1], c=y_train, cmap=cm_bright_1)
|
||||
plt.scatter(X_test[:, 0], X_test[:, 1], c=y_test, cmap=cm_bright_2, alpha=0.8)
|
||||
plt.plot(X_test, y_pred, color='red', linewidth=1)
|
||||
plt.savefig('3_poly_ridge.png')
|
||||
plt.show()
|
||||
|
||||
|
||||
main()
|
Loading…
Reference in New Issue
Block a user