# in this case we link to the directory containing the preprocessing package import sys from os.path import dirname sys.path.append( dirname("/Users/dominiquepaul/xCoding/classification_tool/Main/")) sys.path.append( dirname("/Users/dominiquepaul/xCoding/classification_tool/Main/modules/")) from regressionclass import Logistic_regression, Lasso_regression from label_interpretation import load_industry_labels, create_feature_df import pandas as pd import numpy as np OBJECT_NAME = "apparel" industry_labels = load_industry_labels( file_path="../industry_dicts/selection_ApparelAccessoriesandLuxuryGoods.csv" ) # instantiate a new empty logistic regression model log_reg2 = Logistic_regression() # load the previously saved model from our disk log_reg2.load_model("./example_output_folder/Logistic_regression_model.pkl") new_images, names = np.load( "./example_output_folder/unlabelled_data_image_package_no_labels_0.npy") # load the new data x_test_df = create_feature_df(imgs=new_images, object_name=OBJECT_NAME, ind_labels=industry_labels, k_labels=10,
# option 1 for loading other modules # this doesnt work when run in a REPL environment main_path = os.path.dirname(__file__) module_path = os.path.join(main_path, "modules/") sys.path.append(dirname(module_path)) ### an alternative menthod for handling file paths is by using the absolute path ### # sys.path.append(dirname("/Users/dominiquepaul/xCoding/classification_tool/Main/modules/")) from regressionclass import Logistic_regression, Lasso_regression # folder where different label evaluations are saved FOLDER_PATH_SAVE = "../Data/wnet_hyperopt_datasets" # path with the industry dict folders ind_labels = load_industry_labels( file_path="./industry_dicts/selection_AutomobileManufacturers.csv") OBJECT = "car" automotive_pckgs = ["../Data/np_files/car_image_package_train_test_split0.npy"] x_train, y_train, x_test, y_test, conversion = join_npy_data(automotive_pckgs) n_label_list = [3, 5, 8, 10, 15, 20, 25, 50] # transform or load the data if necessary for label_amount in tqdm(n_label_list): x_train_df = create_feature_df(imgs=x_train, object_name=OBJECT, ind_labels=ind_labels, k_labels=label_amount) x_test_df = create_feature_df(imgs=x_test, object_name=OBJECT,
object_name=object_name, method_type="oob_network_eval", data_type=data_type, augmented=augmented) ################################################################################ ########################### Run through all tests ############################## ################################################################################ EVAL_OUT_FILE = './out_files/master_out.csv' PREDICTIONS_MASTER_OUT_FILE = './out_files/master_predictions.csv' OBJECT_NAME = "food" DATA_FOLDER_PATH = "../Data" ind_labels = load_industry_labels( file_path="./industry_dicts/selection_PackagedFoodsandMeats.csv") x_test, y_test, names, _ = np.load( os.path.join(DATA_FOLDER_PATH, "np_files_final/food_final_testing_dataset.npy")) x_test_df_20 = create_feature_df(imgs=x_test, object_name=OBJECT_NAME, ind_labels=ind_labels, k_labels=20) x_test_df_50 = create_feature_df(imgs=x_test, object_name=OBJECT_NAME, ind_labels=ind_labels, k_labels=50) ALL_PREDICTIONS_DF = pd.DataFrame({"names": names})