Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add InputData from pd and numpy #1184

Merged
merged 6 commits into from
Oct 23, 2023
Merged

add InputData from pd and numpy #1184

merged 6 commits into from
Oct 23, 2023

Conversation

ChrisLisbon
Copy link
Collaborator

Add InputData.from_dataframe and InputData.from_numpy methods. From dataframe expects that user already opend his df, set indeces, removed columns. From numpy based on exicting function.

@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #1184 (a9e04c3) into master (9cd08a0) will decrease coverage by 0.06%.
The diff coverage is 65.38%.

@@            Coverage Diff             @@
##           master    #1184      +/-   ##
==========================================
- Coverage   79.55%   79.50%   -0.06%     
==========================================
  Files         145      145              
  Lines        9995    10021      +26     
==========================================
+ Hits         7952     7967      +15     
- Misses       2043     2054      +11     
Files Coverage Δ
fedot/core/data/data.py 70.10% <65.38%> (-0.36%) ⬇️

... and 1 file with indirect coverage changes

target_array: np.ndarray,
idx: Optional[np.ndarray] = None,
task: Task = Task(TaskTypesEnum.classification),
data_type: Optional[DataTypesEnum] = None) -> InputData:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Думаю по умолчанию можно поставить table, как наиболее часто используемый тип

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может даже стоит создать два метода
from_numpy
и
ts_from_numpy

Интуитивно, пользователю, будет понятней сразу из названия метода, что он может с его помощью конвертировать временной ряд в инпут дату (вместо того, чтобы вручную прописывать Task и DataType)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, по аналогии с from_csv прописала


@classmethod
def from_dataframe(cls,
df: pd.DataFrame,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Иногда возникает ситуация, когда у тебя X и y - отдельные датафреймы, и хочется создать инпут дату из них. Это выглядит как частный случай метода from_numpy. Возможно его можно обобщить и до датафреймов

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ну тут идея как раз в том, что пользователь уже пооткрывал свои данные и подготовил датафрейм самостоятельно, специально из этого метода убрала всю автоматичность

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Может быть у меня замыленный взгляд - привык, что в sklearn ты всегда передаешь X и y отдельно. Поэтому часто возникает именно такая ситуация, что хочется отдельно прокинуть фичи и таргет. Но тот вариант, что сейчас написан, тоже нужен.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Про отдельные X и Y спорный момент. С одной стороны, мы идеологически предлагаем решение "из коробки" - вы просто читаете любой формат в DataFrame и засовываете в AutoML. С другой, почти любая предобработка данных пользователем выдаст X и Y отдельно.

Я считаю, этот вопрос можно переформулировать так: мы рассчитываем на продвинутого пользователя или наоборот?

Судя по тому, что дело дошло до создания InputData вручную, скорее на продвинутого. Тогда, на мой взгляд, разумнее использовать вариант с отдельными параметрами для X и Y.

UPD: На это можно посмотреть ещё так: в pandas гораздо интуитивнее разделяется датафрейм, чем два датафрейма сшиваются воедино. Гораздо лучше, если наш интерфейс не будет никого обрекать на конкатенацию датафреймов.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Принято, разделила from_dataframe на два входа features_df и target_df

Copy link
Collaborator

@MorrisNein MorrisNein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отлично, так гораздо удобнее, чем импортировать отдельную функцию.


@classmethod
def from_dataframe(cls,
df: pd.DataFrame,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Про отдельные X и Y спорный момент. С одной стороны, мы идеологически предлагаем решение "из коробки" - вы просто читаете любой формат в DataFrame и засовываете в AutoML. С другой, почти любая предобработка данных пользователем выдаст X и Y отдельно.

Я считаю, этот вопрос можно переформулировать так: мы рассчитываем на продвинутого пользователя или наоборот?

Судя по тому, что дело дошло до создания InputData вручную, скорее на продвинутого. Тогда, на мой взгляд, разумнее использовать вариант с отдельными параметрами для X и Y.

UPD: На это можно посмотреть ещё так: в pandas гораздо интуитивнее разделяется датафрейм, чем два датафрейма сшиваются воедино. Гораздо лучше, если наш интерфейс не будет никого обрекать на конкатенацию датафреймов.

@classmethod
def from_numpy_time_series(cls,
features_array: np.ndarray,
target_array: np.ndarray,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Было бы здорово сделать таргет по умолчанию None, И если он None, то features считаем равным таргет.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавила


Args:
features_array: numpy array with features.
target_array: numpy array with target.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мне как возможному пользователю может быть непонятно, что в федоте чаще всего фичи = таргет в инпут дате для задач прогнозирования.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Чаще всего, но не всегда. Добавила пояснение в докстринг

fedot/core/data/data.py Outdated Show resolved Hide resolved
test/unit/data/test_data.py Outdated Show resolved Hide resolved
@ChrisLisbon ChrisLisbon merged commit 0bc7c59 into master Oct 23, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants