diff --git a/examples/algebraic_constraints.py b/examples/algebraic_constraints.py index b2481bf517..d8a2554cd1 100644 --- a/examples/algebraic_constraints.py +++ b/examples/algebraic_constraints.py @@ -1,17 +1,19 @@ import desbordante import pandas import operator +from datetime import datetime -TABLE = 'examples/datasets/cargo_march.csv' +# Note that dates in the given dataset must be in the format Y-M-D +TABLE = 'examples/datasets/ACShippingDates.csv' HEADER = 0 SEPARATOR = ',' -P_FUZZ = 0.85 -FUZZINESS = 0.2 +P_FUZZ = 0.7 +FUZZINESS = 0.3 BUMPS_LIMIT = 0 WEIGHT = 0.1 BIN_OPERATION = '-' AC_SEED = 11 -ITERATIONS_LIMIT = 4 +ITERATIONS_LIMIT = 10 OPERATIONS = { '+': (operator.add, 'Sum'), '-': (operator.sub, 'Difference'), @@ -23,7 +25,7 @@ algo = desbordante.ACAlgorithm() df = pandas.read_csv(TABLE, sep=SEPARATOR, header=HEADER) -df_without_id = df[['Delivery date', 'Dispatch date']] +df_without_id = df[['deliveryDate', 'shipDate']] algo.load_data(df=df_without_id) @@ -33,7 +35,7 @@ ac_ranges = algo.get_ac_ranges() for ac_range in ac_ranges: l_col = df_without_id.columns[ac_range.column_indices[0]] - r_col = df_without_id.columns[ac_range.column_indices[1]] + r_col = df_without_id.columns[ac_range.column_indices[1]] print(f'Discovered ranges for ({l_col} {BIN_OPERATION} {r_col}) are:') print(ac_range.ranges) @@ -41,10 +43,12 @@ print() print(f'Rows in which the result of the chosen operation ({BIN_OPERATION}) is outside of discovered ranges:') for ac_exception in ac_exceptions: - id, delivery_date, dispatch_date = df.iloc[ac_exception.row_index] + id, delievery_date, ship_date = df.iloc[ac_exception.row_index] print(f'id: {id}') - print(f'Dispatch date: {dispatch_date}') - print(f'Delivery date: {delivery_date}') - print(f'{operation_name}: {operation(delivery_date, dispatch_date)}') + print(f'Shipping date : {ship_date}') + print(f'Delivery date: {delievery_date}') + date1 = datetime.strptime(ship_date, '%Y-%m-%d').date() + date2 = datetime.strptime(delievery_date, '%Y-%m-%d').date() + print(f'{operation_name}: {operation(date2, date1).days}') print()