alteryx / alteryx/evalml

Invalid logical type error for data while on its own (infer_feature_types)

オープン
#3,886 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
bug
主要言語
Python
スター
850
フォーク
96
PR マージ指標
30日以内にマージされた PR はありません

説明

While attempting to split a dataset into multiple pandas dataframes, an error occurs when one column of binary data is marked as categorical through the infer_feature_types function while in its own dataframe. This error only occurs while it is in its own dataframe, when any other columns of data are included in the dataframe, it accepts the categorical logical type as expected.

I should also mention, i'm still quite new at programming, so the error could be in my understanding.

Here is the exact error I'm getting:
```python
Traceback (most recent call last):
File "d:\PYTHON PROJECTS\Adv-Stock-Predictions\errortest.py", line 68, in
YI = infer_feature_types(
File "C:\Users\chous\AppData\Roaming\Python\Python39\site-packages\evalml\utils\woodwork_utils.py", line 71, in infer_feature_types
return ww.init_series(data, logical_type=feature_types)
File "C:\Users\chous\AppData\Roaming\Python\Python39\site-packages\woodwork\accessor_utils.py", line 62, in init_series
logical_type = _get_column_logical_type(series, logical_type, series.name)
File "C:\Users\chous\AppData\Roaming\Python\Python39\site-packages\woodwork\utils.py", line 416, in _get_column_logical_type
return _parse_logical_type(logical_type, name)
File "C:\Users\chous\AppData\Roaming\Python\Python39\site-packages\woodwork\utils.py", line 429, in _parse_logical_type
raise TypeError(f"Invalid logical type specified for '{name}'")
TypeError: Invalid logical type specified for 'Increased'
```

Here is the code I'm using:
```python
import os
import datetime as dt
import pandas_datareader as pdr
import pandas as pd
from evalml.utils import infer_feature_types

os.makedirs('Historical_Data', exist_ok=True)

def increased_close(row):
if row['Close'] > row['Open']:
return int('1')
else:
return int('0')

# Uncomment these lines to pull initial dataset from Yahoo Finance Historical Data
# start = dt.datetime(1999,11,17)
# end = dt.date.today() - dt.timedelta(days = 5)
# data = pdr.data.DataReader('A','yahoo',start,end)
# data.to_csv('Historical_Data/A.csv')

data = pd.read_csv('Historical_Data/A.csv', header=0)
data = data.drop('Adj Close', axis=1)
data['Increased'] = data.apply(increased_close, axis=1)
data['Yest_High'] = data.High.shift(1)
data['Yest_Low'] = data.Low.shift(1)
data['Yest_Open'] = data.Open.shift(1)
data['Yest_Volume'] = data.Volume.shift(1)
data['Yest_Close'] = data.Close.shift(1)
data['Yest_Increased'] = data.Increased.shift(1)
data = data.dropna()
data = data.loc[:,
['Date', 'Open', 'High', 'Low', 'Volume', 'Yest_Open', 'Yest_High', 'Yest_Low', 'Yest_Volume',
'Yest_Close', 'Yest_Increased', 'Close', 'Increased']]

X = data.iloc[:, 0:-2]
Y = data.iloc[:, -2]
YI = data.iloc[:, -1]

# This works as expected
data = infer_feature_types(
data,
feature_types={
'Yest_Increased': 'Categorical',
'Increased': 'Categorical'
}
)

print(data.ww)

X = infer_feature_types(
X,
feature_types={
'Yest_Increased': 'Categorical'
},
)

print(X.ww)

Y = infer_feature_types(
Y
)

print(Y.ww)

# This causes the TypeError
YI = infer_feature_types(
YI,
feature_types={
'Increased': 'Categorical'
},
)

print(YI.ww)

```

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。