Skip to main content

Implements transfer learning methods for low-rank matrix estimation.

Project description

learner-py

The learner-py package implements transfer learning methods for low-rank matrix estimation. These methods leverage similarity in the latent row and column spaces between the source and target populations to improve estimation in the target population. The methods include the LatEnt spAce-based tRaNsfer lEaRning (LEARNER) method and the direct projection LEARNER (D-LEARNER) method described by McGrath et al. (2024).

Installation

You can install the released version of learner-py from PyPi with:

pip install learner-py

LEARNER Method

We can apply the LEARNER method via the learner function.

This method allows for flexible patterns of heterogeneity across the source and target populations. It consequently requires specifying the tuning parameters lambda_1 and lambda_2 which control the degree of transfer learning between the populations. These values can be selected based on cross-validation via the cv.learner function. For example, we can specify candidate values of 1, 10, and 100 for lambda_1 and lambda_2 and select the optimal values based on cross-validation as follows:

res_cv = pylearner.cv_learner(
            Y_source=dat_highsim["Y_source"],
            Y_target=dat_highsim["Y_target"],
            lambda1_all=[1, 10, 100],
            lambda2_all=[1, 10, 100],
            step_size=0.003
        )

print(res_cv['lambda_1_min']) #100
print(res_cv["lambda_2_min"]) #1

Example

We illustrate an example of how learner can be used. We first load the package.

import learner-py as pylearner

In this illustration, we will use one of the toy data sets in the package (dat_highsim) that has a high degree of similarity between the latent spaces of the source and target populations. The object dat_highsim is a list which contains the observed source population data matrix Y_source and the target population data matrix Y_target. Since the data was simulated, the true values of the matrices are included in dat_highsim as Theta_source and Theta_target.

LEARNER Method

We can apply the LEARNER method via the learner function.

This method allows for flexible patterns of heterogeneity across the source and target populations. It consequently requires specifying the tuning parameters lambda_1 and lambda_2 which control the degree of transfer learning between the populations. These values can be selected based on cross-validation via the cv.learner function. For example, we can specify candidate values of 1, 10, and 100 for lambda_1 and lambda_2 and select the optimal values based on cross-validation as follows:

res_cv = pylearner.cv_learner(
            Y_source=dat_highsim["Y_source"],
            Y_target=dat_highsim["Y_target"],
            lambda1_all=[1, 10, 100],
            lambda2_all=[1, 10, 100],
            step_size=0.003
        )

print(res_cv['lambda_1_min']) #100
print(res_cv["lambda_2_min"]) #1

Next, we apply the learner function with these values of lambda1 and lambda2:

res_learner <- learner(Y_source = dat_highsim$Y_source, 
                       Y_target = dat_highsim$Y_target,
                       lambda1 = 100, lambda2 = 1, 
                       step_size = 0.003)

The LEARNER estimate is given by the learner_estimate component in the output of the learner function, e.g.,

print(res_learner['learner_estimate'][0:4, 0:4])
[[ 0.14688887 -1.63414688  1.18573076  0.00809396]
 [ 0.10877659 -0.2439277  -1.0061737  -0.05811972]
 [-0.62130277  1.04206753 -0.69077759  0.90570933]
 [ 1.58115883 -3.0000149   0.39780804 -2.12428512]]

D-LEARNER Method

We can apply the D-LEARNER method via the dlearner function. This method makes stronger assumptions on the heterogeneity across the source and target populations. It consequently does not rely on choosing tuning parameters. The dlearner function can be applied as follows:

res_dlearner = pylearner.dlearner(Y_source=dat_highsim["Y_source"],
                                  Y_target=dat_highsim["Y_target"])

print(res_dlearner['dlearner_estimate'][0:4, 0:4])

[[ 0.0959171  -1.72143637  1.15500149  0.00547827]
 [ 0.10771367 -0.3224348  -1.03557177 -0.10819564]
 [-0.72372751  0.86634922 -0.43528206  1.10580219]
 [ 1.63476957 -2.91985925  0.04876288 -2.35750409]]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

learner_py-1.0.4-cp313-cp313-win_amd64.whl (237.9 kB view details)

Uploaded CPython 3.13Windows x86-64

learner_py-1.0.4-cp313-cp313-macosx_10_13_x86_64.whl (346.9 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

learner_py-1.0.4-cp312-cp312-win_amd64.whl (237.8 kB view details)

Uploaded CPython 3.12Windows x86-64

learner_py-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl (346.8 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

learner_py-1.0.4-cp311-cp311-win_amd64.whl (236.9 kB view details)

Uploaded CPython 3.11Windows x86-64

learner_py-1.0.4-cp311-cp311-musllinux_1_2_x86_64.whl (11.4 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

learner_py-1.0.4-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (10.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

learner_py-1.0.4-cp311-cp311-macosx_10_9_x86_64.whl (346.5 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

learner_py-1.0.4-cp310-cp310-win_amd64.whl (236.5 kB view details)

Uploaded CPython 3.10Windows x86-64

learner_py-1.0.4-cp310-cp310-musllinux_1_2_x86_64.whl (11.4 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

learner_py-1.0.4-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (10.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

learner_py-1.0.4-cp310-cp310-macosx_10_9_x86_64.whl (345.0 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

learner_py-1.0.4-cp39-cp39-win_amd64.whl (236.5 kB view details)

Uploaded CPython 3.9Windows x86-64

learner_py-1.0.4-cp39-cp39-musllinux_1_2_x86_64.whl (11.4 MB view details)

Uploaded CPython 3.9musllinux: musl 1.2+ x86-64

learner_py-1.0.4-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (10.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

learner_py-1.0.4-cp39-cp39-macosx_10_9_x86_64.whl (345.1 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file learner_py-1.0.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: learner_py-1.0.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 237.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for learner_py-1.0.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 33f4dc469bab8b34154209b6234598add766340cd8bb3f8c6fba129201f21638
MD5 da56a17ff0d67d216a6376112311d14f
BLAKE2b-256 11fc2f8a79d11be38bc10ac9db62d45b2be4357280197e8da017106a9107d6fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp313-cp313-win_amd64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 24bf1417bc02cf50c12439cc45855e88c15df9cbcac30891082230a0dff30475
MD5 7ef96ea42873a6d7cc0d0153814aa3dd
BLAKE2b-256 de2b85871c6cc9ecbc6c2ad9db504e4c77cc27450909b051201815c152e3e522

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: learner_py-1.0.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 237.8 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for learner_py-1.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5462a8032b77d10e720e0952142fad0dce2e231d3aa15817237d255136fe813e
MD5 bedc90f93bae528339df11a7bf5f4727
BLAKE2b-256 6e453210d7df31388b3e0f533ec0eb3f25537c7fcf6d8d949b0bee464ee6f38d

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp312-cp312-win_amd64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 70a007b4678feea30344b03d7d4e90d135334ae4901e4263c828942310faeeda
MD5 7949a07a8acd529089d29965798e172a
BLAKE2b-256 41f0cc988b52f6704ab9808627c06ce9c6d213ccab92dd0c7b7bfc3a81759700

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: learner_py-1.0.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 236.9 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for learner_py-1.0.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7283544a7387c41361234bca8c9aae3857f8ef046a20587a1f1715fe92f463f3
MD5 e85047360cc0323876aca0e2698db967
BLAKE2b-256 f04d581038179282a864e59a62f25eed666cffee30c6f66bdaf825ad9c4b07ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp311-cp311-win_amd64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.4-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5e8152081c471fa69f24b269f96d3dc2997200d59d52be58d5a8f8fd06b56e11
MD5 1a5dc09b02c9f5a43159f052dd25867c
BLAKE2b-256 ccdee7db1fbf99645f23ee77aa8b03c22b3012d8ca72ae3457e05b9e5eb33db0

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp311-cp311-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.4-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 529f882dce6670b88eae451eddacbcd90589d44e58d57f17ba5749cc9d9efbd6
MD5 488491e31fdfede44ca2701e92330697
BLAKE2b-256 528ec55a7dddf52967a10e58299e8c56414bf716367e805fa2b314e8825334e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 84ed7ad8d21a5759d703a9a344535cd16951778f059979c81788cfd235a752fb
MD5 ff55418781bf4d88b7e8529ecfe84a46
BLAKE2b-256 34f0aca27ae5cb64432e1a048a82f7c1dfc82f4e6554731060762e66b609e84a

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: learner_py-1.0.4-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 236.5 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for learner_py-1.0.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3f6fa3f191a00a39e0a4ab3fbebf03fba118a25995ac0eb3cece2b7305040fc0
MD5 babc3e81a56f6772bb55765b884ee86f
BLAKE2b-256 0975ab5763b90e9936175b49b6c6135e53dd53bdff6a290adb86b1e55a5bed7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp310-cp310-win_amd64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.4-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 d1a8e6b41bcf7381144ab731763d574f8839123ea79c1c82fc78630ca1f4a4ec
MD5 37c639b85e74174d50185f5a96602db0
BLAKE2b-256 7c990043d9e7da603b9c3c3dc800047b41e1e8798544eeebf689aaac026d8bec

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp310-cp310-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.4-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1db85c07688291e9af6ef7d8027eda2402dfbcac569ce70e08de2f62d868e999
MD5 4190191a0fb509d8cc2206fb4935e024
BLAKE2b-256 6342577dd7bc88b75d23f4dae10a21465b2a8253b2f191ae4a24f4547128e442

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 215e298991373d9bd18dd8950babf6b8b04a5d44e709431e24fbf2b156d592b9
MD5 90d6d2c643122565e17f6619b158c850
BLAKE2b-256 d008d05e16b85fec4ca1289090c7ed80722dbf823218ebc32eba6f9958660f5e

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp310-cp310-macosx_10_9_x86_64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: learner_py-1.0.4-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 236.5 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for learner_py-1.0.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7b963aec5770b8295c5fdd7f9cd878c3c9d0f89ed426f250475dbade075e77b5
MD5 cfb81fb85046410a69db0f6d8ac23e60
BLAKE2b-256 91a362e2b2745a07e3806c6e2a837c8e8a50bd31c78606c706f193bfc5c9614a

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp39-cp39-win_amd64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp39-cp39-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.4-cp39-cp39-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5865722aa5ef25eadfbb9ca9b2418a4b61507f83bce26812edc7a02c59321e9b
MD5 dfbfc19f6ded4d3ad57f9d9f6ffe7f46
BLAKE2b-256 9ea3ccb33eeaed2a9126717b39844909725142531d660fd87ee0337ee6ca844a

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp39-cp39-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.4-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b97bc4b4cf4ec1f8bfe254214e04ff04e814a3b0a2ec2fc39d3d98fed69cdec1
MD5 8046896123dd9efd7c7e874cde98f0c3
BLAKE2b-256 43f22d1a29f1bd7f618f4f2f29e0bd8ed16e5b8277cee01615d91114ff8038d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file learner_py-1.0.4-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 899f0ee9b20cfaff7e1259c3978e22b382c52ac8f0b7583b84001233de6ab9f5
MD5 4734ea8997d318a604fa66f07fc1358d
BLAKE2b-256 fc8fc56e7a7c1840bb73c04c1edc6db8c880435e63964d3fbe485c219bfbe685

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.4-cp39-cp39-macosx_10_9_x86_64.whl:

Publisher: python-publish.yml on ryan-odea/pylearner

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page