How to use the matminer.utils.io.store_dataframe_as_json function in matminer

To help you get started, we’ve selected a few matminer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hackingmaterials / automatminer / automatminer_dev / matbench / glass.py View on Github external
new_df_dict["composition"].append(c)
    new_df_dict["gfa"].append(gfa)

df_new = pd.DataFrame(new_df_dict)
df_new = df_new.sort_values(by="composition")
df_new = df_new.reset_index(drop=True)

# convert to bools
df_new["gfa"] = df_new["gfa"] == 1


print(df_new)
print(df_new["gfa"].value_counts())
print(f"Problem compositions: {problem_compositions}")

store_dataframe_as_json(df_new, "glass.json.gz", compression="gz")
github hackingmaterials / automatminer / automatminer_dev / matbench / expt_is_metal.py View on Github external
elif not all_metals and not any_metals:
        print(f"No metals: {c}")
        is_metal = 0
    elif all_metals and not any_metals:
        raise ValueError("Impossible combination of metals.")

    new_df_dict["composition"].append(c)
    new_df_dict["is_metal"].append(is_metal)

df_new = pd.DataFrame(new_df_dict)
df_new = df_new.sort_values(by="composition")
df_new = df_new.reset_index(drop=True)

df_new["is_metal"] = df_new["is_metal"] == 1

store_dataframe_as_json(df_new, "expt_is_metal.json.gz", compression="gz")

print(df_new)
print(df_new["is_metal"].value_counts())
print(f"Problem compositions: {problem_compositions}")
github hackingmaterials / automatminer / automatminer / featurization / core.py View on Github external
if self.functionalize:
                ff = FunctionFeaturizer()
                ff.set_n_jobs(self.n_jobs)
                cols = df.columns.tolist()
                for ft in self.featurizers.keys():
                    if ft in cols:
                        cols.pop(ft)
                df = ff.fit_featurize_dataframe(
                    df,
                    cols,
                    ignore_errors=self.ignore_errors,
                    multiindex=self.multiindex,
                    inplace=False,
                )
            if self.cache_src and not os.path.exists(self.cache_src):
                store_dataframe_as_json(df, self.cache_src)
            return df
github hackingmaterials / automatminer / automatminer_dev / workflows / single.py View on Github external
def transfer_data(df, worker, now):
    this_dir = os.path.dirname(os.path.abspath(__file__))
    user_folder = os.path.join(this_dir, "user_dfs")
    if not os.path.exists(user_folder):
        os.makedirs(user_folder)
    filename = "user_df_" + now + ".json"
    filepath = os.path.join(user_folder, filename)
    store_dataframe_as_json(df, filepath)

    if worker != "local":
        if worker == "cori":
            o = subprocess.check_output(
                ['bash', '-c', '. ~/.bash_profile; cori_get_password']
            )
            user = os.environ["CORI_USER"]
            host = "lrc-login.lbl.gov"
        elif worker == "lrc":
            o = subprocess.check_output(
                ['bash', '-c', '. ~/.bash_profile; lrc_get_password']
            )
            user = os.environ["LRC_USER"]
            host = "lrc-login.lbl.gov"
        else:
            raise ValueError(f"Worker {worker} not valid!")
github hackingmaterials / automatminer / automatminer_dev / matbench / expt_gap.py View on Github external
gap_diffs = per_comp_gaps - mean_gap
        min_gap_diff = gap_diffs.min()
        min_gap_diff_index = gap_diffs.tolist().index(min_gap_diff)
        actual_gap_diff = per_comp_gaps.tolist()[min_gap_diff_index]
        # if len(per_comp_gaps) > 1:
        #     print(f"{c} decided on {actual_gap_diff} from \n {per_comp_gaps} \n\n")
        new_df_dict["composition"].append(c)
        new_df_dict["gap expt"].append(actual_gap_diff)


df_new = pd.DataFrame(new_df_dict)
df_new = df_new.sort_values(by="composition")
df_new = df_new.reset_index(drop=True)


store_dataframe_as_json(df_new, "expt_gap.json.gz", compression="gz")

print(df_new)