8000 added anvoa to supported pre-deployed models in tabpy by sbabayan · Pull Request #350 · tableau/TabPy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

added anvoa to supported pre-deployed models in tabpy #350

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 4 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions docs/tabpy-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on TabPy server.
* [Principal Component Analysis (PCA)](#principal-component-analysis-pca)
* [Sentiment Analysis](#sentiment-analysis)
* [T-Test](#t-test)
* [ANOVA](#anova)
- [Providing Schema Metadata](#providing-schema-metadata)
- [Querying an Endpoint](#querying-an-endpoint)
- [Evaluating Arbitrary Python Scripts](#evaluating-arbitrary-python-scripts)
Expand Down Expand Up @@ -318,6 +319,22 @@ The function returns a two-tailed [p-value](https://en.wikipedia.org/wiki/P-valu
you may reject or fail to reject the null hypothesis.
<!-- markdownlint-enable MD029 -->

### ANOVA

[Analysis of variance](https://en.wikipedia.org/wiki/Analysis_of_variance)
helps inform if two or more group means within a sample differ. By measuring
the variation between and among groups and computing the resulting F-statistic
we are able to obtain a p-value. While a statistically significant p-value
will inform you that at least 2 of your groups’ means are different from each
other, it will not tell you which of the two groups differ.

You can call ANOVA from tableau in the following way,

```python

tabpy.query(‘anova’, _arg1, _arg2, _arg3)[‘response’]
```

## Providing Schema Metadata

As soon as you share your deployed functions, you also need to share metadata
Expand Down
1 change: 0 additions & 1 deletion tabpy/models/deploy_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import os
import sys
import platform
import runpy
import subprocess
from pathlib import Path
from tabpy.models.utils import setup_utils
Expand Down
25 changes: 25 additions & 0 deletions tabpy/models/scripts/ANOVA.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import scipy.stats as stats
from tabpy.models.utils import setup_utils


def anova(_arg1, _arg2, *_argN):
'''
ANOVA is a statistical hypothesis test that is used to compare
two or more group means for equality.For more information on
the function and how to use it please refer to tabpy-tools.md
'''

cols = [_arg1, _arg2] + list(_argN)
for col in cols:
if not isinstance(col[0], (int, float)):
print("values must be numeric")
raise ValueError
f_stat, p_value = stats.f_oneway(_arg1, _arg2, *_argN)
return p_value


if __name__ == '__main__':
setup_utils.deploy_model(
'anova',
anova,
'Returns the p-value form an ANOVA test')
2 changes: 0 additions & 2 deletions tabpy/models/scripts/PCA.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import LabelEncoder
from sklearn.preprocessing import OneHotEncoder
import sys
from pathlib import Path
from tabpy.models.utils import setup_utils


Expand Down
2 changes: 0 additions & 2 deletions tabpy/models/scripts/SentimentAnalysis.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from textblob import TextBlob
import nltk
from nltk.sentiment.vader import SentimentIntensityAnalyzer
import sys
from pathlib import Path
from tabpy.models.utils import setup_utils


Expand Down
2 changes: 0 additions & 2 deletions tabpy/models/scripts/tTest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from scipy import stats
import sys
from pathlib import Path
from tabpy.models.utils import setup_utils


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_deploy_model_ssl_off_auth_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def test_deploy_ssl_off_auth_off(self):

conn = self._get_connection()

models = ['PCA', 'Sentiment%20Analysis', "ttest"]
models = ['PCA', 'Sentiment%20Analysis', "ttest", "anova"]
for m in models:
conn.request("GET", f'/endpoints/{m}')
m_request = conn.getresponse()
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_deploy_model_ssl_off_auth_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_deploy_ssl_off_auth_on(self):

conn = self._get_connection()

models = ['PCA', 'Sentiment%20Analysis', "ttest"]
models = ['PCA', 'Sentiment%20Analysis', "ttest", "anova"]
for m in models:
conn.request("GET", f'/endpoints/{m}', headers=headers)
m_request = conn.getresponse()
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_deploy_model_ssl_on_auth_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_deploy_ssl_on_auth_off(self):
# Do not warn about insecure request
requests.packages.urllib3.disable_warnings()

models = ['PCA', 'Sentiment%20Analysis', "ttest"]
models = ['PCA', 'Sentiment%20Analysis', "ttest", "anova"]
for m in models:
m_response = session.get(url=f'{self._get_transfer_protocol()}://'
f'localhost:9004/endpoints/{m}')
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_deploy_model_ssl_on_auth_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_deploy_ssl_on_auth_on(self):
# Do not warn about insecure request
requests.packages.urllib3.disable_warnings()

models = ['PCA', 'Sentiment%20Analysis', "ttest"]
models = ['PCA', 'Sentiment%20Analysis', "ttest", "anova"]
for m in models:
m_response = session.get(url=f'{self._get_transfer_protocol()}://'
f'localhost:9004/endpoints/{m}',
Expand Down
0