--- title: Essais et développement de la méthode de calage sur marges keywords: fastai sidebar: home_sidebar nb_path: "notebooks/calmar/calage_sur_marges.ipynb" ---
{% raw %}
{% endraw %} {% raw %}
from leximpact_socio_fisca_simu_etat.config import Configuration

config = Configuration(project_folder="leximpact-prepare-data")
{% endraw %} {% raw %}
import unittest

tc = unittest.TestCase()
{% endraw %} {% raw %}
import numpy as np
import pandas as pd
import seaborn as sns
{% endraw %} {% raw %}
import leximpact_prepare_data.calmar

calmar.linear(10)
{% endraw %}

CALMAR

Échantillon de données pour test

{% raw %}
 
{% endraw %} {% raw %}
# sample=erfs, X=RFR, d=wprm nos poids de sondage et Y notre variable d'intéret

sample = pd.DataFrame(
    [
        [1, 1, 0, 12],  # Bucket 0
        [2, 1, 0, 32],
        [3, 1, 0, 5],
        [4, 1, 46, 0],  # Bucket 0-100
        [5, 1, 99, 4323],
        [6, 1, 90, 104],
        [7, 1, 250, 102],  # Bucket 250-1000
        [8, 1, 300, 1253],
        [9, 1, 1000, 92],
        [10, 1, 21_000, 9217],  # Bucket 1000-25000
        [11, 1, 12_000, 91],
        [12, 1, 1000, 0],
        [13, 1, 8000, 0],
        [14, 1, 1830, 9812],
        [15, 1, 1185, 100281],
        [16, 1, 1981, 9822],
        [17, 1, 18417, 91],
        [18, 1, 26_000, 2301],  # Bucket 25000-50000
        [19, 1, 49_000, 87203],
    ],
    columns=["idfoy", "d", "X", "Y"],
)

sample.head()
{% endraw %} {% raw %}
estimateur_y = (sample["d"] * sample["Y"]).sum()
print(estimateur_y)
{% endraw %}