<jupyter_start><jupyter_text>Task 1  1a<jupyter_code>model_1a = pickle.load(open(r"saved_models\cat_1a.sav", 'rb'))
print(os.listdir(work_dir + r"\1\Testing")[0])
float(os.listdir(work_dir + r"\1\Testing")[0][0] + "." + os.listdir(work_dir + r"\1\Testing")[0][2:4])
# Predict 1a
for file in os.listdir(work_dir + r"\1\Testing")[:-1]:
    df_temp = pd.read_csv(work_dir + f"\\1\\Testing\\{file}").drop(["Unnamed: 4"], axis=1)
    df_temp["power"] = float(file[-8:-5])
    df_temp["speed"] = float(file[0] + "." + file[2:4])
    y_pred_temp = model_1a.predict(df_temp)
    df_temp["Temp"] = y_pred_temp
    df_temp.drop(["power", "speed"], axis=1, inplace=True)
    df_temp.to_csv(work_dir + f"\\1\\Testing\\{file}", index=False)<jupyter_output><empty_output><jupyter_text>1b<jupyter_code># fuse csv for 1b
df_full = pd.DataFrame()
for file in os.listdir(work_dir + r"\1\Testing")[:-1]:
    df_temp = pd.read_csv(work_dir + f"\\1\\Testing\\{file}")
    df_temp["power"] = float(file[-8:-5])
    df_temp["speed"] = float(file[0] + "." + file[2:4])
    df_full = pd.concat([df_full, df_temp])
print(df_full.shape)
df_full.head()
model_1b_depth = pickle.load(open(r"saved_models\cat_1b_depth.sav", 'rb'))
model_1b_width = pickle.load(open(r"saved_models\cat_1b_width.sav", 'rb'))
model_1b_length = pickle.load(open(r"saved_models\cat_1b_length.sav", 'rb'))
X_test = pd.read_csv(work_dir + r"/1/Testing/Melt_Pool_Dimensions.csv")
# merge to 1b test
X_test_full = pd.merge(df_full, X_test, how='left', left_on=['speed','power'], 
                  right_on = ['Laser_Speed','Laser_Power'])
X_test_to_pred = X_test_full.drop(["Melt_Pool_Length", "Melt_Pool_Width", "Melt_Pool_Depth"], axis=1)
y_test_pred_depth = model_1b_depth.predict(X_test_to_pred)
y_test_pred_width = model_1b_width.predict(X_test_to_pred)
y_test_pred_length = model_1b_length.predict(X_test_to_pred)
X_test_full["Melt_Pool_Length"] = y_test_pred_length
X_test_full["Melt_Pool_Width"] = y_test_pred_width
X_test_full["Melt_Pool_Depth"] = y_test_pred_depth
df_1b_write = pd.DataFrame(X_test_full.groupby(["Laser_Speed", "Laser_Power"])["Melt_Pool_Length", "Melt_Pool_Width", "Melt_Pool_Depth"].mean()).reset_index()
df_1b_write.to_csv(work_dir + "\\1\\Testing\\Melt_Pool_Dimensions.csv", index=False)<jupyter_output><empty_output><jupyter_text>Task 2  2a<jupyter_code>model_2a = pickle.load(open(r"saved_models\cat_900_0.07_14.sav", 'rb'))
print(os.listdir(work_dir + r"\2\Testing")[:-1])
print(os.listdir(work_dir + r"\2\Testing")[0])
file = os.listdir(work_dir + r"\2\Testing")[0]
file[7:10]
for file in os.listdir(work_dir + r"\2\Testing")[:-1]:
    df_temp = pd.read_csv(work_dir + f"\\2\\Testing\\{file}").drop(['Temp'], axis=1)
    df_temp["LasAngle"] = float(file[-9:-7])
    df_temp["LasPower"] = float(file[7:10])
    df_temp["LasSpeed"] = float(file[0] + "." + file[2:4])
    y_pred_temp = model_2a.predict(df_temp)
    df_temp["Temp"] = y_pred_temp
    df_temp.drop(["LasPower", "LasSpeed", "LasAngle"], axis=1, inplace=True)
    df_temp.to_csv(work_dir + f"\\2\\Testing\\{file}", index=False)
# Predict 2a
for file in os.listdir(work_dir + r"\2\Testing")[:-1]:
    df_temp = pd.read_csv(work_dir + f"\\2\\Testing\\{file}").drop(['Temp'], axis=1)
    df_temp["LasAngle"] = float(file[-9:-7])
    df_temp["LasPower"] = float(file[7:10])
    df_temp["LasSpeed"] = float(file[0] + "." + file[2:4])
    y_pred_temp = model_2a.predict(df_temp)
    df_temp["Temp"] = y_pred_temp
    df_temp.drop(["LasPower", "LasSpeed", "LasAngle"], axis=1, inplace=True)
    df_temp.to_csv(work_dir + f"\\2\\Testing\\{file}", index=False)<jupyter_output><empty_output><jupyter_text>2b<jupyter_code>model_2b_depth = pickle.load(open(r"saved_models\cat_2b_depth.sav", 'rb'))
model_2b_width = pickle.load(open(r"saved_models\cat_2b_width.sav", 'rb'))
model_2b_length = pickle.load(open(r"saved_models\cat_2b_length.sav", 'rb'))
X_2_test = pd.read_csv(work_dir + r"/2/Testing/Melt_Pool_Dimensions.csv")
X_2_test.head()
y_2_test_pred_depth = model_2b_depth.predict(X_2_test)
y_2_test_pred_width = model_2b_width.predict(X_2_test)
y_2_test_pred_length = model_2b_length.predict(X_2_test)
    X_2_test["Melt_Pool_Length"] = y_2_test_pred_length
    X_2_test["Melt_Pool_Width"] = y_2_test_pred_width
    X_2_test["Melt_Pool_Depth"] = y_2_test_pred_depth
    X_2_test.to_csv(work_dir + "\\2\\Testing\\Melt_Pool_Dimensions.csv", index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18694765465669613, 'fraction_numerical': 0.029458418309539994, 'mean_word_length': 6.177235772357723, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '94822', 'license': 'MIT', 'n_tokens_mistral': 1938, 'n_tokens_neox': 1885, 'n_words': 208, 'path': 'src/Predict.ipynb', 'repo_name': 'zysophia/3DPrintingPrediction_2020BrownDatathon', 'size': '4413'}