From 7c332687e2cc10a25f71f9228ba81477afef48ee Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 23 Oct 2020 08:59:22 +0900 Subject: [PATCH 1/7] Add a github action to test installation --- .github/workflows/pip.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/pip.yml diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml new file mode 100644 index 0000000..1437d7c --- /dev/null +++ b/.github/workflows/pip.yml @@ -0,0 +1,26 @@ +name: test package installation + +on: + schedule: + - cron: "0 0 * * *" + +jobs: + build: + if: contains(github.event.head_commit.message, '[skip ci]') == false + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: [3.6, 3.7, 3.8, 3.9] + os: [ubuntu-latest, macos-latest] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + pip install --upgrade pip + pip install -U setuptools + - run: pip install seqeval From 1433e1611915ca677eb8b47c510d2a8c61470984 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Sat, 24 Oct 2020 08:32:34 +0900 Subject: [PATCH 2/7] Update setup.py to relax version pinning, fix #65 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index bd4771d..632de98 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ os.system('python setup.py sdist bdist_wheel upload') sys.exit() -required = ['numpy==1.19.2', 'scikit-learn==0.23.2'] +required = ['numpy>=1.14.0', 'scikit-learn>=0.21.3'] setup( name=NAME, From 0447db4f9e947a6ec326e7b8a28a02fffec4040a Mon Sep 17 00:00:00 2001 From: Hironsan Date: Tue, 27 Oct 2020 08:14:56 +0900 Subject: [PATCH 3/7] Update pip.yml to remove Python 3.9 Installation failed due to the problem of Fortran compiler --- .github/workflows/pip.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 1437d7c..aabbd30 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -10,7 +10,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.6, 3.7, 3.8] os: [ubuntu-latest, macos-latest] steps: From 6f29dc86165c924c265b8dfc492d28b03f15d08d Mon Sep 17 00:00:00 2001 From: Hironsan Date: Fri, 30 Oct 2020 07:31:13 +0900 Subject: [PATCH 4/7] Update classifier of setup.py --- setup.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 632de98..bd36f8f 100644 --- a/setup.py +++ b/setup.py @@ -45,13 +45,9 @@ classifiers=[ 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', - 'Programming Language :: Python :: 2.6', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy' ], From 2921931184a98aff0dbbda5ff943214fe50a7847 Mon Sep 17 00:00:00 2001 From: Hiroki Nakayama Date: Tue, 10 Nov 2020 21:55:00 +0900 Subject: [PATCH 5/7] Create FUNDING.yml --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..e131be7 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: Hironsan From 9fe82db7a3ab311ce47d4c0b172103bc586c99de Mon Sep 17 00:00:00 2001 From: morfeo359bone Date: Sat, 31 Jul 2021 00:56:31 -0500 Subject: [PATCH 6/7] Add partial report multitag --- Pipfile | 1 + Pipfile.lock | 352 +++++++++++++++------------ seqeval/metrics/sequence_labeling.py | 72 ++++-- tests/test_metrics.py | 6 + 4 files changed, 266 insertions(+), 165 deletions(-) diff --git a/Pipfile b/Pipfile index cef4773..55304e7 100644 --- a/Pipfile +++ b/Pipfile @@ -9,6 +9,7 @@ autopep8 = "*" flake8 = "*" pytest-cov = "*" isort = "*" +atomicwrites="*" [packages] numpy = "*" diff --git a/Pipfile.lock b/Pipfile.lock index b2a9257..6388d1a 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "ed3e34c865fd90593db1c52563d09c3f8328d8821cec176a467fcf2b3a7da7fa" + "sha256": "a280964ae68eb1ccaddb61251683783dfeb47181b575fadf3b813ad4e6bbafd2" }, "pipfile-spec": 6, "requires": { @@ -18,175 +18,232 @@ "default": { "joblib": { "hashes": [ - "sha256:698c311779f347cf6b7e6b8a39bb682277b8ee4aba8cf9507bc0cf4cd4737b72", - "sha256:9e284edd6be6b71883a63c9b7f124738a3c16195513ad940eae7e3438de885d5" + "sha256:9c17567692206d2f3fb9ecf5e991084254fe631665c450b443761c4186a613f7", + "sha256:feeb1ec69c4d45129954f1b7034954241eedfd6ba39b5e9e4b6883be3332d5e5" ], "markers": "python_version >= '3.6'", - "version": "==0.17.0" + "version": "==1.0.1" }, "numpy": { "hashes": [ - "sha256:04c7d4ebc5ff93d9822075ddb1751ff392a4375e5885299445fcebf877f179d5", - "sha256:0bfd85053d1e9f60234f28f63d4a5147ada7f432943c113a11afcf3e65d9d4c8", - "sha256:0c66da1d202c52051625e55a249da35b31f65a81cb56e4c69af0dfb8fb0125bf", - "sha256:0d310730e1e793527065ad7dde736197b705d0e4c9999775f212b03c44a8484c", - "sha256:1669ec8e42f169ff715a904c9b2105b6640f3f2a4c4c2cb4920ae8b2785dac65", - "sha256:2117536e968abb7357d34d754e3733b0d7113d4c9f1d921f21a3d96dec5ff716", - "sha256:3733640466733441295b0d6d3dcbf8e1ffa7e897d4d82903169529fd3386919a", - "sha256:4339741994c775396e1a274dba3609c69ab0f16056c1077f18979bec2a2c2e6e", - "sha256:51ee93e1fac3fe08ef54ff1c7f329db64d8a9c5557e6c8e908be9497ac76374b", - "sha256:54045b198aebf41bf6bf4088012777c1d11703bf74461d70cd350c0af2182e45", - "sha256:58d66a6b3b55178a1f8a5fe98df26ace76260a70de694d99577ddeab7eaa9a9d", - "sha256:59f3d687faea7a4f7f93bd9665e5b102f32f3fa28514f15b126f099b7997203d", - "sha256:62139af94728d22350a571b7c82795b9d59be77fc162414ada6c8b6a10ef5d02", - "sha256:7118f0a9f2f617f921ec7d278d981244ba83c85eea197be7c5a4f84af80a9c3c", - "sha256:7c6646314291d8f5ea900a7ea9c4261f834b5b62159ba2abe3836f4fa6705526", - "sha256:967c92435f0b3ba37a4257c48b8715b76741410467e2bdb1097e8391fccfae15", - "sha256:9a3001248b9231ed73894c773142658bab914645261275f675d86c290c37f66d", - "sha256:aba1d5daf1144b956bc87ffb87966791f5e9f3e1f6fab3d7f581db1f5b598f7a", - "sha256:addaa551b298052c16885fc70408d3848d4e2e7352de4e7a1e13e691abc734c1", - "sha256:b594f76771bc7fc8a044c5ba303427ee67c17a09b36e1fa32bde82f5c419d17a", - "sha256:c35a01777f81e7333bcf276b605f39c872e28295441c265cd0c860f4b40148c1", - "sha256:cebd4f4e64cfe87f2039e4725781f6326a61f095bc77b3716502bed812b385a9", - "sha256:d526fa58ae4aead839161535d59ea9565863bb0b0bdb3cc63214613fb16aced4", - "sha256:d7ac33585e1f09e7345aa902c281bd777fdb792432d27fca857f39b70e5dd31c", - "sha256:e6ddbdc5113628f15de7e4911c02aed74a4ccff531842c583e5032f6e5a179bd", - "sha256:eb25c381d168daf351147713f49c626030dcff7a393d5caa62515d415a6071d8" + "sha256:01721eefe70544d548425a07c80be8377096a54118070b8a62476866d5208e33", + "sha256:0318c465786c1f63ac05d7c4dbcecd4d2d7e13f0959b01b534ea1e92202235c5", + "sha256:05a0f648eb28bae4bcb204e6fd14603de2908de982e761a2fc78efe0f19e96e1", + "sha256:1412aa0aec3e00bc23fbb8664d76552b4efde98fb71f60737c83efbac24112f1", + "sha256:25b40b98ebdd272bc3020935427a4530b7d60dfbe1ab9381a39147834e985eac", + "sha256:2d4d1de6e6fb3d28781c73fbde702ac97f03d79e4ffd6598b880b2d95d62ead4", + "sha256:38e8648f9449a549a7dfe8d8755a5979b45b3538520d1e735637ef28e8c2dc50", + "sha256:4a3d5fb89bfe21be2ef47c0614b9c9c707b7362386c9a3ff1feae63e0267ccb6", + "sha256:635e6bd31c9fb3d475c8f44a089569070d10a9ef18ed13738b03049280281267", + "sha256:73101b2a1fef16602696d133db402a7e7586654682244344b8329cdcbbb82172", + "sha256:791492091744b0fe390a6ce85cc1bf5149968ac7d5f0477288f78c89b385d9af", + "sha256:7a708a79c9a9d26904d1cca8d383bf869edf6f8e7650d85dbc77b041e8c5a0f8", + "sha256:88c0b89ad1cc24a5efbb99ff9ab5db0f9a86e9cc50240177a571fbe9c2860ac2", + "sha256:8a326af80e86d0e9ce92bcc1e65c8ff88297de4fa14ee936cb2293d414c9ec63", + "sha256:8a92c5aea763d14ba9d6475803fc7904bda7decc2a0a68153f587ad82941fec1", + "sha256:91c6f5fc58df1e0a3cc0c3a717bb3308ff850abdaa6d2d802573ee2b11f674a8", + "sha256:95b995d0c413f5d0428b3f880e8fe1660ff9396dcd1f9eedbc311f37b5652e16", + "sha256:9749a40a5b22333467f02fe11edc98f022133ee1bfa8ab99bda5e5437b831214", + "sha256:978010b68e17150db8765355d1ccdd450f9fc916824e8c4e35ee620590e234cd", + "sha256:9a513bd9c1551894ee3d31369f9b07460ef223694098cf27d399513415855b68", + "sha256:a75b4498b1e93d8b700282dc8e655b8bd559c0904b3910b144646dbbbc03e062", + "sha256:c6a2324085dd52f96498419ba95b5777e40b6bcbc20088fddb9e8cbb58885e8e", + "sha256:d7a4aeac3b94af92a9373d6e77b37691b86411f9745190d2c351f410ab3a791f", + "sha256:d9e7912a56108aba9b31df688a4c4f5cb0d9d3787386b87d504762b6754fbb1b", + "sha256:dff4af63638afcc57a3dfb9e4b26d434a7a602d225b42d746ea7fe2edf1342fd", + "sha256:e46ceaff65609b5399163de5893d8f2a82d3c77d5e56d976c8b5fb01faa6b671", + "sha256:f01f28075a92eede918b965e86e8f0ba7b7797a95aa8d35e1cc8821f5fc3ad6a", + "sha256:fd7d7409fa643a91d0a05c7554dd68aa9c9bb16e186f6ccfe40d6e003156e33a" ], "index": "pypi", - "version": "==1.19.2" + "version": "==1.21.1" }, "scikit-learn": { "hashes": [ - "sha256:0a127cc70990d4c15b1019680bfedc7fec6c23d14d3719fdf9b64b22d37cdeca", - "sha256:0d39748e7c9669ba648acf40fb3ce96b8a07b240db6888563a7cb76e05e0d9cc", - "sha256:1b8a391de95f6285a2f9adffb7db0892718950954b7149a70c783dc848f104ea", - "sha256:20766f515e6cd6f954554387dfae705d93c7b544ec0e6c6a5d8e006f6f7ef480", - "sha256:2aa95c2f17d2f80534156215c87bee72b6aa314a7f8b8fe92a2d71f47280570d", - "sha256:5ce7a8021c9defc2b75620571b350acc4a7d9763c25b7593621ef50f3bd019a2", - "sha256:6c28a1d00aae7c3c9568f61aafeaad813f0f01c729bee4fd9479e2132b215c1d", - "sha256:7671bbeddd7f4f9a6968f3b5442dac5f22bf1ba06709ef888cc9132ad354a9ab", - "sha256:914ac2b45a058d3f1338d7736200f7f3b094857758895f8667be8a81ff443b5b", - "sha256:98508723f44c61896a4e15894b2016762a55555fbf09365a0bb1870ecbd442de", - "sha256:a64817b050efd50f9abcfd311870073e500ae11b299683a519fbb52d85e08d25", - "sha256:cb3e76380312e1f86abd20340ab1d5b3cc46a26f6593d3c33c9ea3e4c7134028", - "sha256:d0dcaa54263307075cb93d0bee3ceb02821093b1b3d25f66021987d305d01dce", - "sha256:d9a1ce5f099f29c7c33181cc4386660e0ba891b21a60dc036bf369e3a3ee3aec", - "sha256:da8e7c302003dd765d92a5616678e591f347460ac7b53e53d667be7dfe6d1b10", - "sha256:daf276c465c38ef736a79bd79fc80a249f746bcbcae50c40945428f7ece074f8" + "sha256:038f4e9d6ef10e1f3fe82addc3a14735c299866eb10f2c77c090410904828312", + "sha256:06ffdcaaf81e2a3b1b50c3ac6842cfb13df2d8b737d61f64643ed61da7389cde", + "sha256:0e71ce9c7cbc20f6f8b860107ce15114da26e8675238b4b82b7e7cd37ca0c087", + "sha256:1eec963fe9ffc827442c2e9333227c4d49749a44e592f305398c1db5c1563393", + "sha256:2754c85b2287333f9719db7f23fb7e357f436deed512db3417a02bf6f2830aa5", + "sha256:2db429090b98045d71218a9ba913cc9b3fe78e0ba0b6b647d8748bc6d5a44080", + "sha256:39b7e3b71bcb1fe46397185d6c1a5db1c441e71c23c91a31e7ad8cc3f7305f9a", + "sha256:3cbd734e1aefc7c5080e6b6973fe062f97c26a1cdf1a991037ca196ce1c8f427", + "sha256:40556bea1ef26ef54bc678d00cf138a63069144a0b5f3a436eecd8f3468b903e", + "sha256:48f273836e19901ba2beecd919f7b352f09310ce67c762f6e53bc6b81cacf1f0", + "sha256:49ec0b1361da328da9bb7f1a162836028e72556356adeb53342f8fae6b450d47", + "sha256:4e6198675a6f9d333774671bd536668680eea78e2e81c0b19e57224f58d17f37", + "sha256:5beaeb091071625e83f5905192d8aecde65ba2f26f8b6719845bbf586f7a04a1", + "sha256:5ff3e4e4cf7592d36541edec434e09fb8ab9ba6b47608c4ffe30c9038d301897", + "sha256:62214d2954377fcf3f31ec867dd4e436df80121e7a32947a0b3244f58f45e455", + "sha256:7be1b88c23cfac46e06404582215a917017cd2edaa2e4d40abe6aaff5458f24b", + "sha256:8fac72b9688176922f9f54fda1ba5f7ffd28cbeb9aad282760186e8ceba9139a", + "sha256:90a297330f608adeb4d2e9786c6fda395d3150739deb3d42a86d9a4c2d15bc1d", + "sha256:a2a47449093dcf70babc930beba2ca0423cb7df2fa5fd76be5260703d67fa574", + "sha256:ae19ac105cf7ce8c205a46166992fdec88081d6e783ab6e38ecfbe45729f3c39", + "sha256:ae426e3a52842c6b6d77d00f906b6031c8c2cfdfabd6af7511bb4bc9a68d720e", + "sha256:cbdb0b3db99dd1d5f69d31b4234367d55475add31df4d84a3bd690ef017b55e2", + "sha256:cdf24c1b9bbeb4936456b42ac5bd32c60bb194a344951acb6bfb0cddee5439a4", + "sha256:d14701a12417930392cd3898e9646cf5670c190b933625ebe7511b1f7d7b8736", + "sha256:d177fe1ff47cc235942d628d41ee5b1c6930d8f009f1a451c39b5411e8d0d4cf", + "sha256:d5bf9c863ba4717b3917b5227463ee06860fc43931dc9026747de416c0a10fee", + "sha256:dd968a174aa82f3341a615a033fa6a8169e9320cbb46130686562db132d7f1f0", + "sha256:f0ed4483c258fb23150e31b91ea7d25ff8495dba108aea0b0d4206a777705350", + "sha256:f18c3ed484eeeaa43a0d45dc2efb4d00fc6542ccdcfa2c45d7b635096a2ae534", + "sha256:f1d2108e770907540b5248977e4cff9ffaf0f73d0d13445ee938df06ca7579c6", + "sha256:f3ec00f023d84526381ad0c0f2cff982852d035c921bbf8ceb994f4886c00c64", + "sha256:f74429a07fedb36a03c159332b914e6de757176064f9fed94b5f79ebac07d913", + "sha256:fec42690a2eb646b384eafb021c425fab48991587edb412d4db77acc358b27ce" ], "index": "pypi", - "version": "==0.23.2" + "version": "==0.24.2" }, "scipy": { "hashes": [ - "sha256:066c513d90eb3fd7567a9e150828d39111ebd88d3e924cdfc9f8ce19ab6f90c9", - "sha256:07e52b316b40a4f001667d1ad4eb5f2318738de34597bd91537851365b6c61f1", - "sha256:0a0e9a4e58a4734c2eba917f834b25b7e3b6dc333901ce7784fd31aefbd37b2f", - "sha256:1c7564a4810c1cd77fcdee7fa726d7d39d4e2695ad252d7c86c3ea9d85b7fb8f", - "sha256:315aa2165aca31375f4e26c230188db192ed901761390be908c9b21d8b07df62", - "sha256:6e86c873fe1335d88b7a4bfa09d021f27a9e753758fd75f3f92d714aa4093768", - "sha256:8e28e74b97fc8d6aa0454989db3b5d36fc27e69cef39a7ee5eaf8174ca1123cb", - "sha256:92eb04041d371fea828858e4fff182453c25ae3eaa8782d9b6c32b25857d23bc", - "sha256:a0afbb967fd2c98efad5f4c24439a640d39463282040a88e8e928db647d8ac3d", - "sha256:a785409c0fa51764766840185a34f96a0a93527a0ff0230484d33a8ed085c8f8", - "sha256:cca9fce15109a36a0a9f9cfc64f870f1c140cb235ddf27fe0328e6afb44dfed0", - "sha256:d56b10d8ed72ec1be76bf10508446df60954f08a41c2d40778bc29a3a9ad9bce", - "sha256:dac09281a0eacd59974e24525a3bc90fa39b4e95177e638a31b14db60d3fa806", - "sha256:ec5fe57e46828d034775b00cd625c4a7b5c7d2e354c3b258d820c6c72212a6ec", - "sha256:eecf40fa87eeda53e8e11d265ff2254729d04000cd40bae648e76ff268885d66", - "sha256:fc98f3eac993b9bfdd392e675dfe19850cc8c7246a8fd2b42443e506344be7d9" + "sha256:0572256c10ddd058e3d315c555538671ddb2737f27eb56189bfbc3483391403f", + "sha256:2e685fdbfa5b989af4338b29c408b9157ea6addec15d661104c437980c292be5", + "sha256:3595c8b64970c9e5a3f137fa1a9eb64da417e78fb7991d0b098b18a00b776d88", + "sha256:3e7df79b42c3015058a5554bfeab6fd4c9906c46560c9ddebb5c652840f3e182", + "sha256:4ef3d4df8af40cb6f4d4eaf7b02780109ebabeec334cda26a7899ec9d8de9176", + "sha256:53116abd5060a5b4a58489cf689bee259b779e6b7ecd4ce366e7147aa7c9626e", + "sha256:5a983d3cebc27294897951a494cebd78af2eae37facf75d9e4ad4f1f62229860", + "sha256:5eb8f054eebb351af7490bbb57465ba9662c4e16e1786655c6c7ed530eb9a74e", + "sha256:6130e22bf6ee506f7cddde7e0515296d97eb6c6c94f7ef5103c2b77aec5833a7", + "sha256:7f4b89c223bd09460b52b669e2e642cab73c28855b540e6ed029692546a86f8d", + "sha256:80df8af7039bce92fb4cd1ceb056258631b11b3c627384e2d29bb48d44c0cae7", + "sha256:821e75f5c16cd7b0ab0ffe7eb9917e5af7b48c25306b4777287de8d792a5f7f3", + "sha256:97ca4552ace1c313707058e774609af59644321e278c3a539322fab2fb09b943", + "sha256:998c5e6ea649489302de2c0bc026ed34284f531df89d2bdc8df3a0d44d165739", + "sha256:aef6e922aea6f2e6bbb539b413c85210a9ee32757535b84204ebd22723e69704", + "sha256:b77ee5e3a9507622e7f98b16122242a3903397f98d1fe3bc269d904a9025e2bc", + "sha256:bd4399d4388ca0239a4825e312b3e61b60f743dd6daf49e5870837716502a92a", + "sha256:c5d012cb82cc1dcfa72609abaabb4a4ed8113e3e8ac43464508a418c146be57d", + "sha256:e7b733d4d98e604109715e11f2ab9340eb45d53f803634ed730039070fc3bc11" ], - "markers": "python_version >= '3.6'", - "version": "==1.5.2" + "markers": "python_version < '3.10' and python_version >= '3.7'", + "version": "==1.7.0" }, "threadpoolctl": { "hashes": [ - "sha256:38b74ca20ff3bb42caca8b00055111d74159ee95c4370882bbff2b93d24da725", - "sha256:ddc57c96a38beb63db45d6c159b5ab07b6bced12c45a1f07b2b92f272aebfa6b" + "sha256:86d4b6801456d780e94681d155779058759eaef3c3564758b17b6c99db5f81cb", + "sha256:e5a995e3ffae202758fa8a90082e35783b9370699627ae2733cd1c3a73553616" ], - "markers": "python_version >= '3.5'", - "version": "==2.1.0" + "markers": "python_version >= '3.6'", + "version": "==2.2.0" } }, "develop": { + "atomicwrites": { + "hashes": [ + "sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197", + "sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a" + ], + "index": "pypi", + "version": "==1.4.0" + }, "attrs": { "hashes": [ - "sha256:26b54ddbbb9ee1d34d5d3668dd37d6cf74990ab23c828c2888dccdceee395594", - "sha256:fce7fc47dfc976152e82d53ff92fa0407700c21acd20886a13777a0d20e655dc" + "sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1", + "sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==20.2.0" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", + "version": "==21.2.0" }, "autopep8": { "hashes": [ - "sha256:d21d3901cb0da6ebd1e83fc9b0dfbde8b46afc2ede4fe32fbda0c7c6118ca094" + "sha256:276ced7e9e3cb22e5d7c14748384a5cf5d9002257c0ed50c0e075b68011bb6d0", + "sha256:aa213493c30dcdac99537249ee65b24af0b2c29f2e83cd8b3f68760441ed0db9" ], "index": "pypi", - "version": "==1.5.4" + "version": "==1.5.7" + }, + "colorama": { + "hashes": [ + "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b", + "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2" + ], + "markers": "sys_platform == 'win32'", + "version": "==0.4.4" }, "coverage": { "hashes": [ - "sha256:0203acd33d2298e19b57451ebb0bed0ab0c602e5cf5a818591b4918b1f97d516", - "sha256:0f313707cdecd5cd3e217fc68c78a960b616604b559e9ea60cc16795c4304259", - "sha256:1c6703094c81fa55b816f5ae542c6ffc625fec769f22b053adb42ad712d086c9", - "sha256:1d44bb3a652fed01f1f2c10d5477956116e9b391320c94d36c6bf13b088a1097", - "sha256:280baa8ec489c4f542f8940f9c4c2181f0306a8ee1a54eceba071a449fb870a0", - "sha256:29a6272fec10623fcbe158fdf9abc7a5fa032048ac1d8631f14b50fbfc10d17f", - "sha256:2b31f46bf7b31e6aa690d4c7a3d51bb262438c6dcb0d528adde446531d0d3bb7", - "sha256:2d43af2be93ffbad25dd959899b5b809618a496926146ce98ee0b23683f8c51c", - "sha256:381ead10b9b9af5f64646cd27107fb27b614ee7040bb1226f9c07ba96625cbb5", - "sha256:47a11bdbd8ada9b7ee628596f9d97fbd3851bd9999d398e9436bd67376dbece7", - "sha256:4d6a42744139a7fa5b46a264874a781e8694bb32f1d76d8137b68138686f1729", - "sha256:50691e744714856f03a86df3e2bff847c2acede4c191f9a1da38f088df342978", - "sha256:530cc8aaf11cc2ac7430f3614b04645662ef20c348dce4167c22d99bec3480e9", - "sha256:582ddfbe712025448206a5bc45855d16c2e491c2dd102ee9a2841418ac1c629f", - "sha256:63808c30b41f3bbf65e29f7280bf793c79f54fb807057de7e5238ffc7cc4d7b9", - "sha256:71b69bd716698fa62cd97137d6f2fdf49f534decb23a2c6fc80813e8b7be6822", - "sha256:7858847f2d84bf6e64c7f66498e851c54de8ea06a6f96a32a1d192d846734418", - "sha256:78e93cc3571fd928a39c0b26767c986188a4118edc67bc0695bc7a284da22e82", - "sha256:7f43286f13d91a34fadf61ae252a51a130223c52bfefb50310d5b2deb062cf0f", - "sha256:86e9f8cd4b0cdd57b4ae71a9c186717daa4c5a99f3238a8723f416256e0b064d", - "sha256:8f264ba2701b8c9f815b272ad568d555ef98dfe1576802ab3149c3629a9f2221", - "sha256:9342dd70a1e151684727c9c91ea003b2fb33523bf19385d4554f7897ca0141d4", - "sha256:9361de40701666b034c59ad9e317bae95c973b9ff92513dd0eced11c6adf2e21", - "sha256:9669179786254a2e7e57f0ecf224e978471491d660aaca833f845b72a2df3709", - "sha256:aac1ba0a253e17889550ddb1b60a2063f7474155465577caa2a3b131224cfd54", - "sha256:aef72eae10b5e3116bac6957de1df4d75909fc76d1499a53fb6387434b6bcd8d", - "sha256:bd3166bb3b111e76a4f8e2980fa1addf2920a4ca9b2b8ca36a3bc3dedc618270", - "sha256:c1b78fb9700fc961f53386ad2fd86d87091e06ede5d118b8a50dea285a071c24", - "sha256:c3888a051226e676e383de03bf49eb633cd39fc829516e5334e69b8d81aae751", - "sha256:c5f17ad25d2c1286436761b462e22b5020d83316f8e8fcb5deb2b3151f8f1d3a", - "sha256:c851b35fc078389bc16b915a0a7c1d5923e12e2c5aeec58c52f4aa8085ac8237", - "sha256:cb7df71de0af56000115eafd000b867d1261f786b5eebd88a0ca6360cccfaca7", - "sha256:cedb2f9e1f990918ea061f28a0f0077a07702e3819602d3507e2ff98c8d20636", - "sha256:e8caf961e1b1a945db76f1b5fa9c91498d15f545ac0ababbe575cfab185d3bd8" + "sha256:004d1880bed2d97151facef49f08e255a20ceb6f9432df75f4eef018fdd5a78c", + "sha256:01d84219b5cdbfc8122223b39a954820929497a1cb1422824bb86b07b74594b6", + "sha256:040af6c32813fa3eae5305d53f18875bedd079960822ef8ec067a66dd8afcd45", + "sha256:06191eb60f8d8a5bc046f3799f8a07a2d7aefb9504b0209aff0b47298333302a", + "sha256:13034c4409db851670bc9acd836243aeee299949bd5673e11844befcb0149f03", + "sha256:13c4ee887eca0f4c5a247b75398d4114c37882658300e153113dafb1d76de529", + "sha256:184a47bbe0aa6400ed2d41d8e9ed868b8205046518c52464fde713ea06e3a74a", + "sha256:18ba8bbede96a2c3dde7b868de9dcbd55670690af0988713f0603f037848418a", + "sha256:1aa846f56c3d49205c952d8318e76ccc2ae23303351d9270ab220004c580cfe2", + "sha256:217658ec7187497e3f3ebd901afdca1af062b42cfe3e0dafea4cced3983739f6", + "sha256:24d4a7de75446be83244eabbff746d66b9240ae020ced65d060815fac3423759", + "sha256:2910f4d36a6a9b4214bb7038d537f015346f413a975d57ca6b43bf23d6563b53", + "sha256:2949cad1c5208b8298d5686d5a85b66aae46d73eec2c3e08c817dd3513e5848a", + "sha256:2a3859cb82dcbda1cfd3e6f71c27081d18aa251d20a17d87d26d4cd216fb0af4", + "sha256:2cafbbb3af0733db200c9b5f798d18953b1a304d3f86a938367de1567f4b5bff", + "sha256:2e0d881ad471768bf6e6c2bf905d183543f10098e3b3640fc029509530091502", + "sha256:30c77c1dc9f253283e34c27935fded5015f7d1abe83bc7821680ac444eaf7793", + "sha256:3487286bc29a5aa4b93a072e9592f22254291ce96a9fbc5251f566b6b7343cdb", + "sha256:372da284cfd642d8e08ef606917846fa2ee350f64994bebfbd3afb0040436905", + "sha256:41179b8a845742d1eb60449bdb2992196e211341818565abded11cfa90efb821", + "sha256:44d654437b8ddd9eee7d1eaee28b7219bec228520ff809af170488fd2fed3e2b", + "sha256:4a7697d8cb0f27399b0e393c0b90f0f1e40c82023ea4d45d22bce7032a5d7b81", + "sha256:51cb9476a3987c8967ebab3f0fe144819781fca264f57f89760037a2ea191cb0", + "sha256:52596d3d0e8bdf3af43db3e9ba8dcdaac724ba7b5ca3f6358529d56f7a166f8b", + "sha256:53194af30d5bad77fcba80e23a1441c71abfb3e01192034f8246e0d8f99528f3", + "sha256:5fec2d43a2cc6965edc0bb9e83e1e4b557f76f843a77a2496cbe719583ce8184", + "sha256:6c90e11318f0d3c436a42409f2749ee1a115cd8b067d7f14c148f1ce5574d701", + "sha256:74d881fc777ebb11c63736622b60cb9e4aee5cace591ce274fb69e582a12a61a", + "sha256:7501140f755b725495941b43347ba8a2777407fc7f250d4f5a7d2a1050ba8e82", + "sha256:796c9c3c79747146ebd278dbe1e5c5c05dd6b10cc3bcb8389dfdf844f3ead638", + "sha256:869a64f53488f40fa5b5b9dcb9e9b2962a66a87dab37790f3fcfb5144b996ef5", + "sha256:8963a499849a1fc54b35b1c9f162f4108017b2e6db2c46c1bed93a72262ed083", + "sha256:8d0a0725ad7c1a0bcd8d1b437e191107d457e2ec1084b9f190630a4fb1af78e6", + "sha256:900fbf7759501bc7807fd6638c947d7a831fc9fdf742dc10f02956ff7220fa90", + "sha256:92b017ce34b68a7d67bd6d117e6d443a9bf63a2ecf8567bb3d8c6c7bc5014465", + "sha256:970284a88b99673ccb2e4e334cfb38a10aab7cd44f7457564d11898a74b62d0a", + "sha256:972c85d205b51e30e59525694670de6a8a89691186012535f9d7dbaa230e42c3", + "sha256:9a1ef3b66e38ef8618ce5fdc7bea3d9f45f3624e2a66295eea5e57966c85909e", + "sha256:af0e781009aaf59e25c5a678122391cb0f345ac0ec272c7961dc5455e1c40066", + "sha256:b6d534e4b2ab35c9f93f46229363e17f63c53ad01330df9f2d6bd1187e5eaacf", + "sha256:b7895207b4c843c76a25ab8c1e866261bcfe27bfaa20c192de5190121770672b", + "sha256:c0891a6a97b09c1f3e073a890514d5012eb256845c451bd48f7968ef939bf4ae", + "sha256:c2723d347ab06e7ddad1a58b2a821218239249a9e4365eaff6649d31180c1669", + "sha256:d1f8bf7b90ba55699b3a5e44930e93ff0189aa27186e96071fac7dd0d06a1873", + "sha256:d1f9ce122f83b2305592c11d64f181b87153fc2c2bbd3bb4a3dde8303cfb1a6b", + "sha256:d314ed732c25d29775e84a960c3c60808b682c08d86602ec2c3008e1202e3bb6", + "sha256:d636598c8305e1f90b439dbf4f66437de4a5e3c31fdf47ad29542478c8508bbb", + "sha256:deee1077aae10d8fa88cb02c845cfba9b62c55e1183f52f6ae6a2df6a2187160", + "sha256:ebe78fe9a0e874362175b02371bdfbee64d8edc42a044253ddf4ee7d3c15212c", + "sha256:f030f8873312a16414c0d8e1a1ddff2d3235655a2174e3648b4fa66b3f2f1079", + "sha256:f0b278ce10936db1a37e6954e15a3730bea96a0997c26d7fee88e6c396c2086d", + "sha256:f11642dddbb0253cc8853254301b51390ba0081750a8ac03f20ea8103f0c56b6" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'", - "version": "==5.3" + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4.0'", + "version": "==5.5" }, "flake8": { "hashes": [ - "sha256:749dbbd6bfd0cf1318af27bf97a14e28e5ff548ef8e5b1566ccfb25a11e7c839", - "sha256:aadae8761ec651813c24be05c6f7b4680857ef6afaae4651a4eccaef97ce6c3b" + "sha256:07528381786f2a6237b061f6e96610a4167b226cb926e2aa2b6b1d78057c576b", + "sha256:bf8fd333346d844f616e8d47905ef3a3384edae6b4e9beb0c5101e25e3110907" ], "index": "pypi", - "version": "==3.8.4" + "version": "==3.9.2" }, "iniconfig": { "hashes": [ - "sha256:80cf40c597eb564e86346103f609d74efce0f6b4d4f30ec8ce9e2c26411ba437", - "sha256:e5f92f89355a67de0595932a6c6c02ab4afddc6fcdc0bfc5becd0d60884d3f69" + "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", + "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" ], - "version": "==1.0.1" + "version": "==1.1.1" }, "isort": { "hashes": [ - "sha256:2f510f34ae18a8d0958c53eec51ef84fd099f07c4c639676525acbcd7b5bd3ff", - "sha256:dd3211f513f4a92ec1ec1876fc1dc3c686649c349d49523f5b5adbb0814e5960" + "sha256:9c2ea1e62d871267b78307fe511c0838ba0da28698c5732d54e2790bf3ba9899", + "sha256:e17d6e2b81095c9db0a03a8025a957f334d6ea30b26f9ec70805411e5c7c81f2" ], "index": "pypi", - "version": "==5.6.1" + "version": "==5.9.3" }, "mccabe": { "hashes": [ @@ -197,11 +254,11 @@ }, "packaging": { "hashes": [ - "sha256:4357f74f47b9c12db93624a82154e9b120fa8293699949152b22065d556079f8", - "sha256:998416ba6962ae7fbd6596850b80e17859a5753ba17c32284f67bfff33784181" + "sha256:7dc96269f53a4ccec5c0670940a4281106dd0bb343f47b7471f779df49c2fbe7", + "sha256:c86254f9220d55e31cc94d69bade760f0847da8000def4dfe1c6b872fd14ff14" ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==20.4" + "markers": "python_version >= '3.6'", + "version": "==21.0" }, "pluggy": { "hashes": [ @@ -213,27 +270,27 @@ }, "py": { "hashes": [ - "sha256:366389d1db726cd2fcfc79732e75410e5fe4d31db13692115529d34069a043c2", - "sha256:9ca6883ce56b4e8da7e79ac18787889fa5206c79dcc67fb065376cd2fe03f342" + "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3", + "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==1.9.0" + "version": "==1.10.0" }, "pycodestyle": { "hashes": [ - "sha256:2295e7b2f6b5bd100585ebcb1f616591b652db8a741695b3d8f5d28bdc934367", - "sha256:c58a7d2815e0e8d7972bf1803331fb0152f867bd89adf8a01dfd55085434192e" + "sha256:514f76d918fcc0b55c6680472f0a37970994e07bbb80725808c17089be302068", + "sha256:c389c1d06bf7904078ca03399a4816f974a1d590090fecea0c63ec26ebaf1cef" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==2.6.0" + "version": "==2.7.0" }, "pyflakes": { "hashes": [ - "sha256:0d94e0e05a19e57a99444b6ddcf9a6eb2e5c68d3ca1e98e90707af8152c90a92", - "sha256:35b2d75ee967ea93b55750aa9edbbf72813e06a66ba54438df2cfac9e3c27fc8" + "sha256:7893783d01b8a89811dd72d7dfd4d84ff098e5eed95cfa8905b22bbffe52efc3", + "sha256:f5bc8ecabc05bb9d291eb5203d6810b49040f6ff446a756326104746cc00c1db" ], "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==2.2.0" + "version": "==2.3.1" }, "pyparsing": { "hashes": [ @@ -245,34 +302,27 @@ }, "pytest": { "hashes": [ - "sha256:7a8190790c17d79a11f847fba0b004ee9a8122582ebff4729a082c109e81a4c9", - "sha256:8f593023c1a0f916110285b6efd7f99db07d59546e3d8c36fc60e2ab05d3be92" + "sha256:50bcad0a0b9c5a72c8e4e7c9855a3ad496ca6a881a3641b4260605450772c54b", + "sha256:91ef2131a9bd6be8f76f1f08eac5c5317221d6ad1e143ae03894b862e8976890" ], "index": "pypi", - "version": "==6.1.1" + "version": "==6.2.4" }, "pytest-cov": { "hashes": [ - "sha256:45ec2d5182f89a81fc3eb29e3d1ed3113b9e9a873bcddb2a71faaab066110191", - "sha256:47bd0ce14056fdd79f93e1713f88fad7bdcc583dcd7783da86ef2f085a0bb88e" + "sha256:261bb9e47e65bd099c89c3edf92972865210c36813f80ede5277dceb77a4a62a", + "sha256:261ceeb8c227b726249b376b8526b600f38667ee314f910353fa318caa01f4d7" ], "index": "pypi", - "version": "==2.10.1" - }, - "six": { - "hashes": [ - "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", - "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" - ], - "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", - "version": "==1.15.0" + "version": "==2.12.1" }, "toml": { "hashes": [ - "sha256:926b612be1e5ce0634a2ca03470f95169cf16f939018233a670519cb4ac58b0f", - "sha256:bda89d5935c2eac546d648028b9901107a595863cb36bae0c73ac804a9b4ce88" + "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", + "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" ], - "version": "==0.10.1" + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==0.10.2" } } } diff --git a/seqeval/metrics/sequence_labeling.py b/seqeval/metrics/sequence_labeling.py index b5807a3..fb33d0b 100644 --- a/seqeval/metrics/sequence_labeling.py +++ b/seqeval/metrics/sequence_labeling.py @@ -27,7 +27,8 @@ def precision_recall_fscore_support(y_true: List[List[str]], beta: float = 1.0, sample_weight: Optional[List[int]] = None, zero_division: str = 'warn', - suffix: bool = False) -> SCORES: + suffix: bool = False, + partial_match: bool = False) -> SCORES: """Compute precision, recall, F-measure and support for each class. Args: @@ -70,6 +71,8 @@ def precision_recall_fscore_support(y_true: List[List[str]], suffix : bool, False by default. + partial_match : bool, False by default. + Returns: precision : float (if average is not None) or array of float, shape = [n_unique_labels] @@ -121,9 +124,32 @@ def extract_tp_actual_correct(y_true, y_pred, suffix, *args): for type_name in target_names: entities_true_type = entities_true.get(type_name, set()) entities_pred_type = entities_pred.get(type_name, set()) - tp_sum = np.append(tp_sum, len(entities_true_type & entities_pred_type)) - pred_sum = np.append(pred_sum, len(entities_pred_type)) - true_sum = np.append(true_sum, len(entities_true_type)) + if partial_match: + n_sublist = len(y_true) + vector_size = 0 + if entities_true_type: + vector_size = max(entities_true_type)[1] + if entities_pred_type: + vector_size = max(max(entities_pred_type)[1], vector_size) + + vector_size += n_sublist + entities_true_vector = np.zeros(vector_size, dtype=np.bool8) + # fill true values + for star, end in entities_true_type: + entities_true_vector[star:end+1] = True + # fill predict values + entities_pred_vector = np.zeros(vector_size, dtype=np.bool8) + for star, end in entities_pred_type: + entities_pred_vector[star:end+1] = True + + tp_sum = np.append(tp_sum, (entities_true_vector * entities_pred_vector).sum()) + pred_sum = np.append(pred_sum, entities_pred_vector.sum()) + true_sum = np.append(true_sum, entities_true_vector.sum()) + + else: + tp_sum = np.append(tp_sum, len(entities_true_type & entities_pred_type)) + pred_sum = np.append(pred_sum, len(entities_pred_type)) + true_sum = np.append(true_sum, len(entities_true_type)) return pred_sum, tp_sum, true_sum @@ -281,7 +307,8 @@ def f1_score(y_true: List[List[str]], y_pred: List[List[str]], mode: Optional[str] = None, sample_weight: Optional[List[int]] = None, zero_division: str = 'warn', - scheme: Optional[Type[Token]] = None): + scheme: Optional[Type[Token]] = None, + partial_match: bool = False): """Compute the F1 score. The F1 score can be interpreted as a weighted average of the precision and @@ -330,6 +357,8 @@ def f1_score(y_true: List[List[str]], y_pred: List[List[str]], suffix : bool, False by default. + partial_match : bool, False by default. + Returns: score : float or array of float, shape = [n_unique_labels]. @@ -354,7 +383,8 @@ def f1_score(y_true: List[List[str]], y_pred: List[List[str]], sample_weight=sample_weight, zero_division=zero_division, scheme=scheme, - suffix=suffix) + suffix=suffix + ) else: _, _, f, _ = precision_recall_fscore_support(y_true, y_pred, average=average, @@ -362,7 +392,8 @@ def f1_score(y_true: List[List[str]], y_pred: List[List[str]], beta=1, sample_weight=sample_weight, zero_division=zero_division, - suffix=suffix) + suffix=suffix, + partial_match=partial_match) return f @@ -406,7 +437,8 @@ def precision_score(y_true: List[List[str]], y_pred: List[List[str]], mode: Optional[str] = None, sample_weight: Optional[List[int]] = None, zero_division: str = 'warn', - scheme: Optional[Type[Token]] = None): + scheme: Optional[Type[Token]] = None, + partial_match: bool = False): """Compute the precision. The precision is the ratio ``tp / (tp + fp)`` where ``tp`` is the number of @@ -454,6 +486,8 @@ def precision_score(y_true: List[List[str]], y_pred: List[List[str]], suffix : bool, False by default. + partial_match : bool, False by default. + Returns: score : float or array of float, shape = [n_unique_labels]. @@ -484,7 +518,8 @@ def precision_score(y_true: List[List[str]], y_pred: List[List[str]], warn_for=('precision',), sample_weight=sample_weight, zero_division=zero_division, - suffix=suffix) + suffix=suffix, + partial_match=partial_match) return p @@ -495,7 +530,8 @@ def recall_score(y_true: List[List[str]], y_pred: List[List[str]], mode: Optional[str] = None, sample_weight: Optional[List[int]] = None, zero_division: str = 'warn', - scheme: Optional[Type[Token]] = None): + scheme: Optional[Type[Token]] = None, + partial_match: bool = False,): """Compute the recall. The recall is the ratio ``tp / (tp + fn)`` where ``tp`` is the number of @@ -543,6 +579,8 @@ def recall_score(y_true: List[List[str]], y_pred: List[List[str]], suffix : bool, False by default. + partial_match : bool, False by default. + Returns: score : float. @@ -573,7 +611,8 @@ def recall_score(y_true: List[List[str]], y_pred: List[List[str]], warn_for=('recall',), sample_weight=sample_weight, zero_division=zero_division, - suffix=suffix) + suffix=suffix, + partial_match=partial_match) return r @@ -617,7 +656,8 @@ def classification_report(y_true, y_pred, mode=None, sample_weight=None, zero_division='warn', - scheme=None): + scheme=None, + partial_match: bool = False): """Build a text report showing the main classification metrics. Args: @@ -648,6 +688,8 @@ def classification_report(y_true, y_pred, suffix : bool, False by default. + partial_match : bool, False by default. + Returns: report : string/dict. Summary of the precision, recall, F1 score for each class. @@ -694,7 +736,8 @@ def classification_report(y_true, y_pred, average=None, sample_weight=sample_weight, zero_division=zero_division, - suffix=suffix + suffix=suffix, + partial_match=partial_match, ) for row in zip(target_names, p, r, f1, s): reporter.write(*row) @@ -708,7 +751,8 @@ def classification_report(y_true, y_pred, average=average, sample_weight=sample_weight, zero_division=zero_division, - suffix=suffix + suffix=suffix, + partial_match=partial_match ) reporter.write('{} avg'.format(average), avg_p, avg_r, avg_f1, support) reporter.write_blank() diff --git a/tests/test_metrics.py b/tests/test_metrics.py index c1fdb8f..819f1cc 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -123,9 +123,15 @@ def test_performance_measure(self): def test_classification_report(self): print(classification_report(self.y_true, self.y_pred)) + def test_classification_report(self): + print(classification_report(self.y_true, self.y_pred, partial_match=True)) + def test_inv_classification_report(self): print(classification_report(self.y_true_inv, self.y_pred_inv, suffix=True)) + def test_classification_report(self): + print(classification_report(self.y_true_inv, self.y_pred_inv, suffix=True, partial_match=True)) + def test_by_ground_truth(self): with open(self.file_name) as f: output = subprocess.check_output(['perl', 'conlleval.pl'], stdin=f).decode('utf-8') From 688d7efd76d03c263e0211335b64065a6e6346e6 Mon Sep 17 00:00:00 2001 From: morfeo359bone Date: Mon, 2 Aug 2021 18:05:20 -0500 Subject: [PATCH 7/7] add sample partial match in README.md --- README.md | 15 +++++++++++++++ seqeval/metrics/sequence_labeling.py | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a9be8ad..97dd063 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,21 @@ In strict mode, the inputs are evaluated according to the specified schema. The weighted avg 0.50 0.50 0.50 2 ``` +With the partial match, the inputs are evaluated according the number of tags. It isn't compatible with strict mode. +```python +print(classification_report(y_true, y_pred, partial_match=True)) + + precision recall f1-score support + + MISC 0.75 1.00 0.86 3 + PER 1.00 1.00 1.00 2 + + micro avg 0.83 1.00 0.91 5 + macro avg 0.88 1.00 0.93 5 +weighted avg 0.85 1.00 0.91 5 +``` + + A minimum case to explain differences between the default and strict mode: ```python diff --git a/seqeval/metrics/sequence_labeling.py b/seqeval/metrics/sequence_labeling.py index fb33d0b..e68aa95 100644 --- a/seqeval/metrics/sequence_labeling.py +++ b/seqeval/metrics/sequence_labeling.py @@ -136,11 +136,11 @@ def extract_tp_actual_correct(y_true, y_pred, suffix, *args): entities_true_vector = np.zeros(vector_size, dtype=np.bool8) # fill true values for star, end in entities_true_type: - entities_true_vector[star:end+1] = True + entities_true_vector[star:end + 1] = True # fill predict values entities_pred_vector = np.zeros(vector_size, dtype=np.bool8) for star, end in entities_pred_type: - entities_pred_vector[star:end+1] = True + entities_pred_vector[star:end + 1] = True tp_sum = np.append(tp_sum, (entities_true_vector * entities_pred_vector).sum()) pred_sum = np.append(pred_sum, entities_pred_vector.sum())