Beklentiler Oluşturma

Great Expectations ile Veri Kalitesine Giriş

Davina Moossazadeh

Data Scientist

Beklentiler

Beklenti (Expectation) - Veriye dair doğrulanabilir bir iddia

  • Sütun Beklentileri
  • Şekil ve şema Beklentileri
    • şema (schema) - veri kümesinin yapısının planı
1 https://docs.greatexpectations.io/docs/reference/learn/terms/expectation
Great Expectations ile Veri Kalitesine Giriş

Beklentiler

Beklenti (Expectation) - Veriye dair doğrulanabilir bir iddia

  • Sütun Beklentileri
  • Şekil ve şema Beklentileri
    • şema (schema) - veri kümesinin yapısının planı
1 https://docs.greatexpectations.io/docs/reference/learn/terms/expectation
Great Expectations ile Veri Kalitesine Giriş

Yenilenebilir Enerji Üretimi veri kümesi

Aşağıdaki sütunlara sahip Yenilenebilir Enerji Üretimi verilerini içeren bir pandas DataFrame'i: "Time", "Energy delta[Wh]", "GHI", "temp", "pressure", "humidity", "wind_speed", "rain_1h", "snow_1h" ve "clouds_all". DataFrame 118.066 satır içerir.

1 https://www.kaggle.com/datasets/pythonafroz/renewable-power-generation-and-weather-conditions
Great Expectations ile Veri Kalitesine Giriş

Bir Beklenti Oluşturma

gx.expectations.Expect...(...)

GX sınıfları (Expectations): PascalCase

GX fonksiyonları / metodları: snake_case

1 https://docs.greatexpectations.io/docs/core/define_expectations/create_an_expectation/
Great Expectations ile Veri Kalitesine Giriş

Bir Beklenti Oluşturma

row_count_expectation = gx.expectations.ExpectTableRowCountToEqual(

value=118000 )
validation_results = batch.validate(
expect=row_count_expectation )
1 https://docs.greatexpectations.io/docs/core/define_expectations/create_an_expectation/ https://docs.greatexpectations.io/docs/core/define_expectations/test_an_expectation/
Great Expectations ile Veri Kalitesine Giriş

Bir Beklentiyi Değerlendirme

print(validation_results)
{ 
    "success": false,
    "expectation_config": {
        "type": "expect_table_row_count_to_equal",
        "kwargs": {"batch_id": "my_pandas_datasource-my_dataframe_asset", "value": 118000},
        "meta": {},
        "rendered_content": [{"name": "atomic.prescriptive.summary", "value": {"schema": {"type": "com.superconductive.rendered.string"}, "template": "Must have exactly $value rows.", "params": {"value": {"schema": {"type": "number"}, "value": 118000}}}, "value_type": "StringValueType"}]
    },
    "result": {"observed_value": 118066},
    "meta": {},
    "exception_info": {"raised_exception": false, "exception_traceback": null, "exception_message": null},
    "rendered_content": [{"name": "atomic.diagnostic.observed_value", "value": {"schema": {"type": "com.superconductive.rendered.string"}, "template": "118066", "params": {}}, "value_type": "StringValueType"}]
}
1 https://docs.greatexpectations.io/docs/core/run_validations/run_a_validation_definition/
Great Expectations ile Veri Kalitesine Giriş

Bir Beklentiyi Değerlendirme

print(validation_results.describe())
{
    "expectation_type": "expect_table_row_count_to_equal",
    "success": false,
    "kwargs": {
        "batch_id": "my_pandas_datasource-my_dataframe_asset",
        "value": 118000
    },
    "result": {
        "observed_value": 118066
    }
}
Great Expectations ile Veri Kalitesine Giriş

Bir Beklentiyi Değerlendirme

print(validation_results.success)
False
print(validation_results["success"])
False
Great Expectations ile Veri Kalitesine Giriş

Bir Beklentiyi Değerlendirme

print(validation_results.result)
{'observed_value': 118066}
print(validation_results["result"])
{'observed_value': 118066}
Great Expectations ile Veri Kalitesine Giriş

Diğer yaygın Beklentiler

Şekil Beklentileri:

ExpectTableRowCountToEqual(value: int)
ExpectTableRowCountToBeBetween(
    min_value: int, max_value: int
)
ExpectTableColumnCountToEqual(
    value: int
)
ExpectTableColumnCountToBeBetween(
    min_value: int, max_value: int
)

Sütun adı Beklentileri:

ExpectTableColumnsToMatchSet(
    column_set: set
)
ExpectColumnToExist(column: str)
Great Expectations ile Veri Kalitesine Giriş

Hızlı bakış

Bir Beklenti oluşturun:

gx.expectations.Expect...(...)

Bir Beklentiyi doğrulayın:

validation_results = batch.validate(
    expect=expectation
)

Satır sayısı Beklentisi oluşturun:

expectation = gx.expectations. \
ExpectTableRowCountToEqual(
    value: int
)

Doğrulama Sonuçlarını kontrol edin:

validation_results.describe()
validation_results.success
validation_results.result
Great Expectations ile Veri Kalitesine Giriş

Hadi pratik yapalım!

Great Expectations ile Veri Kalitesine Giriş

Preparing Video For Download...