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 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.0-cp313-cp313-manylinux_2_28_x86_64.whl (7.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ x86-64

learner_py-1.0.0-cp312-cp312-manylinux_2_28_x86_64.whl (7.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.28+ x86-64

learner_py-1.0.0-cp311-cp311-manylinux_2_28_x86_64.whl (7.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

learner_py-1.0.0-cp310-cp310-manylinux_2_28_x86_64.whl (7.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.28+ x86-64

learner_py-1.0.0-cp39-cp39-manylinux_2_28_x86_64.whl (7.9 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.28+ x86-64

File details

Details for the file learner_py-1.0.0-cp313-cp313-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.0-cp313-cp313-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f0cd330b2444a646e50ec6308bb391d1a9b7e0341d74e4035cef8449c2cb063e
MD5 7e0efb1e9b6b9b78bb22760bd16fb73a
BLAKE2b-256 30656b72bd5c8c0e6426b190821459d4c0c9e35daa9dce95e26bf9d8fd995aa6

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.0-cp313-cp313-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.0-cp312-cp312-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.0-cp312-cp312-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9a7e17e38b4760a4009a12f2d6bc3ec267e3b157937e1c674803f2059cb6536f
MD5 de5ec762917d6073be1554f29bce3cbc
BLAKE2b-256 1570d92f681b3d98cb3bdadcc873f2610377b07aed3adf7c489385e264ba58a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.0-cp312-cp312-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.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8b7aa012361d8ec8169c1fa0f0cc86dc8578f132eff05154cf7945f01ab10196
MD5 6a678db455bc162d5ccf476a24d5408f
BLAKE2b-256 e738c3b0839af22600c6a909b5434d2bb707f8a267c7ae811eb75b04f8e956e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.0-cp311-cp311-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.0-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.0-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4a170b2c39b3f97ff34d891c19e9b1be7906516dd88984fa7d935490094b232b
MD5 14e63de08700d7be9b8488ab209bc0b6
BLAKE2b-256 de2145a3b0f0491f1719ea1ba27525c6a2584b2add67b2ab2fb8dad90e216b46

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.0-cp310-cp310-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.0-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for learner_py-1.0.0-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0aa92cd20202f2ce5f1763f79ebc3a9e362073474770267aa4ca9e3380e77f6e
MD5 f38e1371ca7ba626a9524682dadcd723
BLAKE2b-256 0688418886a9d8ce576130f1f1e5f7a8e819e620524c0f8613401c77f0d30d7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for learner_py-1.0.0-cp39-cp39-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.

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