コード例 #1
0
ファイル: logo.py プロジェクト: JustinGOSSES/pyrolite
# means = np.array([(-d, -d), (d, -d), (-d, d), (d, d)])
covs = (  # covariance for logspace (D=2)
    np.array(
        [
            [[1, 0], [0, 1]],
            [[0.5, 0.15], [0.15, 0.5]],
            [[1.5, -1], [-1, 1.5]],
            [[1.2, -0.6], [-0.6, 1.2]],
        ]
    )
    * sig
)

means = ILRTransform().inverse_transform(means)  # compositional means (D=3)
size = 2000  # logo @ 10000
pts = [random_composition(mean=M, cov=C, size=size) for M, C in zip(means, covs)]

T = ILRTransform()
to_log = T.transform
from_log = T.inverse_transform

df = pd.DataFrame(np.vstack(pts))
df.columns = ["SiO2", "MgO", "FeO"]
df["Sample"] = np.repeat(np.arange(df.columns.size + 1), size).flatten()
chem = ["MgO", "SiO2", "FeO"]
#######################################################################################
#
fig, ax = plt.subplots(
    2, 2, figsize=(10, 10 * np.sqrt(3) / 2), subplot_kw=dict(projection="ternary")
)
ax = ax.flat
コード例 #2
0
 def setUp(self):
     self.static = np.array(
         [[0, 1, 1], [0, np.nan, 1], [np.nan, 0, 1], [0, 1, np.nan], [1, np.nan, 0]]
     )
     self.rdata = random_composition(size=200, missing="MCAR")
コード例 #3
0
 def setUp(self):
     self.data = random_composition(size=200, missing="MNAR")
コード例 #4
0
ファイル: EMCOMP.py プロジェクト: JustinGOSSES/pyrolite
.. note:: This example and features in this module are currently incomplete and a work in progress.
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from pyrolite.comp.impute import EMCOMP
from pyrolite.util.synthetic import random_composition, random_cov_matrix
from pyrolite.plot import pyroplot

np.random.seed(41)
########################################################################################

sample_data = random_composition(
    size=1000,
    D=4,
    cov=random_cov_matrix(3, sigmas=[0.1, 0.3, 0.15]),
    propnan=0.1,
    missing="MNAR",
    missingcols=3,
)
########################################################################################
imputed_data, p0, niter = EMCOMP(sample_data,
                                 threshold=np.nanpercentile(sample_data,
                                                            10,
                                                            axis=0),
                                 tol=0.01)
imputed_data = pd.DataFrame(imputed_data, columns=["A", "B", "C", "D"])
########################################################################################
fig, ax = plt.subplots(1, 3, sharex=True, sharey=True, figsize=(12, 5))

ax[0].set_title("Original Data")
ax[1].set_title("New Imputed Data")
コード例 #5
0
 def setUp(self):
     self.fig, self.ax = plt.subplots(1)
     self.els = REE()
     self.arr = random_composition(size=10, D=len(self.els))
コード例 #6
0
ファイル: util_plot.py プロジェクト: JustinGOSSES/pyrolite
 def setUp(self):
     self.comp3d = random_composition(size=100, D=3)
     self.T = ILRTransform()
     self.comp2d = self.T.transform(self.comp3d)
コード例 #7
0
ファイル: util_plot.py プロジェクト: JustinGOSSES/pyrolite
 def setUp(self):
     self.rdata = pd.DataFrame(
         random_composition(size=200, D=4, missing="MCAR"),
         columns=["MgO", "SiO2", "CaO", "TiO2"],
     )