Ejemplo n.º 1
0
def test_1():
    """
    Tests that the match factor for a known learning set and test case is close to the known value

    """

    script_dir = os.path.dirname(__file__)
    file1 = os.path.join(script_dir, '../assets/bladeCombined.csv')

    store_data, records = get_data(file1)

    conf_results, results = find_associations(store_data,
                                              records,
                                              support=0.0003,
                                              confidence=0.01,
                                              lift=0.1)

    thresh_results = get_top_results(conf_results, 0.7)

    test_file = os.path.join(script_dir, '../assets/jigsawQuery.csv')

    test_data, test_records = get_data(test_file)

    learned_dict, matched, overmatched, unmatched, match_factor = match(
        thresh_results, test_records)

    assert np.allclose(0.82051, match_factor)
def test_1():
    """
    For this particular .csv file, check to make sure the first component is ic motor
    """

    script_dir = os.path.dirname(__file__)
    file = os.path.join(script_dir, '../assets/bladeQueryClean.csv')

    assert get_data(file)[0][0][0] == 'ic motor'
def test_3():
    """
    For this particular .csv file, check to make sure the last component is positioner
    """

    script_dir = os.path.dirname(__file__)
    file = os.path.join(script_dir, '../assets/bladeQueryClean.csv')

    assert get_data(file)[0][0][89] == 'positioner'
def test_2():
    """
    For this particular .csv file, check to make sure the first function-flow is convert chemical
    """

    script_dir = os.path.dirname(__file__)
    file = os.path.join(script_dir, '../assets/bladeQueryClean.csv')

    assert get_data(file)[0][1][0] == 'convert chemical'
def test_2():

    """
    Testing that the results for the component screw have all three factors: support, confidence, lift
    """

    script_dir = os.path.dirname(__file__)
    file1 = os.path.join(script_dir, '../assets/bladeCombined.csv')

    store_data, records = get_data(file1)

    conf_results, results = find_associations(store_data, records, support=0.0003, confidence=0.01, lift=0.1)

    assert len(results['screw']) == 3
def test_1():
    """
    Tests that the top function-flow combination for the component "screw" is "couple solid"
    """

    script_dir = os.path.dirname(__file__)
    file1 = os.path.join(script_dir, '../assets/bladeCombined.csv')

    store_data, records = get_data(file1)

    conf_results, results = find_associations(store_data, records)

    thresh_results = get_top_results(conf_results, 0.7)

    assert thresh_results['screw'][0][0] == 'couple solid'
def test_2():
    """
    Tests that the top 70% of function-flow combinations for the component "screw" only has one result
    """

    script_dir = os.path.dirname(__file__)
    file1 = os.path.join(script_dir, '../assets/bladeCombined.csv')

    store_data, records = get_data(file1)

    conf_results, results = find_associations(store_data, records)

    thresh_results = get_top_results(conf_results, 0.7)

    assert len(thresh_results['screw']) == 1
def test_1():

    """
    Testing that the highest confidence result for the screw component is couple solid, which is what
    a screw does almost exclusively
    """

    script_dir = os.path.dirname(__file__)
    file1 = os.path.join(script_dir, '../assets/bladeCombined.csv')

    store_data, records = get_data(file1)

    conf_results, results = find_associations(store_data,records)

    assert conf_results['screw'][0][0] == 'couple solid'
Ejemplo n.º 9
0
from autofunc.get_match_factor import match
from autofunc.simple_counter import count_stuff
from autofunc.get_top_results import get_top_results
from autofunc.get_data import get_data
import os.path
""" Example showing how to find the match factor using the simple counting file """

# Dataset used for data mining
script_dir = os.path.dirname(__file__)
file1 = os.path.join(script_dir, '../assets/bladeCombined.csv')

comb_sort = count_stuff(file1)

# Use a threshold to get the top XX% of confidence values
threshold = 0.69
thresh_results = get_top_results(comb_sort, threshold)

# Use a known product for verification
test_file = os.path.join(script_dir, '../assets/jigsawQuery.csv')

test_data, test_records = get_data(test_file)

# Find the match factor of the verification test by comparing the learned results with the known function/flows
learned_dict, matched, overmatched, unmatched, match_factor = match(
    thresh_results, test_records)

print('Match factor = {0:.5f}'.format(match_factor))
Ejemplo n.º 10
0
from autofunc.get_match_factor import match
from autofunc.get_top_results import get_top_results
from autofunc.find_associations import find_associations
from autofunc.get_data import get_data
import os.path
""" Example showing how to find the match factor using association rules """

# Dataset used for data mining
script_dir = os.path.dirname(__file__)
file1 = os.path.join(script_dir, '../assets/bladeCombined.csv')

# Convert file to data frame and list
store_data, records = get_data(file1)

# Use Association Rules to sort the functions/flows of components by confidence
conf_results, results = find_associations(store_data, records)

# Use a threshold to get the top XX% of confidence values
thresh_results = get_top_results(conf_results, 0.7)

# Use a known product for verification
test_file = os.path.join(script_dir, '../assets/jigsawQuery.csv')

test_data, test_records = get_data(test_file)

# Find the match factor of the verification test by comparing the learned results with the known function/flows
learned_dict, matched, overmatched, unmatched, match_factor = match(
    thresh_results, test_records)

print('Match factor = {0:.5f}'.format(match_factor))