代码拉取完成,页面将自动刷新
#!/usr/bin/env python
"extract features, impute nulls, save"
import warnings
import pandas as pd
from tsfresh import extract_features
from tsfresh.utilities.dataframe_functions import impute
#
from config import input_file, features_file
if __name__ == '__main__':
d = pd.read_csv( input_file, header = None )
columns = list( d.columns )
columns.pop()
columns.append( 'target' )
d.columns = columns
y = d.target
d.drop( 'target', axis = 1, inplace = True )
d = d.stack()
d.index.rename([ 'id', 'time' ], inplace = True )
d = d.reset_index()
print len( d )
print d.head()
# doesn't work too well
with warnings.catch_warnings():
warnings.simplefilter( "ignore" )
f = extract_features( d, column_id = "id", column_sort = "time" )
#c:\usr\anaconda\lib\site-packages\scipy\signal\spectral.py:1633:
# UserWarning: nperseg = 256 is greater than input length = 152, using nperseg = 152
# Feature Extraction: 20it [22:33, 67.67s/it]
impute( f )
assert f.isnull().sum().sum() == 0
f['y'] = y
f.to_csv( features_file, index = None )
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。