-
Notifications
You must be signed in to change notification settings - Fork 0
Rstevanak/models tester #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rstevanak
wants to merge
7
commits into
master
Choose a base branch
from
rstevanak/models_tester
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
470edc6
added model testing script
rstevanak 0abcfe4
fixed pep-8 error
rstevanak 0087594
changed required options to arguments
rstevanak 1579e40
loader argument fix
rstevanak 9c32e26
click now checks input paths, changed pickle to joblib
rstevanak 62f5df6
Added machine friendly printing
rstevanak 8d14223
ad-hoc import solution, added some commentary
rstevanak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import os | ||
| import pickle | ||
| import click | ||
| from sklearn.metrics import classification_report | ||
| from pkspace.utils.loaders import PKSpaceLoader, PKLotLoader | ||
|
|
||
|
|
||
| @click.command() | ||
| @click.option('--loader', '-l', type=click.Choice(['PKLot', 'PKSpace']), | ||
| default='PKSpace', help='Loader used to load dataset') | ||
| @click.argument('dataset_dir') | ||
| @click.argument('model_file') | ||
| def test_model(loader, dataset_dir, model_file): | ||
| if not os.path.isdir(dataset_dir): | ||
| print('{} is not a directory') | ||
| return | ||
|
|
||
| if loader == 'PKSpace': | ||
| loader = PKSpaceLoader() | ||
| elif loader == 'PKLot': | ||
| loader = PKLotLoader() | ||
|
|
||
| with open(model_file, 'rb') as mp: | ||
| model = pickle.load(mp) | ||
| spaces, ground_answers = loader.load(dataset_dir) | ||
| model_answers = model.predict(spaces) | ||
| print(classification_report(ground_answers, model_answers)) | ||
|
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| test_model() | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rstevanak Here we can add similar line to the trainer file
output = os.path.join(dataset_dir, 'out.pkl')so theclickwould take care of handling the existence of these file for us.