-
Notifications
You must be signed in to change notification settings - Fork 604
adding t-test to pre-deployed models #312
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
33c57ba
adding t-test to pre-deployed models
sbabayan 708fe8a
fixed pep8 issues
sbabayan f0b6279
import error on ttest and updated successful deployment message for s…
sbabayan aace278
fixed md issues
sbabayan e134e51
fixed endpoint name in integration tests
sbabayan e5e0c19
refactor redundant code and update md
sbabayan 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
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
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
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,44 @@ | ||
from scipy import stats | ||
import sys | ||
from pathlib import Path | ||
sys.path.append(str(Path(__file__).resolve().parent.parent.parent / 'models')) | ||
from utils import setup_utils | ||
|
||
|
||
def ttest(_arg1, _arg2): | ||
''' | ||
T-Test is a statistical hypothesis test that is used to compare | ||
two sample means or a sample’s mean against a known population mean. | ||
For more information on the function and how to use it please refer | ||
to tabpy-tools.md | ||
''' | ||
# one sample test with mean | ||
if len(_arg2) == 1: | ||
test_stat, p_value = stats.ttest_1samp(_arg1, _arg2) | ||
return p_value | ||
# two sample t-test where _arg1 is numeric and _arg2 is a binary factor | ||
elif len(set(_arg2)) == 2: | ||
# each sample in _arg1 needs to have a corresponding classification | ||
# in _arg2 | ||
if not (len(_arg1) == len(_arg2)): | ||
raise ValueError | ||
class1, class2 = set(_arg2) | ||
sample1 = [] | ||
sample2 = [] | ||
for i in range(len(_arg1)): | ||
if _arg2[i] == class1: | ||
sample1.append(_arg1[i]) | ||
else: | ||
sample2.append(_arg1[i]) | ||
test_stat, p_value = stats.ttest_ind(sample1, sample2, equal_var=False) | ||
return p_value | ||
# arg1 is a sample and arg2 is a sample | ||
else: | ||
test_stat, p_value = stats.ttest_ind(_arg1, _arg2, equal_var=False) | ||
return p_value | ||
|
||
|
||
if __name__ == '__main__': | ||
setup_utils.main('ttest', | ||
ttest, | ||
'Returns the p-value form a t-test') |
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
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.