repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
featuretools | featuretools-main/featuretools/tests/primitive_tests/natural_language_primitives_tests/test_mean_characters_per_word.py | import numpy as np
import pandas as pd
import pytest
from featuretools.primitives import MeanCharactersPerWord
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
find_applicable_primitives,
valid_dfs,
)
class TestMeanCharactersPerWord(PrimitiveTestBase):
primitive = MeanCharact... | 2,737 | 32.802469 | 85 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/natural_language_primitives_tests/test_num_words.py | import numpy as np
import pandas as pd
from featuretools.primitives import NumWords
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
find_applicable_primitives,
valid_dfs,
)
class TestNumWords(PrimitiveTestBase):
primitive = NumWords
def test_general(self):
x = p... | 2,630 | 31.8875 | 76 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/natural_language_primitives_tests/test_total_word_length.py | import numpy as np
import pandas as pd
from featuretools.primitives import TotalWordLength
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
find_applicable_primitives,
valid_dfs,
)
class TestTotalWordLength(PrimitiveTestBase):
primitive = TotalWordLength
def test_delimit... | 1,590 | 32.145833 | 88 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/natural_language_primitives_tests/test_median_word_length.py | import numpy as np
import pandas as pd
from featuretools.primitives import MedianWordLength
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
find_applicable_primitives,
valid_dfs,
)
class TestMedianWordLength(PrimitiveTestBase):
primitive = MedianWordLength
def test_deli... | 1,585 | 32.041667 | 88 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/natural_language_primitives_tests/__init__.py | 0 | 0 | 0 | py | |
featuretools | featuretools-main/featuretools/tests/primitive_tests/natural_language_primitives_tests/test_whitespace_count.py | import numpy as np
import pandas as pd
from featuretools.primitives import WhitespaceCount
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
find_applicable_primitives,
valid_dfs,
)
class TestWhitespaceCount(PrimitiveTestBase):
primitive = WhitespaceCount
def compare(self... | 1,245 | 32.675676 | 80 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/natural_language_primitives_tests/test_punctuation_count.py | import numpy as np
import pandas as pd
from featuretools.primitives import PunctuationCount
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
find_applicable_primitives,
valid_dfs,
)
class TestPunctuationCount(PrimitiveTestBase):
primitive = PunctuationCount
def test_punc... | 1,642 | 31.215686 | 79 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/natural_language_primitives_tests/test_number_of_unique_words.py | import numpy as np
import pandas as pd
from featuretools.primitives import NumberOfUniqueWords
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
find_applicable_primitives,
valid_dfs,
)
class TestNumberOfUniqueWords(PrimitiveTestBase):
primitive = NumberOfUniqueWords
def ... | 2,799 | 30.818182 | 76 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/natural_language_primitives_tests/test_natural_language_primitives_terminate.py | import pandas as pd
import pytest
from featuretools.primitives.utils import _get_natural_language_primitives
TIMEOUT_THRESHOLD = 20
class TestNaturalLanguagePrimitivesTerminate:
# need to sort primitives to avoid pytest collection error
primitives = sorted(_get_natural_language_primitives().items())
@p... | 693 | 30.545455 | 75 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/natural_language_primitives_tests/test_count_string.py | import numpy as np
import pandas as pd
from featuretools.primitives import CountString
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
find_applicable_primitives,
valid_dfs,
)
class TestCountString(PrimitiveTestBase):
primitive = CountString
def compare(self, primitive_... | 7,416 | 30.561702 | 83 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/natural_language_primitives_tests/test_upper_case_word_count.py | import numpy as np
import pandas as pd
from featuretools.primitives import UpperCaseWordCount
class TestUpperCaseWordCount:
primitive = UpperCaseWordCount
def test_strings(self):
x = pd.Series(
[
"This IS a STRING.",
"Testing AAA",
"Testing... | 1,195 | 25.577778 | 59 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/primitives_to_install/custom_max.py | from woodwork.column_schema import ColumnSchema
from featuretools.primitives.base import AggregationPrimitive
class CustomMax(AggregationPrimitive):
name = "custom_max"
input_types = [ColumnSchema(semantic_tags={"numeric"})]
return_type = ColumnSchema(semantic_tags={"numeric"})
| 294 | 28.5 | 61 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/primitives_to_install/custom_sum.py | from woodwork.column_schema import ColumnSchema
from featuretools.primitives.base import AggregationPrimitive
class CustomSum(AggregationPrimitive):
name = "custom_sum"
input_types = [ColumnSchema(semantic_tags={"numeric"})]
return_type = ColumnSchema(semantic_tags={"numeric"})
| 294 | 28.5 | 61 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/primitives_to_install/custom_mean.py | from woodwork.column_schema import ColumnSchema
from featuretools.primitives.base import AggregationPrimitive
class CustomMean(AggregationPrimitive):
name = "custom_mean"
input_types = [ColumnSchema(semantic_tags={"numeric"})]
return_type = ColumnSchema(semantic_tags={"numeric"})
| 296 | 28.7 | 61 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/primitives_to_install/__init__.py | 0 | 0 | 0 | py | |
featuretools | featuretools-main/featuretools/tests/primitive_tests/bad_primitive_files/multiple_primitives.py | from woodwork.column_schema import ColumnSchema
from featuretools.primitives import AggregationPrimitive
class CustomMax(AggregationPrimitive):
name = "custom_max"
input_types = [ColumnSchema(semantic_tags={"numeric"})]
return_type = ColumnSchema(semantic_tags={"numeric"})
class CustomSum(AggregationPr... | 472 | 28.5625 | 59 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/bad_primitive_files/__init__.py | 0 | 0 | 0 | py | |
featuretools | featuretools-main/featuretools/tests/primitive_tests/bad_primitive_files/no_primitives.py | 0 | 0 | 0 | py | |
featuretools | featuretools-main/featuretools/tests/primitive_tests/aggregation_primitive_tests/test_num_consecutive.py | import numpy as np
import pandas as pd
from featuretools.primitives import NumConsecutiveGreaterMean, NumConsecutiveLessMean
class TestNumConsecutiveGreaterMean:
primitive = NumConsecutiveGreaterMean
def test_continuous_range(self):
x = pd.Series(range(10))
longest_sequence = [5, 6, 7, 8, 9]... | 7,524 | 26.973978 | 85 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/aggregation_primitive_tests/test_count_aggregation_primitives.py | import numpy as np
import pandas as pd
from pytest import raises
from featuretools.primitives import (
CountAboveMean,
CountGreaterThan,
CountInsideNthSTD,
CountInsideRange,
CountLessThan,
CountOutsideNthSTD,
CountOutsideRange,
)
from featuretools.tests.primitive_tests.utils import Primitiv... | 17,616 | 29.321859 | 78 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/aggregation_primitive_tests/test_rolling_primitive.py | import numpy as np
import pandas as pd
import pytest
from featuretools.primitives import (
RollingCount,
RollingMax,
RollingMean,
RollingMin,
RollingOutlierCount,
RollingSTD,
RollingTrend,
)
from featuretools.primitives.standard.transform.time_series.utils import (
apply_rolling_agg_to_... | 14,148 | 28.72479 | 107 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/aggregation_primitive_tests/test_max_consecutive.py | import numpy as np
import pandas as pd
import pytest
from featuretools.primitives import (
MaxConsecutiveFalse,
MaxConsecutiveNegatives,
MaxConsecutivePositives,
MaxConsecutiveTrue,
MaxConsecutiveZeros,
)
class TestMaxConsecutiveFalse:
def test_regular(self):
primitive_instance = MaxC... | 9,320 | 40.798206 | 87 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/aggregation_primitive_tests/test_time_since.py | from datetime import datetime
from math import isnan
import numpy as np
import pandas as pd
from featuretools.primitives import (
TimeSinceLastFalse,
TimeSinceLastMax,
TimeSinceLastMin,
TimeSinceLastTrue,
)
class TestTimeSinceLastFalse:
primitive = TimeSinceLastFalse
cutoff_time = datetime(2... | 8,501 | 33.282258 | 87 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/aggregation_primitive_tests/test_agg_primitives.py | from datetime import datetime
from math import sqrt
import numpy as np
import pandas as pd
import pytest
from pandas.core.dtypes.dtypes import CategoricalDtype
from pytest import raises
from featuretools.primitives import (
AverageCountPerUnique,
DateFirstEvent,
Entropy,
FirstLastTimeDelta,
HasNoD... | 42,360 | 33.524042 | 88 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/aggregation_primitive_tests/__init__.py | 0 | 0 | 0 | py | |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_percent_unique.py | import numpy as np
import pandas as pd
from featuretools.primitives import PercentUnique
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
)
class TestPercentUnique(PrimitiveTestBase):
array = pd.Series([1, 1, 2, 2, 3, 4, 5, 6, 7, 8])
primitive = PercentUnique
def test_percen... | 1,380 | 37.361111 | 88 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_latlong_primitives.py | import numpy as np
import pandas as pd
import pytest
from featuretools.primitives import CityblockDistance, GeoMidpoint, IsInGeoBox
def test_cityblock():
primitive_instance = CityblockDistance()
latlong_1 = pd.Series([(i, i) for i in range(3)])
latlong_2 = pd.Series([(i, i) for i in range(3, 6)])
ans... | 3,786 | 31.930435 | 82 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_cumulative_time_since.py | from datetime import datetime
import numpy as np
import pandas as pd
from featuretools.primitives import (
CumulativeTimeSinceLastFalse,
CumulativeTimeSinceLastTrue,
)
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
find_applicable_primitives,
valid_dfs,
)
class TestCum... | 5,347 | 31.412121 | 80 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_percent_change.py | import numpy as np
import pandas as pd
from pytest import raises
from featuretools.primitives import PercentChange
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
find_applicable_primitives,
valid_dfs,
)
class TestPercentChange(PrimitiveTestBase):
primitive = PercentChange
... | 3,077 | 38.974026 | 81 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_distancetoholiday_primitive.py | from datetime import datetime
import holidays
import numpy as np
import pandas as pd
import pytest
from packaging.version import parse
from featuretools.primitives import DistanceToHoliday
def test_distanceholiday():
distance_to_holiday = DistanceToHoliday("New Year's Day")
dates = pd.Series(
[
... | 3,580 | 28.113821 | 88 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_postal_primitives.py | import pandas as pd
from featuretools.primitives.standard.transform.postal import (
OneDigitPostalCode,
TwoDigitPostalCode,
)
from featuretools.tests.testing_utils.es_utils import to_pandas
def test_one_digit_postal_code(postal_code_dataframe):
primitive = OneDigitPostalCode().get_function()
for x in... | 1,006 | 32.566667 | 73 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_expanding_primitives.py | import numpy as np
import pandas as pd
import pytest
from featuretools.primitives.standard.transform.time_series.expanding import (
ExpandingCount,
ExpandingMax,
ExpandingMean,
ExpandingMin,
ExpandingSTD,
ExpandingTrend,
)
from featuretools.primitives.standard.transform.time_series.utils import... | 6,255 | 27.053812 | 88 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_full_name_primitives.py | import numpy as np
import pandas as pd
from featuretools.primitives import (
FullNameToFirstName,
FullNameToLastName,
FullNameToTitle,
)
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
find_applicable_primitives,
valid_dfs,
)
class TestFullNameToFirstName(PrimitiveTe... | 6,951 | 35.208333 | 88 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_datetoholiday_primitive.py | from datetime import datetime
import numpy as np
import pandas as pd
import pytest
from featuretools.primitives import DateToHoliday
def test_datetoholiday():
date_to_holiday = DateToHoliday()
dates = pd.Series(
[
datetime(2016, 1, 1),
datetime(2016, 2, 27),
date... | 3,591 | 25.028986 | 81 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_savgol_filter.py | from math import floor
import numpy as np
import pandas as pd
from pytest import raises
from featuretools.primitives import SavgolFilter
from featuretools.tests.primitive_tests.utils import (
PrimitiveTestBase,
find_applicable_primitives,
valid_dfs,
)
class TestSavgolFilter(PrimitiveTestBase):
primi... | 7,200 | 25.09058 | 88 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_exponential_primitives.py | import numpy as np
import pandas as pd
from featuretools.primitives import (
ExponentialWeightedAverage,
ExponentialWeightedSTD,
ExponentialWeightedVariance,
)
def test_regular_com_avg():
primitive_instance = ExponentialWeightedAverage(com=0.5)
primitive_func = primitive_instance.get_function()
... | 7,700 | 33.846154 | 84 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_transform_primitive.py | from datetime import datetime
import numpy as np
import pandas as pd
import pytest
from pytz import timezone
from featuretools.primitives import (
Age,
DateToTimeZone,
DayOfYear,
DaysInMonth,
EmailAddressToDomain,
FileExtension,
IsFirstWeekOfMonth,
IsFreeEmailDomain,
IsLeapYear,
... | 37,994 | 31.810881 | 126 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_season.py | from datetime import datetime
import pandas as pd
from featuretools.primitives import Season
class TestSeason:
def test_regular(self):
primitive_instance = Season()
primitive_func = primitive_instance.get_function()
case = pd.date_range(start="2019-01", periods=12, freq="m").to_series()
... | 2,059 | 28.428571 | 79 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_is_federal_holiday.py | from datetime import datetime
import numpy as np
import pandas as pd
from pytest import raises
from featuretools.primitives import IsFederalHoliday
def test_regular():
primitive_instance = IsFederalHoliday()
primitive_func = primitive_instance.get_function()
case = pd.Series(
[
"2016... | 2,971 | 26.018182 | 67 | py |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/__init__.py | 0 | 0 | 0 | py | |
featuretools | featuretools-main/featuretools/tests/primitive_tests/transform_primitive_tests/test_same_as_previous.py | import numpy as np
import pandas as pd
import pytest
from featuretools.primitives import SameAsPrevious
class TestSameAsPrevious:
def test_ints(self):
primitive_func = SameAsPrevious().get_function()
array = pd.Series([1, 2, 2, 3, 2], dtype="int64")
answer = primitive_func(array)
... | 3,877 | 43.068182 | 87 | py |
featuretools | featuretools-main/featuretools/tests/integration_data/__init__.py | 0 | 0 | 0 | py | |
featuretools | featuretools-main/featuretools/tests/computational_backend/test_calculate_feature_matrix.py | import logging
import os
import re
import shutil
from datetime import datetime
from itertools import combinations
from random import randint
import numpy as np
import pandas as pd
import psutil
import pytest
from tqdm import tqdm
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import (
... | 87,223 | 33.530483 | 110 | py |
featuretools | featuretools-main/featuretools/tests/computational_backend/test_feature_set_calculator.py | from datetime import datetime
import numpy as np
import pandas as pd
import pytest
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Categorical, Datetime, Double, Integer
from featuretools import (
AggregationFeature,
EntitySet,
Feature,
Timedelta,
calculate_featu... | 38,668 | 28.837191 | 91 | py |
featuretools | featuretools-main/featuretools/tests/computational_backend/test_feature_set.py | from featuretools import (
AggregationFeature,
DirectFeature,
IdentityFeature,
TransformFeature,
primitives,
)
from featuretools.computational_backends.feature_set import FeatureSet
from featuretools.entityset.relationship import RelationshipPath
from featuretools.tests.testing_utils import backward... | 6,385 | 32.260417 | 88 | py |
featuretools | featuretools-main/featuretools/tests/computational_backend/__init__.py | 0 | 0 | 0 | py | |
featuretools | featuretools-main/featuretools/tests/computational_backend/test_dask_features.py | import pandas as pd
import pytest
from featuretools.tests.testing_utils import make_ecommerce_entityset
def test_tokenize_entityset(pd_es, pd_int_es):
pytest.importorskip("dask", reason="Dask not installed, skipping")
from dask.base import tokenize
dupe = make_ecommerce_entityset()
# check identitc... | 1,156 | 29.447368 | 70 | py |
featuretools | featuretools-main/featuretools/tests/computational_backend/test_utils.py | import numpy as np
from featuretools import dfs
from featuretools.computational_backends import replace_inf_values
from featuretools.primitives import DivideByFeature, DivideNumericScalar
from featuretools.tests.testing_utils import to_pandas
def test_replace_inf_values(divide_by_zero_es):
div_by_scalar = Divide... | 1,804 | 35.1 | 80 | py |
featuretools | featuretools-main/featuretools/tests/config_tests/test_config.py | from featuretools import config
def test_get_default_config_does_not_change():
old_config = config.get_all()
key = "primitive_data_folder"
value = "This is an example string"
config.set({key: value})
config.set_to_default()
assert config.get(key) != value
config.set(old_config)
def te... | 617 | 19.6 | 46 | py |
featuretools | featuretools-main/featuretools/tests/config_tests/__init__.py | 0 | 0 | 0 | py | |
featuretools | featuretools-main/featuretools/tests/selection/test_selection.py | import numpy as np
import pandas as pd
import pytest
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Boolean, BooleanNullable, NaturalLanguage
from featuretools import EntitySet, Feature, dfs
from featuretools.selection import (
remove_highly_correlated_features,
remove_highl... | 12,146 | 31.565684 | 102 | py |
featuretools | featuretools-main/featuretools/tests/selection/__init__.py | 0 | 0 | 0 | py | |
featuretools | featuretools-main/featuretools/tests/feature_discovery/test_convertors.py | from woodwork.logical_types import Double, NaturalLanguage
from featuretools.entityset.entityset import EntitySet
from featuretools.feature_base.feature_base import (
FeatureBase,
IdentityFeature,
TransformFeature,
)
from featuretools.feature_discovery.convertors import (
_convert_feature_to_featurebas... | 7,999 | 31.786885 | 85 | py |
featuretools | featuretools-main/featuretools/tests/feature_discovery/test_feature_discovery.py | from unittest.mock import patch
import pytest
from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import (
Boolean,
BooleanNullable,
Datetime,
Double,
NaturalLanguage,
Ordinal,
)
from featuretools.entityset.entityset import EntitySet
from featuretools.feature_discovery.... | 11,215 | 28.43832 | 103 | py |
featuretools | featuretools-main/featuretools/tests/feature_discovery/test_feature_collection.py | import pytest
from woodwork.logical_types import (
Boolean,
Double,
Ordinal,
)
from featuretools.feature_discovery.FeatureCollection import FeatureCollection
from featuretools.feature_discovery.LiteFeature import LiteFeature
from featuretools.primitives import Absolute, AddNumeric
@pytest.mark.parametriz... | 2,981 | 26.869159 | 79 | py |
featuretools | featuretools-main/featuretools/tests/feature_discovery/test_type_defs.py | import json
from unittest.mock import patch
import pytest
from woodwork.logical_types import Boolean, Double
from featuretools.feature_discovery.feature_discovery import (
generate_features_from_primitives,
schema_to_features,
)
from featuretools.feature_discovery.FeatureCollection import FeatureCollection
fr... | 12,240 | 26.384787 | 112 | py |
featuretools | featuretools-main/featuretools/computational_backends/feature_set_calculator.py | from datetime import datetime
from functools import partial
import numpy as np
import pandas as pd
import pandas.api.types as pdtypes
from featuretools.entityset.relationship import RelationshipPath
from featuretools.exceptions import UnknownFeature
from featuretools.feature_base import (
AggregationFeature,
... | 36,926 | 37.385655 | 121 | py |
featuretools | featuretools-main/featuretools/computational_backends/calculate_feature_matrix.py | import logging
import math
import os
import shutil
import time
import warnings
from datetime import datetime
import cloudpickle
import numpy as np
import pandas as pd
from woodwork.logical_types import (
Age,
AgeNullable,
Boolean,
BooleanNullable,
Integer,
IntegerNullable,
)
from featuretools.... | 39,008 | 38.244467 | 129 | py |
featuretools | featuretools-main/featuretools/computational_backends/utils.py | import logging
import os
import typing
import warnings
from datetime import datetime
from functools import wraps
import numpy as np
import pandas as pd
import psutil
from woodwork.logical_types import Datetime, Double
from featuretools.entityset.relationship import RelationshipPath
from featuretools.feature_base impo... | 15,370 | 36.038554 | 148 | py |
featuretools | featuretools-main/featuretools/computational_backends/api.py | # flake8: noqa
from featuretools.computational_backends.calculate_feature_matrix import (
approximate_features,
calculate_feature_matrix,
)
from featuretools.computational_backends.utils import (
bin_cutoff_times,
create_client_and_cluster,
replace_inf_values,
)
| 283 | 24.818182 | 74 | py |
featuretools | featuretools-main/featuretools/computational_backends/__init__.py | # flake8: noqa
from featuretools.computational_backends.api import *
| 69 | 22.333333 | 53 | py |
featuretools | featuretools-main/featuretools/computational_backends/feature_set.py | import itertools
import logging
from collections import defaultdict
from featuretools.entityset.relationship import RelationshipPath
from featuretools.feature_base import (
AggregationFeature,
FeatureOutputSlice,
GroupByTransformFeature,
TransformFeature,
)
from featuretools.utils import Trie
logger =... | 9,251 | 35.282353 | 103 | py |
featuretools | featuretools-main/featuretools/entityset/relationship.py | class Relationship(object):
"""Class to represent a relationship between dataframes
See Also:
:class:`.EntitySet`
"""
def __init__(
self,
entityset,
parent_dataframe_name,
parent_column_name,
child_dataframe_name,
child_column_name,
):
... | 6,709 | 31.259615 | 88 | py |
featuretools | featuretools-main/featuretools/entityset/timedelta.py | import pandas as pd
from dateutil.relativedelta import relativedelta
class Timedelta(object):
"""Represents differences in time.
Timedeltas can be defined in multiple units. Supported units:
- "ms" : milliseconds
- "s" : seconds
- "h" : hours
- "m" : minutes
- "d" : days
- "o"/"obser... | 6,575 | 30.018868 | 81 | py |
featuretools | featuretools-main/featuretools/entityset/deserialize.py | import json
import os
import tarfile
import tempfile
import pandas as pd
import woodwork.type_sys.type_system as ww_type_system
from woodwork.deserialize import read_woodwork_table
from featuretools.entityset.relationship import Relationship
from featuretools.utils.gen_utils import Library, import_or_none
from featur... | 6,508 | 35.774011 | 134 | py |
featuretools | featuretools-main/featuretools/entityset/api.py | # flake8: noqa
from featuretools.entityset.deserialize import read_entityset
from featuretools.entityset.entityset import EntitySet
from featuretools.entityset.relationship import Relationship
from featuretools.entityset.timedelta import Timedelta
| 248 | 40.5 | 61 | py |
featuretools | featuretools-main/featuretools/entityset/entityset.py | import copy
import logging
import warnings
from collections import defaultdict
import numpy as np
import pandas as pd
from woodwork import init_series
from woodwork.logical_types import Datetime, LatLong
from featuretools.entityset import deserialize, serialize
from featuretools.entityset.relationship import Relation... | 79,133 | 40.023328 | 137 | py |
featuretools | featuretools-main/featuretools/entityset/__init__.py | # flake8: noqa
from featuretools.entityset.api import *
| 56 | 18 | 40 | py |
featuretools | featuretools-main/featuretools/entityset/serialize.py | import datetime
import json
import os
import tarfile
import tempfile
from woodwork.serializers.serializer_base import typing_info_to_dict
from featuretools.utils.gen_utils import import_or_none
from featuretools.utils.s3_utils import get_transport_params, use_smartopen_es
from featuretools.utils.wrangle import _is_s3... | 3,558 | 34.237624 | 152 | py |
featuretools | featuretools-main/featuretools/demo/flight.py | import math
import re
import pandas as pd
from tqdm import tqdm
from woodwork.logical_types import Boolean, Categorical, Ordinal
import featuretools as ft
def load_flight(
month_filter=None,
categorical_filter=None,
nrows=None,
demo=True,
return_single_table=False,
verbose=False,
):
"""
... | 9,667 | 27.186589 | 120 | py |
featuretools | featuretools-main/featuretools/demo/weather.py | import pandas as pd
import featuretools as ft
def load_weather(nrows=None, return_single_table=False):
"""
Load the Australian daily-min-temperatures weather dataset.
Args:
nrows (int): Passed to nrows in ``pd.read_csv``.
return_single_table (bool): Exit the function early and return a ... | 923 | 22.1 | 87 | py |
featuretools | featuretools-main/featuretools/demo/mock_customer.py | import pandas as pd
from numpy import random
from numpy.random import choice
from woodwork.logical_types import Categorical, PostalCode
import featuretools as ft
def load_mock_customer(
n_customers=5,
n_products=5,
n_sessions=35,
n_transactions=500,
random_seed=0,
return_single_table=False,
... | 4,072 | 32.385246 | 88 | py |
featuretools | featuretools-main/featuretools/demo/api.py | # flake8: noqa
from featuretools.demo.flight import load_flight
from featuretools.demo.mock_customer import load_mock_customer
from featuretools.demo.retail import load_retail
from featuretools.demo.weather import load_weather
| 227 | 37 | 62 | py |
featuretools | featuretools-main/featuretools/demo/retail.py | import pandas as pd
from woodwork.logical_types import NaturalLanguage
import featuretools as ft
def load_retail(id="demo_retail_data", nrows=None, return_single_table=False):
"""Returns the retail entityset example.
The original dataset can be found `here <https://archive.ics.uci.edu/ml/datasets/online+reta... | 3,466 | 30.807339 | 109 | py |
featuretools | featuretools-main/featuretools/demo/__init__.py | # flake8: noqa
from featuretools.demo.api import *
| 51 | 16.333333 | 35 | py |
featuretools | featuretools-main/featuretools/feature_base/features_serializer.py | import json
from featuretools.primitives.utils import serialize_primitive
from featuretools.utils.s3_utils import get_transport_params, use_smartopen_features
from featuretools.utils.wrangle import _is_s3, _is_url
from featuretools.version import FEATURES_SCHEMA_VERSION
from featuretools.version import __version__ as ... | 6,035 | 39.24 | 128 | py |
featuretools | featuretools-main/featuretools/feature_base/utils.py | def is_valid_input(candidate, template):
"""Checks if a candidate schema should be considered a match for a template schema"""
if template.logical_type is not None and not isinstance(
candidate.logical_type,
type(template.logical_type),
):
return False
if len(template.semantic_ta... | 388 | 34.363636 | 89 | py |
featuretools | featuretools-main/featuretools/feature_base/features_deserializer.py | import json
from featuretools.entityset.deserialize import (
description_to_entityset as deserialize_es,
)
from featuretools.feature_base.feature_base import (
AggregationFeature,
DirectFeature,
Feature,
FeatureBase,
FeatureOutputSlice,
GroupByTransformFeature,
IdentityFeature,
Tran... | 5,377 | 35.337838 | 128 | py |
featuretools | featuretools-main/featuretools/feature_base/api.py | # flake8: noqa
from featuretools.feature_base.feature_base import (
AggregationFeature,
DirectFeature,
Feature,
FeatureBase,
FeatureOutputSlice,
GroupByTransformFeature,
IdentityFeature,
TransformFeature,
)
from featuretools.feature_base.feature_descriptions import describe_feature
from ... | 532 | 32.3125 | 75 | py |
featuretools | featuretools-main/featuretools/feature_base/feature_visualizer.py | import html
from featuretools.feature_base.feature_base import (
AggregationFeature,
DirectFeature,
FeatureOutputSlice,
IdentityFeature,
TransformFeature,
)
from featuretools.feature_base.feature_descriptions import describe_feature
from featuretools.utils.plot_utils import (
check_graphviz,
... | 9,889 | 33.701754 | 92 | py |
featuretools | featuretools-main/featuretools/feature_base/cache.py | """
cache.py
Custom caching class, currently used for FeatureBase
"""
# needed for defaultdict annotation if < python 3.9
from __future__ import annotations
from collections import defaultdict
from dataclasses import dataclass, field
from enum import Enum
from typing import Any, List, Optional, Union
class CacheTyp... | 1,617 | 24.28125 | 79 | py |
featuretools | featuretools-main/featuretools/feature_base/feature_base.py | from woodwork.column_schema import ColumnSchema
from woodwork.logical_types import Boolean, BooleanNullable
from featuretools import primitives
from featuretools.entityset.relationship import Relationship, RelationshipPath
from featuretools.entityset.timedelta import Timedelta
from featuretools.feature_base.utils impo... | 37,541 | 33.410632 | 139 | py |
featuretools | featuretools-main/featuretools/feature_base/__init__.py | # flake8: noqa
from featuretools.feature_base.api import *
| 59 | 19 | 43 | py |
featuretools | featuretools-main/featuretools/feature_base/feature_descriptions.py | import json
import featuretools as ft
def describe_feature(
feature,
feature_descriptions=None,
primitive_templates=None,
metadata_file=None,
):
"""Generates an English language description of a feature.
Args:
feature (FeatureBase) : Feature to describe
feature_descriptions (... | 6,827 | 34.195876 | 88 | py |
featuretools | featuretools-main/featuretools/utils/plot_utils.py | from featuretools.utils.gen_utils import import_or_raise
def check_graphviz():
GRAPHVIZ_ERR_MSG = (
"Please install graphviz to plot."
+ " (See https://featuretools.alteryx.com/en/stable/install.html#installing-graphviz for"
+ " details)"
)
graphviz = import_or_raise("graphviz", GR... | 2,248 | 37.775862 | 118 | py |
featuretools | featuretools-main/featuretools/utils/wrangle.py | import re
import tarfile
from datetime import datetime
import numpy as np
import pandas as pd
from woodwork.logical_types import Datetime, Ordinal
from featuretools.entityset.timedelta import Timedelta
def _check_timedelta(td):
"""
Convert strings to Timedelta objects
Allows for both shortform and longf... | 4,538 | 30.089041 | 111 | py |
featuretools | featuretools-main/featuretools/utils/gen_utils.py | import importlib
import logging
import re
import sys
from enum import Enum
from tqdm import tqdm
logger = logging.getLogger("featuretools.utils")
def make_tqdm_iterator(**kwargs):
options = {"file": sys.stdout, "leave": True}
options.update(kwargs)
return tqdm(**options)
def get_relationship_column_id... | 3,159 | 27.990826 | 100 | py |
featuretools | featuretools-main/featuretools/utils/description_utils.py | def convert_to_nth(integer):
string_nth = str(integer)
end_int = integer % 10
if end_int == 1 and integer % 100 != 11:
return str(integer) + "st"
elif end_int == 2 and integer % 100 != 12:
return str(string_nth) + "nd"
elif end_int == 3 and integer % 100 != 13:
return str(str... | 384 | 31.083333 | 46 | py |
featuretools | featuretools-main/featuretools/utils/schema_utils.py | import logging
import warnings
from packaging.version import parse
from featuretools.version import ENTITYSET_SCHEMA_VERSION, FEATURES_SCHEMA_VERSION
logger = logging.getLogger("featuretools.utils")
def check_schema_version(cls, cls_type):
"""
If the saved schema version is newer than the current featureto... | 1,684 | 34.851064 | 82 | py |
featuretools | featuretools-main/featuretools/utils/s3_utils.py | import json
import shutil
from featuretools.utils.gen_utils import import_or_raise
def use_smartopen_es(file_path, path, transport_params=None, read=True):
open = import_or_raise("smart_open", SMART_OPEN_ERR_MSG).open
if read:
with open(path, "rb", transport_params=transport_params) as fin:
... | 2,451 | 35.058824 | 87 | py |
featuretools | featuretools-main/featuretools/utils/utils_info.py | import locale
import os
import platform
import struct
import sys
import pkg_resources
import featuretools
deps = [
"numpy",
"pandas",
"tqdm",
"cloudpickle",
"dask",
"distributed",
"psutil",
"pip",
"setuptools",
]
def show_info():
print("Featuretools version: %s" % featuretoo... | 2,483 | 26.296703 | 119 | py |
featuretools | featuretools-main/featuretools/utils/recommend_primitives.py | import logging
from typing import List
from featuretools.computational_backends import calculate_feature_matrix
from featuretools.entityset import EntitySet
from featuretools.primitives.utils import get_transform_primitives
from featuretools.synthesis import dfs, get_valid_primitives
ORDERED_PRIMITIVES = (
[ # n... | 9,941 | 38.927711 | 210 | py |
featuretools | featuretools-main/featuretools/utils/api.py | # flake8: noqa
from featuretools.utils.entry_point import entry_point
from featuretools.utils.gen_utils import make_tqdm_iterator
from featuretools.utils.time_utils import (
calculate_trend,
convert_time_units,
make_temporal_cutoffs,
)
from featuretools.utils.trie import Trie
from featuretools.utils.utils_i... | 423 | 25.5 | 59 | py |
featuretools | featuretools-main/featuretools/utils/spark_utils.py | import pandas as pd
def replace_tuple_columns(pdf):
new_df = pd.DataFrame()
for c in pdf.columns:
if isinstance(pdf[c].iloc[0], tuple):
new_df[c] = pdf[c].map(lambda x: list(x) if isinstance(x, tuple) else x)
else:
new_df[c] = pdf[c]
return new_df
def replace_nan_... | 1,228 | 23.58 | 87 | py |
featuretools | featuretools-main/featuretools/utils/entry_point.py | import time
from functools import wraps
from inspect import signature
import pkg_resources
def entry_point(name):
def inner_function(func):
@wraps(func)
def function_wrapper(*args, **kwargs):
"""function_wrapper of greeting"""
# add positional args as named kwargs
... | 1,551 | 30.04 | 72 | py |
featuretools | featuretools-main/featuretools/utils/trie.py | class Trie(object):
"""
A trie (prefix tree) where the keys are sequences of hashable objects.
It behaves similarly to a dictionary, except that the keys can be lists or
other sequences.
Examples:
>>> from featuretools.utils import Trie
>>> trie = Trie(default=str)
>>> # Se... | 3,381 | 30.607477 | 79 | py |
featuretools | featuretools-main/featuretools/utils/time_utils.py | from datetime import datetime, timedelta
import numpy as np
import pandas as pd
def make_temporal_cutoffs(
instance_ids,
cutoffs,
window_size=None,
num_windows=None,
start=None,
):
"""Makes a set of equally spaced cutoff times prior to a set of input cutoffs and instance ids.
If window_s... | 4,766 | 33.05 | 108 | py |
featuretools | featuretools-main/featuretools/utils/__init__.py | # flake8: noqa
from featuretools.utils.api import *
| 52 | 16.666667 | 36 | py |
featuretools | featuretools-main/featuretools/utils/common_tld_utils.py | # put longer TLDs first to avoid catching a small part of a longer TLD and escape periods
COMMON_TLDS = [
"management",
"technology",
"solutions",
"delivery",
"services",
"software",
"digital",
"finance",
"monster",
"network",
"support",
"systems",
"website",
"age... | 2,861 | 10.312253 | 89 | py |
featuretools | featuretools-main/featuretools/primitives/options_utils.py | import logging
import warnings
from itertools import permutations
from featuretools import primitives
from featuretools.feature_base import IdentityFeature
logger = logging.getLogger("featuretools")
def _get_primitive_options():
# all possible option keys: function that verifies value type
return {
... | 12,514 | 38.355346 | 104 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.