-
Notifications
You must be signed in to change notification settings - Fork 7
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 #60 from mindsdb/staging
Release 0.0.18
- Loading branch information
Showing
19 changed files
with
817 additions
and
739 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "type_infer" | ||
version = "0.0.17" | ||
version = "0.0.18" | ||
description = "Automated type inference for Machine Learning pipelines." | ||
authors = ["MindsDB Inc. <[email protected]>"] | ||
license = "GPL-3.0" | ||
|
@@ -15,12 +15,17 @@ numpy = "^1.15" | |
pandas = "^2" | ||
dataclasses-json = "^0.6.3" | ||
colorlog = "^6.5.0" | ||
langid = "^1.1.6" | ||
nltk = "^3" | ||
toml = "^0.10.2" | ||
psutil = "^5.9.0" | ||
toml = "^0.10.2" | ||
|
||
# rule based deps, part of core | ||
langid = "^1.1.6" | ||
nltk = "^3" | ||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
build-backend = "poetry.core.masonry.api" | ||
|
||
# TODO: update once this engine is introduced | ||
[tool.poetry.extras] | ||
# bert = ["torch"] |
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
Empty file.
4 changes: 3 additions & 1 deletion
4
tests/unit_tests/test_dates.py → tests/unit_tests/rule_based/test_dates.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,22 @@ | ||
import unittest | ||
import random | ||
|
||
import pandas as pd | ||
from type_infer.rule_based.core import RuleBasedEngine | ||
from type_infer.dtype import dtype | ||
|
||
get_column_data_type = RuleBasedEngine.get_column_data_type | ||
|
||
|
||
class TestInferDtypes(unittest.TestCase): | ||
def test_negative_integers(self): | ||
data = pd.DataFrame([-random.randint(-10, 10) for _ in range(100)], columns=['test_col']) | ||
engine = RuleBasedEngine() | ||
dtyp, dist, ainfo, warn, info = engine.get_column_data_type(data['test_col'], data, 'test_col', 0.0) | ||
self.assertEqual(dtyp, dtype.integer) | ||
|
||
def test_negative_floats(self): | ||
data = pd.DataFrame([float(-random.randint(-10, 10)) for _ in range(100)] + [0.1], columns=['test_col']) | ||
engine = RuleBasedEngine() | ||
dtyp, dist, ainfo, warn, info = engine.get_column_data_type(data['test_col'], data, 'test_col', 0.0) | ||
self.assertEqual(dtyp, dtype.float) |
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,12 @@ | ||
import unittest | ||
|
||
from type_infer.rule_based.helpers import tokenize_text | ||
|
||
|
||
class TestDates(unittest.TestCase): | ||
def test_get_tokens(self): | ||
sentences = ['hello, world!', ' !hello! world!!,..#', '#hello!world'] | ||
for sent in sentences: | ||
assert list(tokenize_text(sent)) == ['hello', 'world'] | ||
|
||
assert list(tokenize_text("don't wouldn't")) == ['do', 'not', 'would', 'not'] |
This file was deleted.
Oops, something went wrong.
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,10 +1,12 @@ | ||
from type_infer import base | ||
from type_infer import dtype | ||
from type_infer import infer | ||
from type_infer import api | ||
from type_infer import helpers | ||
|
||
__version__ = '0.0.18' | ||
|
||
__version__ = '0.0.17' | ||
|
||
|
||
__all__ = ['base', 'dtype', 'infer', 'helpers', '__version__'] | ||
__all__ = [ | ||
'__version__', | ||
'base', 'dtype', 'api', 'helpers', | ||
] |
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,40 @@ | ||
from typing import Dict, Optional | ||
import pandas as pd | ||
|
||
from type_infer.base import TypeInformation, ENGINES | ||
from type_infer.rule_based.core import RuleBasedEngine | ||
|
||
|
||
def infer_types( | ||
data: pd.DataFrame, | ||
config: Optional[Dict] = None | ||
) -> TypeInformation: | ||
""" | ||
Infers the data types of each column of the dataset by analyzing a small sample of | ||
each column's items. | ||
Inputs | ||
---------- | ||
data : pd.DataFrame | ||
The input dataset for which we want to infer data type information. | ||
""" | ||
# Set global defaults if missing | ||
if config is None: | ||
config = {'engine': 'rule_based', 'pct_invalid': 2, 'seed': 420, 'mp_cutoff': 1e4} | ||
elif 'engine' not in config: | ||
config['engine'] = 'rule_based' | ||
|
||
if 'pct_invalid' not in config: | ||
config['pct_invalid'] = 2 | ||
|
||
if 'seed' not in config: | ||
config['seed'] = 420 | ||
|
||
if config['engine'] == ENGINES.RULE_BASED: | ||
if 'mp_cutoff' not in config: | ||
config['mp_cutoff'] = 1e4 | ||
|
||
engine = RuleBasedEngine(config) | ||
return engine.infer(data) | ||
else: | ||
raise Exception(f'Unknown engine {config["engine"]}') |
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
Empty file.
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,9 @@ | ||
from type_infer.base import BaseEngine | ||
|
||
|
||
class BERType(BaseEngine): | ||
def __init__(self, stable=False): | ||
super().__init__(stable=stable) | ||
|
||
def infer(self, df): | ||
raise NotImplementedError |
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 |
---|---|---|
|
@@ -45,3 +45,6 @@ class dtype: | |
# Misc (Unk/NaNs) | ||
empty = "empty" | ||
invalid = "invalid" | ||
|
||
|
||
# TODO: modifier class + system |
Oops, something went wrong.