lipatov_ilya_lab_1
This commit is contained in:
parent
1f70bc7eb8
commit
d592186245
@ -1,7 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<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 afterPath="$PROJECT_DIR$/lipatov_ilya_lab_1/README.md" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lipatov_ilya_lab_1/lab1.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lipatov_ilya_lab_1/lineal.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lipatov_ilya_lab_1/perceptron.png" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/lipatov_ilya_lab_1/polynomial.png" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
@ -20,6 +30,10 @@
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo"><![CDATA[{
|
||||
"customColor": "",
|
||||
"associatedIndex": 2
|
||||
}]]></component>
|
||||
<component name="ProjectId" id="2VlZqWiOX68aCf0o2y0AtYJWURS" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
@ -29,7 +43,15 @@
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"last_opened_file_path": "D:/ulstukek/Course4/IIS/labs"
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"git-widget-placeholder": "lipatov__ilya__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",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
@ -38,7 +60,30 @@
|
||||
<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" 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="" />
|
||||
<option name="SDK_NAME" value="Python 3.9" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/lipatov_ilya_lab_1" />
|
||||
<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$/lipatov_ilya_lab_1/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="" />
|
||||
@ -51,6 +96,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" />
|
||||
@ -72,6 +118,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" />
|
||||
@ -93,6 +140,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" />
|
||||
@ -104,6 +152,7 @@
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.lab1" />
|
||||
<item itemvalue="Python.zavrazhnova_svetlana_lab3_2" />
|
||||
<item itemvalue="Python.zavrazhnova_svetlana_lab_3_1" />
|
||||
<item itemvalue="Python.zavrazhnova_svetlana_lab_2" />
|
||||
@ -118,9 +167,14 @@
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1695412818437</updated>
|
||||
<workItem from="1697354497890" duration="101000" />
|
||||
<workItem from="1697354644292" duration="1176000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
@ -132,4 +186,7 @@
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||
<SUITE FILE_PATH="coverage/IIS_2023_1$lab1.coverage" NAME="lab1 Coverage Results" MODIFIED="1697355305448" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/lipatov_ilya_lab_1" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,35 @@
|
||||
## Лабораторная работа №1
|
||||
|
||||
### Работа с типовыми наборами данных и различными моделями
|
||||
|
||||
## Выполнил студент группы ПИбд-41 Липатов Илья
|
||||
|
||||
### Как запустить лабораторную работу:
|
||||
|
||||
* установить python, numpy, matplotlib, sklearn
|
||||
* запустить проект (стартовая точка класс lab1)
|
||||
|
||||
### Какие технологии использовались:
|
||||
|
||||
* Язык программирования `Python`, библиотеки numpy, matplotlib, sklearn
|
||||
* Среда разработки `PyCharm`
|
||||
|
||||
### Что делает лабораторная работа:
|
||||
|
||||
* Генерирует набор данных типа с помощью make_circles(noise=0.2, factor=0.5, random_state=4)
|
||||
* Сравнивает три типа моделей: линейную, полиномиальную (степень 4) и персептрон
|
||||
|
||||
### Примеры работы:
|
||||
|
||||
#### Результаты:
|
||||
* Линейная регрессия, оценка качества: 0.0494206358498015
|
||||
* Полиноминальная регрессия, оценка качества: 0.4480860719638978
|
||||
* Персептрон, оценка качества: 0.52
|
||||
|
||||
#### Самый лучший результат показал персептрон - 0.52
|
||||
|
||||
#### График линейной, полиномиальной, персептрон:
|
||||
|
||||
![Lineal](lineal.png)
|
||||
![Polynomial](polynomial.png)
|
||||
![Perceptron](perceptron.png)
|
@ -0,0 +1,52 @@
|
||||
from sklearn.model_selection import train_test_split
|
||||
from sklearn.preprocessing import PolynomialFeatures
|
||||
from sklearn.linear_model import LinearRegression
|
||||
from sklearn.preprocessing import StandardScaler
|
||||
from sklearn.linear_model import Perceptron
|
||||
from sklearn.datasets import make_circles
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
|
||||
|
||||
def polynomial(x_train, y_train):
|
||||
model = PolynomialFeatures(degree=4).fit(x_train, y_train)
|
||||
x_poly = model.fit_transform(x_train)
|
||||
lin = LinearRegression()
|
||||
lin.fit(x_poly, y_train)
|
||||
plt.scatter(x_train, y_train, color='green')
|
||||
plt.plot(x_train, lin.predict(x_poly), color='red')
|
||||
plt.show()
|
||||
print('Полиноминальная регрессия')
|
||||
print('Оценка качества:', lin.score(x_poly, y_train))
|
||||
|
||||
|
||||
def lineal(x, y, x_train, y_train):
|
||||
model = LinearRegression().fit(x_train, y_train)
|
||||
plt.scatter(x, y, color='green')
|
||||
plt.plot(x, model.predict(x), color='red')
|
||||
plt.show()
|
||||
print('Линейная регрессия')
|
||||
print('Оценка качества:', model.score(x_train, y_train))
|
||||
|
||||
|
||||
def perceptron(x_test, x_train, y_train):
|
||||
sc = StandardScaler()
|
||||
sc.fit(x_train)
|
||||
x_train_std = sc.transform(x_train)
|
||||
x_test_std = sc.transform(x_test)
|
||||
model = Perceptron(eta0=0.1, random_state=1).fit(x_train_std, y_train)
|
||||
plt.scatter(x_train, y_train, color='green')
|
||||
plt.plot(x_test_std, model.predict(x_test_std), color='red')
|
||||
plt.show()
|
||||
print('Персептрон')
|
||||
print('Оценка качества:', model.score(x_train, y_train))
|
||||
|
||||
|
||||
x, y = make_circles(noise=0.2, factor=0.5, random_state=10)
|
||||
x = x[:, np.newaxis, 1]
|
||||
x = StandardScaler().fit_transform(x)
|
||||
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=.5, random_state=42)
|
||||
|
||||
lineal(x_test, y_test, x_train, y_train)
|
||||
polynomial(x_train, y_train)
|
||||
perceptron(x_test, x_train, y_train)
|
Loading…
Reference in New Issue
Block a user