ensure that all attributes with trailing underscore in fit are leared after the entire logic has succeded

Aberta
#586 3 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
35/100
Tipo de issue
Refatoração
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
python, scikit-learn
Domínio
machine-learning

Direção de pesquisa

Start with the test_encoders test the issue quotes, which shows the non-fitted-error pattern, and copy it for each unchecked module (encoding, outliers, scaling, datetime, text, selection, time series, preproc, wrappers). In each module's fit() method, move every assignment of a trailing-underscore attribute to after the last step that can raise. Done means the new parametrized test passes for every module and the existing tests still pass. Related PR #917 is referenced but not linked, so check it before starting.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

All attributes with trailing underscore must be set up at the end of the fit() functionality, when we are sure that all fit logic worked. At the moment, it is not like that for all transformers.

Add a test like the one in test_encoders:

@pytest.mark.parametrize("estimator", _estimators)
def test_raises_non_fitted_error_when_error_during_fit(estimator):
    X, y = test_df(categorical=True)
    X.loc[len(X) - 1] = nan
    transformer = clone(estimator)

    with pytest.raises(ValueError):
        transformer.fit(X, y)

    # Test when fit is not called prior to transform.
    with pytest.raises(NotFittedError):
        transformer.transform(X)

Modules encoding and preprocessing already have this functionality.

Modules to update:

  • imputation
  • encoding
  • discretisation
  • outliers
  • transformation
  • scaling
  • creation
  • datetime
  • text
  • selection
  • time series
  • preproc
  • wrappers

Related PRs:

  • #917
Linguagem predominante
Python
Estrelas
2.3k
Forks
391
Merge médio
11h 34min
PRs com merge (30d)
11

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de feature-engine/feature_engine

Todas as issues de feature-engine/feature_engine

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.