예제 #1
0
def association_rule(table, group_by=None, **params):
    check_required_parameters(_association_rule, params, ['table'])
    params = get_default_from_parameters_if_required(params, _association_rule)
    param_validation_check = [from_to(params, 0, 1, 'min_support'),
                              from_to(params, 0, 1, 'min_confidence')]
        
    validate(*param_validation_check)
    if group_by is not None:
        return _function_by_group(_association_rule, table, group_by=group_by, **params)
    else:
        return _association_rule(table, **params)
def decision_tree_classification_train(table, group_by=None, **params):
    check_required_parameters(_decision_tree_classification_train, params,
                              ['table'])

    params = get_default_from_parameters_if_required(
        params, _decision_tree_classification_train)

    param_validation_check = [
        greater_than_or_equal_to(params, 2, 'min_samples_split'),
        greater_than_or_equal_to(params, 1, 'min_samples_leaf'),
        from_to(params, 0.0, 0.5, 'min_weight_fraction_leaf'),
        greater_than_or_equal_to(params, 0.0, 'min_impurity_decrease'),
        greater_than_or_equal_to(params, 1, 'max_depth'),
        greater_than_or_equal_to(params, 1, 'max_features'),
        greater_than(params, 1, 'max_leaf_nodes')
    ]

    validate(*param_validation_check)

    if group_by is not None:
        grouped_model = _function_by_group(_decision_tree_classification_train,
                                           table,
                                           group_by=group_by,
                                           **params)
        return grouped_model
    else:
        return _decision_tree_classification_train(table, **params)
예제 #3
0
def ngram(table, **params):  # to be deprecated
    check_required_parameters(_ngram, params, ['table'])
    params = get_default_from_parameters_if_required(params, _ngram)

    max_len = np.max(np.vectorize(len)(table[params["input_col"]])).item()
    param_validation_check = [from_to(params, 1, max_len, 'n')]

    validate(*param_validation_check)
    return _ngram(table, **params)
예제 #4
0
파일: ttest.py 프로젝트: steelblu/studio
def paired_ttest(table, group_by=None, **params):
    check_required_parameters(_paired_ttest, params, ['table'])
    params = get_default_from_parameters_if_required(params, _paired_ttest)
    param_validation_check = [from_to(params, 0, 1, 'confidence_level')]
    validate(*param_validation_check)
    if group_by is not None:
        return _function_by_group(_paired_ttest, table, group_by=group_by, **params)
    else:
        return _paired_ttest(table, **params)
예제 #5
0
파일: ttest.py 프로젝트: steelblu/studio
def two_sample_ttest_for_stacked_data(table, group_by=None, **params):
    params = get_default_from_parameters_if_required(params, _two_sample_ttest_for_stacked_data)
    param_validation_check = [from_to(params, 0, 1, 'confi_level')]
        
    validate(*param_validation_check)
    check_required_parameters(_two_sample_ttest_for_stacked_data, params, ['table'])
    if group_by is not None:
        return _function_by_group(_two_sample_ttest_for_stacked_data, table, group_by=group_by, **params)
    else:
        return _two_sample_ttest_for_stacked_data(table, **params)
예제 #6
0
def tsne(table, group_by=None, **params):
    check_required_parameters(_tsne, params, ['table'])
    params = get_default_from_parameters_if_required(params, _tsne)
    param_validation_check = [from_to(params, 1, len(params['input_cols']), 'n_components')]
    validate(*param_validation_check)
    if group_by is not None:
        grouped_model = _function_by_group(_tsne, table, group_by=group_by, **params)
        return grouped_model
    else:
        return _tsne(table, **params)
예제 #7
0
def ewma(table, group_by=None, **params):
    check_required_parameters(_ewma, params, ['table'])
    params = get_default_from_parameters_if_required(params,_ewma)
    param_validation_check = [greater_than_or_equal_to(params, 1, 'period_number'),
                              from_to(params, 0, 1, 'custom_ratio')]
    validate(*param_validation_check)
    if group_by is not None:
        return _function_by_group(_ewma, table, group_by=group_by, **params)
    else:
        return _ewma(table, **params)
예제 #8
0
파일: lda.py 프로젝트: ymorzart/studio
def lda(table, group_by=None, **params):
    check_required_parameters(_lda, params, ['table'])
    params = get_default_from_parameters_if_required(params, _lda)
    param_validation_check = [greater_than_or_equal_to(params, 2, 'num_voca'),
                              greater_than_or_equal_to(params, 2, 'num_topic'),
                              from_to(params, 2, params['num_voca'], 'num_topic_word'),
                              greater_than_or_equal_to(params, 1, 'max_iter'),
                              greater_than(params, 1.0, 'learning_offset')]
    
    validate(*param_validation_check)
    if group_by is not None:
        return _function_by_group(_lda, table, group_by=group_by, **params)
    else:
        return _lda(table, **params)
예제 #9
0
def holt_winters_train(table, group_by=None, **params):
    len_table = len(table)
    check_required_parameters(_holt_winters_train, params, ['table'])
    params = get_default_from_parameters_if_required(params,
                                                     _holt_winters_train)
    param_validation_check = [from_to(params, 2, (len_table) // 2, 'period')]
    validate(*param_validation_check)
    if group_by is not None:
        return _function_by_group(_holt_winters_train,
                                  table,
                                  group_by=group_by,
                                  **params)
    else:
        return _holt_winters_train(table, **params)
예제 #10
0
def arima_train(table, group_by=None, **params):
    check_required_parameters(_arima_train, params, ['table'])
    params = get_default_from_parameters_if_required(params, _arima_train)
    param_validation_check = [
        greater_than_or_equal_to(params, 0, 'p'),
        from_to(params, 0, 2, 'd'),
        greater_than_or_equal_to(params, 0, 'q')
    ]
    validate(*param_validation_check)
    if group_by is not None:
        return _function_by_group(_arima_train,
                                  table,
                                  group_by=group_by,
                                  **params)
    else:
        return _arima_train(table, **params)
예제 #11
0
def split_data(table, group_by=None, **params):
    params = get_default_from_parameters_if_required(params, _split_data)
    param_validation_check = [
        greater_than(params, 0.0, 'train_ratio'),
        greater_than(params, 0.0, 'test_ratio'),
        from_to(params, 0, 2**30, 'random_state')
    ]

    validate(*param_validation_check)
    check_required_parameters(_split_data, params, ['table'])
    if group_by is not None:
        return _function_by_group(_split_data,
                                  table,
                                  group_by=group_by,
                                  **params)
    else:
        return _split_data(table, **params)
예제 #12
0
def penalized_linear_regression_train(table, group_by=None, **params):
    check_required_parameters(_penalized_linear_regression_train, params,
                              ['table'])
    params = get_default_from_parameters_if_required(
        params, _penalized_linear_regression_train)
    param_validation_check = [
        greater_than_or_equal_to(params, 0.0, 'alpha'),
        from_to(params, 0.0, 1.0, 'l1_ratio'),
        greater_than_or_equal_to(params, 1, 'max_iter'),
        greater_than(params, 0.0, 'tol')
    ]
    validate(*param_validation_check)
    if group_by is not None:
        grouped_model = _function_by_group(_penalized_linear_regression_train,
                                           table,
                                           group_by=group_by,
                                           **params)
        return grouped_model
    else:
        return _penalized_linear_regression_train(table, **params)