Rewrite linear regression (0/1)

This commit is contained in:
Bartusiak 2020-04-20 19:07:31 +02:00
parent 8d2a814d44
commit f5b038ce64
7 changed files with 13398 additions and 2974 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 (untitled)" jdkType="Python SDK" /> <orderEntry type="jdk" jdkName="Python 3.8" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
</component> </component>
</module> </module>

View File

@ -3,5 +3,5 @@
<component name="JavaScriptSettings"> <component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" /> <option name="languageLevel" value="ES6" />
</component> </component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (untitled)" project-jdk-type="Python SDK" /> <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8" project-jdk-type="Python SDK" />
</project> </project>

View File

@ -46,8 +46,8 @@ def read_words(input_path):
return vocabulary return vocabulary
def train(vocabulary,input_train,expected_train): def train(vocabulary,input_train,expected_train):
learning_rate=0.0001 learning_rate=0.01
learning_precision=0.00000001 learning_precision=0.000001
words_vocabulary={} words_vocabulary={}
with open(input_train,encoding='utf-8') as input_file, open(expected_train,encoding='utf-8') as expected_file: with open(input_train,encoding='utf-8') as input_file, open(expected_train,encoding='utf-8') as expected_file:
for line, exp in zip(input_file,expected_file): for line, exp in zip(input_file,expected_file):
@ -104,7 +104,7 @@ def main():
vocabulary=define_vocabulary('train/in.tsv'); vocabulary=define_vocabulary('train/in.tsv');
weights, words = train(vocabulary,'train/in.tsv','train/expected.tsv') weights, words = train(vocabulary,'train/in.tsv','train/expected.tsv')
prediction('dev-0/in.tsv','dev-0/out.tsv',weights,words) prediction('dev-0/in.tsv','dev-0/out.tsv',weights,words)
prediction('test-A/in.tsv/in.tsv','test-A/out.tsv',weights,words) prediction('test-A/in.tsv','test-A/out.tsv',weights,words)
main() main()

5272
dev-0/in.tsv Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

5152
test-A/in.tsv Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff