-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from yzhao062/development
V0.8.4
- Loading branch information
Showing
14 changed files
with
493 additions
and
47 deletions.
There are no files selected for viewing
This file contains 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 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,49 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Example of using and visualizing ``generate_data_categorical`` function. | ||
""" | ||
# Author: Yahya Almardeny <almardeny@gmail.com> | ||
# License: BSD 2 clause | ||
|
||
from __future__ import division | ||
from __future__ import print_function | ||
|
||
import os | ||
import sys | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
|
||
# temporary solution for relative imports in case pyod is not installed | ||
# if pyod is installed, no need to use the following line | ||
|
||
sys.path.append( | ||
os.path.abspath(os.path.join(os.path.dirname("__file__"), '..'))) | ||
|
||
from pyod.utils.data import generate_data_categorical | ||
|
||
if __name__ == "__main__": | ||
contamination = 0.1 # percentage of outliers | ||
|
||
# Generate sample data in clusters | ||
X_train, X_test, y_train, y_test = generate_data_categorical \ | ||
(n_train=200, n_test=50, | ||
n_category_in=8, n_category_out=5, | ||
n_informative=1, n_features=1, | ||
contamination=contamination, | ||
shuffle=True, random_state=42) | ||
|
||
# note that visalizing it can only be in 1 dimension! | ||
cats = list(np.ravel(X_train)) | ||
labels = list(y_train) | ||
fig, axs = plt.subplots(1, 2) | ||
axs[0].bar(cats, labels) | ||
axs[1].plot(cats, labels) | ||
plt.title('Synthetic Categorical Train Data') | ||
plt.show() | ||
|
||
cats = list(np.ravel(X_test)) | ||
labels = list(y_test) | ||
fig, axs = plt.subplots(1, 2) | ||
axs[0].bar(cats, labels) | ||
axs[1].plot(cats, labels) | ||
plt.title('Synthetic Categorical Test Data') | ||
plt.show() |
This file contains 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 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,27 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Base class for deep learning models | ||
""" | ||
# Author: Yue Zhao <zhaoy@cmu.edu> | ||
# License: BSD 2 clause | ||
|
||
from __future__ import division | ||
from __future__ import print_function | ||
|
||
import tensorflow | ||
|
||
def _get_tensorflow_version(): # pragma: no cover | ||
""" Utility function to decide the version of tensorflow, which will | ||
affect how to import keras models. | ||
Returns | ||
------- | ||
tensorflow version : int | ||
""" | ||
|
||
tf_version = str(tensorflow.__version__) | ||
if int(tf_version.split(".")[0]) != 1 and int( | ||
tf_version.split(".")[0]) != 2: | ||
raise ValueError("tensorflow version error") | ||
|
||
return int(tf_version.split(".")[0]) |
This file contains 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 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 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 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 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 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
Oops, something went wrong.