Skip to content

Commit

Permalink
example_script.py updated to include returning a prediction of kappa …
Browse files Browse the repository at this point in the history
…in a DataFrame output
  • Loading branch information
SpaceMeerkat committed May 17, 2019
1 parent 7756930 commit e5a883a
Show file tree
Hide file tree
Showing 8 changed files with 196 additions and 173 deletions.
Binary file added Kinematics_Tester_Files/PCA_routine.pkl
Binary file not shown.
Binary file modified Kinematics_Tester_Files/__pycache__/config.cpython-37.pyc
Binary file not shown.
Binary file not shown.
4 changes: 3 additions & 1 deletion Kinematics_Tester_Files/config.py
Expand Up @@ -25,7 +25,9 @@

DATA_PATH = '../Test_FITS_files/'
MODEL_PATH = 'CAE_Epoch_300.pt'
SAVE_PATH = '../'
SAVE_PATH = '../Results/'
PCA_PATH = 'PCA_routine.pkl'
BOUNDARY = 2.960960960960961

#=============================================================================#
#/// END OF SCRIPT ///////////////////////////////////////////////////////#
Expand Down
31 changes: 26 additions & 5 deletions Kinematics_Tester_Files/example_script.py
Expand Up @@ -59,15 +59,36 @@
#/////////////////////////////////////////////////////////////////////////////#
#=============================================================================#

""" Optional: Store the results as a DataFrame and pickle """
""" Load the PCA routine and transform the 3D latent data for making
predictions of circularity """

with open(PCA_PATH, 'rb') as file:
PCA_model = pickle.load(file)

pca_test_data = PCA_model.transform(all_features)

#=============================================================================#
#/////////////////////////////////////////////////////////////////////////////#
#=============================================================================#

""" Get a circularity prediction from the 3D latent positions """

df_data = np.vstack([all_names,all_features.T]).T
latent_x = np.sqrt((pca_test_data[:,0]**2)+(pca_test_data[:,1]**2))
latent_y = np.abs(pca_test_data[:,2])
classifications = np.ones(len(latent_x))
zero_indices = np.where(latent_x<BOUNDARY)[0]
classifications[zero_indices] = 0

#=============================================================================#
#/////////////////////////////////////////////////////////////////////////////#
#=============================================================================#

""" Optional: Store the results as a DataFrame and pickle """

df_data = np.vstack([all_names,all_features.T,classifications]).T
results = pd.DataFrame(df_data)
results.columns = ['Name','L1','L2','L3']
results.columns = ['Name','L1','L2','L3','Circularity']
results.set_index(keys='Name',drop=True,inplace=True)

_save_path = '/home/user/Documents/results/'
results.to_pickle(os.path.join(SAVE_PATH,'CAE_results.pkl'))

#=============================================================================#
Expand Down

0 comments on commit e5a883a

Please sign in to comment.