Skip to content

Commit

Permalink
minor fixes and cleanups in lode examples
Browse files Browse the repository at this point in the history
  • Loading branch information
PicoCentauri committed Oct 26, 2023
1 parent 51b048c commit ea292ef
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions examples/lode_linear/lode_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

# %%
#
# Convert target properties to equistore format
# Convert target properties to metatensor format
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# If we want to train models using the
Expand Down Expand Up @@ -197,8 +197,8 @@
#
# .. code:: python
#
# descriptor_co = AtomicComposition(per_structure=True).compute(**compute_args) co =
# descriptor_co.keys_to_properties(["species_center"])
# descriptor_co = AtomicComposition(per_structure=True).compute(**compute_args)
# co = descriptor_co.keys_to_properties(["species_center"])
#
# Stack all the features together for linear model
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -267,24 +267,26 @@

# %%
#
# For doing the split we define two ``Labels`` instances
# For doing the split we define two ``Labels`` instances and combine them in a
# :py:class:`List`.

samples_train = metatensor.Labels(["structure"], np.reshape(idx_train, (-1, 1)))
samples_test = metatensor.Labels(["structure"], np.reshape(idx_test, (-1, 1)))
grouped_labels = [samples_train, samples_test]


# %%
#
# That we use as input to the :py:func:`equistore.slice()` function
# That we use as input to the :py:func:`metatensor.split()` function

X_sr_train = metatensor.slice(X_sr, axis="samples", labels=samples_train)
X_sr_test = metatensor.slice(X_sr, axis="samples", labels=samples_test)
X_sr_train, X_sr_test = metatensor.split(
X_sr, axis="samples", grouped_labels=grouped_labels)

X_lr_train = metatensor.slice(X_lr, axis="samples", labels=samples_train)
X_lr_test = metatensor.slice(X_lr, axis="samples", labels=samples_test)
X_lr_train, X_lr_test = metatensor.split(
X_lr, axis="samples", grouped_labels=grouped_labels)

y_train = metatensor.slice(y, axis="samples", labels=samples_train)
y_test = metatensor.slice(y, axis="samples", labels=samples_test)
y_train, grouped_labels = metatensor.split(
y, axis="samples", grouped_labels=grouped_labels)


# %%
Expand Down

0 comments on commit ea292ef

Please sign in to comment.