Skip to content

Commit

Permalink
Merge pull request #89 from salesforce/fix_defaults
Browse files Browse the repository at this point in the history
Fix the default parameters in TabularTransform
  • Loading branch information
yangwenz authored Jul 16, 2023
2 parents 9d110bd + 7933284 commit f3ba97f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 37 deletions.
34 changes: 6 additions & 28 deletions docs/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,35 +45,13 @@ sphinx-build -b html "${DIRNAME}" "${DIRNAME}/_build/html/${current_version}" -W
rm -rf "${DIRNAME}/_build/html/${current_version}/.doctrees"
pip3 uninstall -y omnixai

# Install all previous released versions
# and use them to build the appropriate API docs.
# Uninstall after we're done with each one.
versions=()
checkout_files=("${DIRNAME}/*.rst" "tutorials" "omnixai" "setup.py")
for version in $(git tag --list 'v[0-9]*'); do
versions+=("$version")
git checkout -b "${version}_local_docs_only"
for f in $(git diff --name-only --diff-filter=A "tags/${version}" "${DIRNAME}/*.rst"); do
git rm "$f"
done
git checkout "tags/${version}" -- "${checkout_files[@]}"
export current_version=${version}
pip3 install ".[all]"
sphinx-build -b html "${DIRNAME}" "${DIRNAME}/_build/html/${current_version}" -W --keep-going
rm -rf "${DIRNAME}/_build/html/${current_version}/.doctrees"
pip3 uninstall -y omnixai
git reset --hard
git checkout "${GIT_BRANCH}" --
done
# Build API docs for current head
export current_version="latest"
pip3 install ".[all]"
sphinx-build -b html "${DIRNAME}" "${DIRNAME}/_build/html/${current_version}" -W --keep-going
rm -rf "${DIRNAME}/_build/html/${current_version}/.doctrees"

# Determine the latest stable version if there is one
if (( ${#versions[@]} > 0 )); then
stable_hash=$(git rev-list --tags --max-count=1)
stable_version=$(git describe --tags "$stable_hash")
export stable_version
else
export stable_version="latest"
fi
export stable_version="latest"

# Create dummy HTML's for the stable version in the base directory
while read -r filename; do
Expand Down
21 changes: 13 additions & 8 deletions omnixai/preprocessing/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""
import numpy as np
import pandas as pd
from typing import Optional
from .base import TransformBase, Identity
from .encode import OneHot, Ordinal, LabelEncoder
from ..data.tabular import Tabular
Expand All @@ -21,21 +22,25 @@ class TabularTransform(TransformBase):

def __init__(
self,
cate_transform: TransformBase = OneHot(),
cont_transform: TransformBase = Identity(),
target_transform: TransformBase = LabelEncoder(),
cate_transform: Optional[TransformBase] = None,
cont_transform: Optional[TransformBase] = None,
target_transform: Optional[TransformBase] = None,
):
"""
:param cate_transform: The transform for the categorical features, e.g.,
`OneHot`, `Ordinal`.
`OneHot`, `Ordinal`. Default is `OneHot`.
:param cont_transform: The transform for the continuous-valued features,
e.g., `Identity`, `Standard`, `MinMax`, `Scale`.
e.g., `Identity`, `Standard`, `MinMax`, `Scale`. Default is `Identity`.
:param target_transform: The transform for the target column, e.g.,
`Identity` for regression, `LabelEncoder` for classification.
`Identity` for regression, `LabelEncoder` for classification. Default is `LabelEncoder`.
"""
super().__init__()
assert cate_transform is not None, "Transform for categorical features cannot be None."
assert cont_transform is not None, "Transform for continuous-valued features cannot be None."
if cate_transform is None:
cate_transform = OneHot()
if cont_transform is None:
cont_transform = Identity()
if target_transform is None:
target_transform = LabelEncoder()

# Feature column
self.cate_transform = cate_transform
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

setup(
name="omnixai",
version="1.3.0",
version="1.3.1",
author="Wenzhuo Yang, Hung Le, Tanmay Shivprasad Laud, Silvio Savarese, Steven C.H. Hoi",
description="OmniXAI: An Explainable AI Toolbox",
long_description=open("README.md", "r", encoding="utf-8").read(),
Expand Down

0 comments on commit f3ba97f

Please sign in to comment.