new dataset

This commit is contained in:
shaaqu 2020-05-25 00:24:34 +02:00
parent d07d2ce137
commit 239eaf7d97
4 changed files with 70064 additions and 23 deletions

View File

@ -19,7 +19,9 @@
<select /> <select />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="828778c9-9d97-422f-a727-18ddbd059b85" name="Default Changelist" comment="finding barcode"> <list default="true" id="828778c9-9d97-422f-a727-18ddbd059b85" name="Default Changelist" comment="po">
<change afterPath="$PROJECT_DIR$/coder/dataset/test.csv" afterDir="false" />
<change afterPath="$PROJECT_DIR$/coder/dataset/train.csv" 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$/coder/image.py" beforeDir="false" afterPath="$PROJECT_DIR$/coder/image.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/coder/image.py" beforeDir="false" afterPath="$PROJECT_DIR$/coder/image.py" afterDir="false" />
</list> </list>
@ -70,16 +72,17 @@
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> <property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" /> <property name="WebServerToolWindowFactoryState" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$/coder" /> <property name="last_opened_file_path" value="$PROJECT_DIR$/coder/dataset" />
<property name="restartRequiresConfirmation" value="false" /> <property name="restartRequiresConfirmation" value="false" />
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" /> <property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
</component> </component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS"> <key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\Pawel Lukaszewicz\PycharmProjects\AL-2020\coder\dataset" />
<recent name="C:\Users\Pawel Lukaszewicz\PycharmProjects\AL-2020\coder" /> <recent name="C:\Users\Pawel Lukaszewicz\PycharmProjects\AL-2020\coder" />
</key> </key>
</component> </component>
<component name="RunManager" selected="Python.rocognizer"> <component name="RunManager" selected="Python.image">
<configuration default="true" type="PythonConfigurationType" factoryName="Python"> <configuration default="true" type="PythonConfigurationType" factoryName="Python">
<module name="wozek" /> <module name="wozek" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
@ -169,6 +172,9 @@
<module name="wozek" /> <module name="wozek" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" /> <option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/coder" /> <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/coder" />
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
@ -188,6 +194,9 @@
<module name="wozek" /> <module name="wozek" />
<option name="INTERPRETER_OPTIONS" value="" /> <option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" /> <option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" /> <option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/coder" /> <option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/coder" />
<option name="IS_MODULE_SDK" value="true" /> <option name="IS_MODULE_SDK" value="true" />
@ -204,16 +213,16 @@
<method v="2" /> <method v="2" />
</configuration> </configuration>
<list> <list>
<item itemvalue="Python.image" />
<item itemvalue="Python.main" /> <item itemvalue="Python.main" />
<item itemvalue="Python.feature_hashing" /> <item itemvalue="Python.feature_hashing" />
<item itemvalue="Python.train_nn" /> <item itemvalue="Python.train_nn" />
<item itemvalue="Python.load_image" />
<item itemvalue="Python.rocognizer" /> <item itemvalue="Python.rocognizer" />
</list> </list>
<recent_temporary> <recent_temporary>
<list> <list>
<item itemvalue="Python.image" />
<item itemvalue="Python.rocognizer" /> <item itemvalue="Python.rocognizer" />
<item itemvalue="Python.load_image" />
<item itemvalue="Python.train_nn" /> <item itemvalue="Python.train_nn" />
<item itemvalue="Python.main" /> <item itemvalue="Python.main" />
<item itemvalue="Python.feature_hashing" /> <item itemvalue="Python.feature_hashing" />
@ -242,7 +251,12 @@
<workItem from="1589814601057" duration="4208000" /> <workItem from="1589814601057" duration="4208000" />
<workItem from="1589844260514" duration="777000" /> <workItem from="1589844260514" duration="777000" />
<workItem from="1589845066174" duration="177000" /> <workItem from="1589845066174" duration="177000" />
<workItem from="1589888090669" duration="27074000" /> <workItem from="1589888090669" duration="27128000" />
<workItem from="1590140903263" duration="211000" />
<workItem from="1590179245978" duration="6655000" />
<workItem from="1590230578314" duration="1895000" />
<workItem from="1590235510565" duration="925000" />
<workItem from="1590340739871" duration="8052000" />
</task> </task>
<task id="LOCAL-00001" summary="create Shelf"> <task id="LOCAL-00001" summary="create Shelf">
<created>1589815443652</created> <created>1589815443652</created>
@ -307,7 +321,14 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1589967955430</updated> <updated>1589967955430</updated>
</task> </task>
<option name="localTasksCounter" value="10" /> <task id="LOCAL-00010" summary="po">
<created>1589972251988</created>
<option name="number" value="00010" />
<option name="presentableId" value="LOCAL-00010" />
<option name="project" value="LOCAL" />
<updated>1589972251988</updated>
</task>
<option name="localTasksCounter" value="11" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@ -336,7 +357,8 @@
<MESSAGE value="recognizing but training must be improved" /> <MESSAGE value="recognizing but training must be improved" />
<MESSAGE value="zwiekszenie dokladnosci" /> <MESSAGE value="zwiekszenie dokladnosci" />
<MESSAGE value="finding barcode" /> <MESSAGE value="finding barcode" />
<option name="LAST_COMMIT_MESSAGE" value="finding barcode" /> <MESSAGE value="po" />
<option name="LAST_COMMIT_MESSAGE" value="po" />
</component> </component>
<component name="WindowStateProjectService"> <component name="WindowStateProjectService">
<state x="115" y="162" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1589923610328"> <state x="115" y="162" key="#com.intellij.refactoring.safeDelete.UnsafeUsagesDialog" timestamp="1589923610328">
@ -363,10 +385,10 @@
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="277" y="57" key="SettingsEditor/0.0.1536.824@0.0.1536.824" timestamp="1589845139218" /> <state x="277" y="57" key="SettingsEditor/0.0.1536.824@0.0.1536.824" timestamp="1589845139218" />
<state x="361" y="145" key="Vcs.Push.Dialog.v2" timestamp="1589955889829"> <state x="361" y="145" key="Vcs.Push.Dialog.v2" timestamp="1589972275899">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>
<state x="361" y="145" key="Vcs.Push.Dialog.v2/0.0.1536.824@0.0.1536.824" timestamp="1589955889829" /> <state x="361" y="145" key="Vcs.Push.Dialog.v2/0.0.1536.824@0.0.1536.824" timestamp="1589972275899" />
<state x="54" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1589918982407"> <state x="54" y="145" width="672" height="678" key="search.everywhere.popup" timestamp="1589918982407">
<screen x="0" y="0" width="1536" height="824" /> <screen x="0" y="0" width="1536" height="824" />
</state> </state>

28001
coder/dataset/test.csv Normal file

File diff suppressed because one or more lines are too long

42001
coder/dataset/train.csv Normal file

File diff suppressed because one or more lines are too long

View File

@ -4,37 +4,55 @@ import matplotlib.pyplot as plt
from sklearn import datasets from sklearn import datasets
from sklearn.metrics import accuracy_score from sklearn.metrics import accuracy_score
from sklearn.neural_network import MLPClassifier from sklearn.neural_network import MLPClassifier
import pandas as pd
import cv2 import cv2
#28x28
train_data = np.genfromtxt('dataset/train.csv', delimiter=',', skip_header=1 ,max_rows=20000, encoding='utf-8')
test_data = np.genfromtxt('dataset/test.csv', delimiter=',' , skip_header=1, max_rows=20000, encoding='utf-8')
# training # training
# recznie napisane cyfry # recznie napisane cyfry
digits = datasets.load_digits()
digits = datasets.load_digits()
y = digits.target y = digits.target
x = digits.images.reshape((len(digits.images), -1)) x = digits.images.reshape((len(digits.images), -1))
#ogarnac zbior, zwiekszyc warstwy #ogarnac zbior, zwiekszyc warstwy
x_train = x[:1000000] x_train = train_data[0:20000, 1:]
y_train = y[:1000000] y_train = train_data[0:20000, 0]
x_test = x[1000000:] x_test = test_data[0:20000]
y_test = y[1000000:] y_test = test_data[0:20000, 0]
mlp = MLPClassifier(hidden_layer_sizes=(15,), activation='logistic', alpha=1e-4, # x_train = x[:900]
solver='sgd', tol=1e-4, random_state=1, # y_train = y[:900]
learning_rate_init=.1, verbose=True) # x_test = x[900:]
# y_test = y[900:]
print(x_test[0].shape, y_test[9].shape)
mlp = MLPClassifier(hidden_layer_sizes=(100, 100, 100, 100), activation='logistic', alpha=1e-4,
solver='sgd', tol=0.000000000001, random_state=1,
learning_rate_init=.1, verbose=True, max_iter=1000)
mlp.fit(x_train, y_train) mlp.fit(x_train, y_train)
print(123456789)
predictions = mlp.predict(x_test) predictions = mlp.predict(x_test)
print(accuracy_score(y_test, predictions)) print(123456789)
print("Accuracy: ", accuracy_score(y_test, predictions))
# image # image
img = cv2.cvtColor(cv2.imread('test3.png'), cv2.COLOR_BGR2GRAY) img = cv2.cvtColor(cv2.imread('test5.jpg'), cv2.COLOR_BGR2GRAY)
img = cv2.blur(img, (9, 9)) # poprawia jakosc img = cv2.blur(img, (9, 9)) # poprawia jakosc
img = cv2.resize(img, (8, 8), interpolation=cv2.INTER_AREA) img = cv2.resize(img, (28, 28), interpolation=cv2.INTER_AREA)
img = img.reshape((len(img), -1))
print(type(img)) print(type(img))
print(img.shape) print(img.shape)
@ -61,4 +79,3 @@ print(data)
predictions = mlp.predict([data]) predictions = mlp.predict([data])
print("Liczba to:", predictions[0]) print("Liczba to:", predictions[0])