-
Notifications
You must be signed in to change notification settings - Fork 1
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 #22 from msamsami/enhancements
Adhere to sklearn's docstring and type hint format, minor improvements
- Loading branch information
Showing
10 changed files
with
313 additions
and
132 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -133,4 +133,5 @@ dmypy.json | |
|
||
# Test files | ||
/test | ||
test.ipynb | ||
test.ipynb | ||
dummy.py |
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 @@ | ||
[metadata] | ||
name = wnb | ||
version = attr: wnb.__version__ | ||
author = Mehdi Samsami | ||
author_email = mehdisamsami@live.com | ||
description = General and Weighted Naive Bayes Classifiers | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
url = https://github.com/msamsami/weighted-naive-bayes | ||
keywords = python, bayes, naivebayes, classifier, probabilistic | ||
license = BSD | ||
|
||
[options] | ||
packages = find: | ||
python_requires = >=3.7 | ||
install_requires = | ||
pandas | ||
scipy | ||
scikit-learn | ||
|
||
[options.extras_require] | ||
dev = | ||
pytest | ||
black | ||
|
||
[aliases] | ||
test = pytest |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = "0.2.0" | ||
__version__ = "0.2.1" | ||
__author__ = "Mehdi Samsami" | ||
|
||
|
||
|
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,29 @@ | ||
from enum import EnumMeta, Enum | ||
from typing import Any | ||
|
||
|
||
class CaseInsensitiveEnumMeta(EnumMeta): | ||
""" | ||
Enum metaclass to allow for interoperability with case-insensitive strings. | ||
""" | ||
|
||
def __getitem__(cls, name: str) -> Any: | ||
return super(CaseInsensitiveEnumMeta, cls).__getitem__(name.upper()) | ||
|
||
def __getattr__(cls, name: str) -> Enum: | ||
"""Returns the enum member matching `name`. | ||
We use __getattr__ instead of descriptors or inserting into the enum | ||
class' __dict__ in order to support `name` and `value` being both | ||
properties for enum members (which live in the class' __dict__) and | ||
enum members themselves. | ||
:param str name: The name of the enum member to retrieve. | ||
:rtype: ~CaseInsensitiveEnumMeta | ||
:return: The enum member matching `name`. | ||
:raises AttributeError: If `name` is not a valid enum member. | ||
""" | ||
try: | ||
return cls._member_map_[name.upper()] | ||
except KeyError as err: | ||
raise AttributeError(name) from err |
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,24 @@ | ||
from typing import Union, Type | ||
|
||
import numpy.typing | ||
import numpy as np | ||
import pandas as pd | ||
from scipy.sparse import spmatrix | ||
|
||
from ._base import ContinuousDistMixin, DiscreteDistMixin | ||
from ._enums import Distribution | ||
|
||
__all__ = ["MatrixLike", "ArrayLike", "Int", "Float", "DistibutionLike"] | ||
|
||
ArrayLike = numpy.typing.ArrayLike | ||
MatrixLike = Union[np.ndarray, pd.DataFrame, spmatrix] | ||
|
||
Int = Union[int, np.int8, np.int16, np.int32, np.int64] | ||
Float = Union[float, np.float16, np.float32, np.float64] | ||
|
||
DistibutionLike = Union[ | ||
str, | ||
Distribution, | ||
Type[ContinuousDistMixin], | ||
Type[DiscreteDistMixin], | ||
] |
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.