def test_header_happy(names, col_idx, feature_idx): h = Header(column_names=["a", "b", "c"], target_column_name="b") assert h.target_column_index == 1 assert h.as_feature_indices(names) == feature_idx assert h.as_column_indices(names) == col_idx assert h.num_features == 2 assert h.num_columns == 3
def test_automl(): st_helper = SklearnTestHelper() data = np.array( [[4, 5, np.nan, 7], [0, np.nan, 2, 3], [8, 9, 10, 11], [np.nan, 13, 14, 15]], dtype=np.float32, ) pipeline = Pipeline( steps=[("robustimputer", RobustImputer(fill_values=np.nan, strategy="constant"))]) ct = ColumnTransformer(transformers=[("numeric_processing", pipeline, [0, 1, 2, 3])]) ct.fit(data) pipeline = Pipeline(steps=[("column_transformer", ct)]) header = Header(column_names=["x1", "x2", "x3", "class"], target_column_name="class") na = NALabelEncoder() na.fit(data) automl_transformer = AutoMLTransformer(header, pipeline, na) dshape = (relay.Any(), relay.Any()) _test_model_impl(st_helper, automl_transformer, dshape, data, auto_ml=True)
def test_automl_transformer(feature_transformer, target_transformer, expected_X_transformed_shape, expected_Xy_transformed_shape): X = np.arange(0, 3 * 10).reshape((10, 3)).astype(np.str) y = np.array([0] * 5 + [1] * 4 + [np.nan]).astype(np.str) header = Header(column_names=["x1", "x2", "x3", "class"], target_column_name="class") automl_transformer = AutoMLTransformer( header=header, feature_transformer=feature_transformer, target_transformer=target_transformer, ) model = automl_transformer.fit(X, y) X_transformed = model.transform(X) assert X_transformed.shape == expected_X_transformed_shape Xy = np.column_stack([X, y]) Xy_transformed = model.transform(Xy) assert Xy_transformed.shape == expected_Xy_transformed_shape with pytest.raises(ValueError): model.transform(X[:, 2:])
def test_automl_transformer_regression(): """Tests that rows in a regression dataset where the target column is not a finite numeric are imputed""" data = read_csv_data(source="test/data/csv/regression_na_labels.csv") X = data[:, :3] y = data[:, 3] header = Header(column_names=["x1", "x2", "x3", "class"], target_column_name="class") automl_transformer = AutoMLTransformer( header=header, feature_transformer=RobustImputer(strategy="constant", fill_values=0), target_transformer=NALabelEncoder(), ) model = automl_transformer.fit(X, y) X_transformed = model.transform(X) assert X_transformed.shape == X.shape Xy = np.concatenate((X, y.reshape(-1, 1)), axis=1) Xy_transformed = model.transform(Xy) assert Xy_transformed.shape == (3, 4) assert np.array_equal( Xy_transformed, np.array([[1.1, 1.0, 2.0, 3.0], [2.2, 4.0, 0.0, 5.0], [3.3, 12.0, 13.0, 14.0]]))
from sagemaker_sklearn_extension.decomposition import RobustPCA from sagemaker_sklearn_extension.externals import Header from sagemaker_sklearn_extension.feature_extraction.text import MultiColumnTfidfVectorizer from sagemaker_sklearn_extension.preprocessing import RobustLabelEncoder from sagemaker_sklearn_extension.preprocessing import RobustStandardScaler from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline # Given a list of column names and target column name, Header can return the index # for given column name HEADER = Header(column_names=['star_rating', 'review_body'], target_column_name='star_rating') def build_feature_transform(): """ Returns the model definition representing feature processing.""" # These features can be parsed as natural language. text = HEADER.as_feature_indices(['review_body']) text_processors = Pipeline(steps=[( 'multicolumntfidfvectorizer', MultiColumnTfidfVectorizer( max_df=0.99, min_df=0.0021, analyzer='char_wb', max_features=10000) )]) column_transformer = ColumnTransformer(transformers=[('text_processing', text_processors, text)]) return Pipeline(steps=[(
from sagemaker_sklearn_extension.externals import Header from sagemaker_sklearn_extension.feature_extraction.text import MultiColumnTfidfVectorizer from sagemaker_sklearn_extension.preprocessing import RobustLabelEncoder from sagemaker_sklearn_extension.preprocessing import RobustStandardScaler from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline # Given a list of column names and target column name, Header can return the index # for given column name HEADER = Header(column_names=['label', 'features'], target_column_name='label') def build_feature_transform(): """ Returns the model definition representing feature processing.""" # These features can be parsed as natural language. text = HEADER.as_feature_indices(['features']) text_processors = Pipeline( steps=[ ( 'multicolumntfidfvectorizer', MultiColumnTfidfVectorizer( max_df=0.9684, min_df=0.013108614232209739, analyzer='word', max_features=10000 ) ) ] )
from sagemaker_sklearn_extension.externals import Header from sagemaker_sklearn_extension.feature_extraction.text import MultiColumnTfidfVectorizer from sagemaker_sklearn_extension.preprocessing import RobustLabelEncoder from sagemaker_sklearn_extension.preprocessing import RobustStandardScaler from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline # Given a list of column names and target column name, Header can return the index # for given column name HEADER = Header(column_names=["star_rating", "review_body"], target_column_name="star_rating") def build_feature_transform(): """ Returns the model definition representing feature processing.""" # These features can be parsed as natural language. text = HEADER.as_feature_indices(["review_body"]) text_processors = Pipeline(steps=[( "multicolumntfidfvectorizer", MultiColumnTfidfVectorizer( max_df=0.9941, min_df=0.0007, analyzer="word", max_features=10000), )]) column_transformer = ColumnTransformer(transformers=[("text_processing", text_processors, text)]) return Pipeline(steps=[(
from sagemaker_sklearn_extension.decomposition import RobustPCA from sagemaker_sklearn_extension.externals import Header from sagemaker_sklearn_extension.impute import RobustImputer from sagemaker_sklearn_extension.preprocessing import RobustStandardScaler from sagemaker_sklearn_extension.preprocessing import ThresholdOneHotEncoder from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline from sklearn.preprocessing import LabelEncoder # Given a list of column names and target column name, Header can return the index # for given column name HEADER = Header(column_names=[ 'age', 'job', 'marital', 'education', 'default', 'housing', 'loan', 'contact', 'month', 'day_of_week', 'duration', 'campaign', 'pdays', 'previous', 'poutcome', 'emp.var.rate', 'cons.price.idx', 'cons.conf.idx', 'euribor3m', 'nr.employed', 'y' ], target_column_name='y') def build_feature_transform(): """ Returns the model definition representing feature processing.""" # These features can be parsed as numeric. numeric = HEADER.as_feature_indices([ 'age', 'duration', 'campaign', 'pdays', 'previous', 'emp.var.rate', 'cons.price.idx', 'cons.conf.idx', 'euribor3m', 'nr.employed' ]) # These features contain a relatively small number of unique items. categorical = HEADER.as_feature_indices([
from numpy import nan from sagemaker_sklearn_extension.externals import Header from sagemaker_sklearn_extension.impute import RobustImputer from sagemaker_sklearn_extension.preprocessing import RobustLabelEncoder from sagemaker_sklearn_extension.preprocessing import RobustStandardScaler from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline # Given a list of column names and target column name, Header can return the index # for given column name HEADER = Header( column_names=[ 'Unnamed: 0', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'V10', 'V11', 'V12', 'V13', 'V14', 'V15', 'V16', 'V17', 'V18', 'V19', 'V20', 'V21', 'V22', 'V23', 'V24', 'V25', 'V26', 'V27', 'V28', 'Class', 'amt' ], target_column_name='Class' ) def build_feature_transform(): """ Returns the model definition representing feature processing.""" # These features can be parsed as numeric. numeric = HEADER.as_feature_indices( [ 'Unnamed: 0', 'V1', 'V2', 'V3', 'V4', 'V5', 'V6', 'V7', 'V8', 'V9', 'V10', 'V11', 'V12', 'V13', 'V14', 'V15', 'V16', 'V17', 'V18', 'V19', 'V20', 'V21', 'V22', 'V23', 'V24', 'V25', 'V26', 'V27',
from sagemaker_sklearn_extension.impute import RobustImputer from sagemaker_sklearn_extension.preprocessing import RobustStandardScaler from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline from sklearn.preprocessing import LabelEncoder # Given a list of column names and target column name, Header can return the index # for given column name HEADER = Header(column_names=[ 'Churn', 'Account Length', 'VMail Message', 'Day Mins', 'Day Calls', 'Eve Mins', 'Eve Calls', 'Night Mins', 'Night Calls', 'Intl Mins', 'Intl Calls', 'CustServ Calls', 'State_AK', 'State_AL', 'State_AR', 'State_AZ', 'State_CA', 'State_CO', 'State_CT', 'State_DC', 'State_DE', 'State_FL', 'State_GA', 'State_HI', 'State_IA', 'State_ID', 'State_IL', 'State_IN', 'State_KS', 'State_KY', 'State_LA', 'State_MA', 'State_MD', 'State_ME', 'State_MI', 'State_MN', 'State_MO', 'State_MS', 'State_MT', 'State_NC', 'State_ND', 'State_NE', 'State_NH', 'State_NJ', 'State_NM', 'State_NV', 'State_NY', 'State_OH', 'State_OK', 'State_OR', 'State_PA', 'State_RI', 'State_SC', 'State_SD', 'State_TN', 'State_TX', 'State_UT', 'State_VA', 'State_VT', 'State_WA', 'State_WI', 'State_WV', 'State_WY', 'Area Code_408', 'Area Code_415', 'Area Code_510', "Int'l Plan_no", "Int'l Plan_yes", 'VMail Plan_no', 'VMail Plan_yes' ], target_column_name='Churn') def build_feature_transform(): """ Returns the model definition representing feature processing.""" # These features can be parsed as numeric. numeric = HEADER.as_feature_indices([ 'Account Length', 'VMail Message', 'Day Mins', 'Day Calls', 'Eve Mins',
def test_header_error_as_column_index(): h = Header(column_names=["a", "b", "c"], target_column_name="b") assert h.target_column_index == 1 with pytest.raises(ValueError): h.as_column_indices(["unknown"])
def test_header_error_as_feature_indices(names, error_regex): h = Header(column_names=["a", "b", "c"], target_column_name="b") assert h.target_column_index == 1 with pytest.raises(ValueError) as err: h.as_feature_indices(names) err.match(error_regex)
def test_header_errors_duplicate_columns(column_names, target_column): with pytest.raises(ValueError): Header(column_names=column_names, target_column_name=target_column)
def test_header_errors_target_missing(): with pytest.raises(ValueError): Header(column_names=["a", "b"], target_column_name="c")
from sagemaker_sklearn_extension.decomposition import RobustPCA from sagemaker_sklearn_extension.externals import Header from sagemaker_sklearn_extension.feature_extraction.text import MultiColumnTfidfVectorizer from sagemaker_sklearn_extension.preprocessing import RobustLabelEncoder from sagemaker_sklearn_extension.preprocessing import RobustStandardScaler from sagemaker_sklearn_extension.preprocessing import ThresholdOneHotEncoder from sklearn.compose import ColumnTransformer from sklearn.pipeline import Pipeline # Given a list of column names and target column name, Header can return the index # for given column name HEADER = Header(column_names=[ 'ifa', 'label', 'bundle_vec', 'persona_segment_vec', 'persona_L1_vec', 'persona_L2_vec', 'persona_L3_vec', 'device_vendor_vec', 'device_name_vec', 'device_manufacturer_vec', 'device_model_vec', 'device_year_of_release_vec', 'dev_platform_vec', 'major_os_vec' ], target_column_name='label') def build_feature_transform(): """ Returns the model definition representing feature processing.""" # These features contain a relatively small number of unique items. categorical = HEADER.as_feature_indices(['dev_platform_vec']) # These features can be parsed as natural language. text = HEADER.as_feature_indices([ 'ifa', 'bundle_vec', 'persona_segment_vec', 'persona_L1_vec', 'persona_L2_vec', 'persona_L3_vec', 'device_vendor_vec', 'device_name_vec', 'device_manufacturer_vec', 'device_model_vec',
HEADER = Header( column_names=[ 'activity', 'tBodyAcc.mean.X', 'tBodyAcc.mean.Y', 'tBodyAcc.mean.Z', 'tBodyAcc.std.X', 'tBodyAcc.std.Y', 'tBodyAcc.std.Z', 'tBodyAcc.mad.X', 'tBodyAcc.mad.Y', 'tBodyAcc.mad.Z', 'tBodyAcc.max.X', 'tBodyAcc.max.Y', 'tBodyAcc.max.Z', 'tBodyAcc.min.X', 'tBodyAcc.min.Y', 'tBodyAcc.min.Z', 'tBodyAcc.sma', 'tBodyAcc.energy.X', 'tBodyAcc.energy.Y', 'tBodyAcc.energy.Z', 'tBodyAcc.iqr.X', 'tBodyAcc.iqr.Y', 'tBodyAcc.iqr.Z', 'tBodyAcc.entropy.X', 'tBodyAcc.entropy.Y', 'tBodyAcc.entropy.Z', 'tBodyAcc.arCoeff.X.1', 'tBodyAcc.arCoeff.X.2', 'tBodyAcc.arCoeff.X.3', 'tBodyAcc.arCoeff.X.4', 'tBodyAcc.arCoeff.Y.1', 'tBodyAcc.arCoeff.Y.2', 'tBodyAcc.arCoeff.Y.3', 'tBodyAcc.arCoeff.Y.4', 'tBodyAcc.arCoeff.Z.1', 'tBodyAcc.arCoeff.Z.2', 'tBodyAcc.arCoeff.Z.3', 'tBodyAcc.arCoeff.Z.4', 'tBodyAcc.correlation.X.Y', 'tBodyAcc.correlation.X.Z', 'tBodyAcc.correlation.Y.Z', 'tGravityAcc.mean.X', 'tGravityAcc.mean.Y', 'tGravityAcc.mean.Z', 'tGravityAcc.std.X', 'tGravityAcc.std.Y', 'tGravityAcc.std.Z', 'tGravityAcc.mad.X', 'tGravityAcc.mad.Y', 'tGravityAcc.mad.Z', 'tGravityAcc.max.X', 'tGravityAcc.max.Y', 'tGravityAcc.max.Z', 'tGravityAcc.min.X', 'tGravityAcc.min.Y', 'tGravityAcc.min.Z', 'tGravityAcc.sma', 'tGravityAcc.energy.X', 'tGravityAcc.energy.Y', 'tGravityAcc.energy.Z', 'tGravityAcc.iqr.X', 'tGravityAcc.iqr.Y', 'tGravityAcc.iqr.Z', 'tGravityAcc.entropy.X', 'tGravityAcc.entropy.Y', 'tGravityAcc.entropy.Z', 'tGravityAcc.arCoeff.X.1', 'tGravityAcc.arCoeff.X.2', 'tGravityAcc.arCoeff.X.3', 'tGravityAcc.arCoeff.X.4', 'tGravityAcc.arCoeff.Y.1', 'tGravityAcc.arCoeff.Y.2', 'tGravityAcc.arCoeff.Y.3', 'tGravityAcc.arCoeff.Y.4', 'tGravityAcc.arCoeff.Z.1', 'tGravityAcc.arCoeff.Z.2', 'tGravityAcc.arCoeff.Z.3', 'tGravityAcc.arCoeff.Z.4', 'tGravityAcc.correlation.X.Y', 'tGravityAcc.correlation.X.Z', 'tGravityAcc.correlation.Y.Z', 'tBodyAccJerk.mean.X', 'tBodyAccJerk.mean.Y', 'tBodyAccJerk.mean.Z', 'tBodyAccJerk.std.X', 'tBodyAccJerk.std.Y', 'tBodyAccJerk.std.Z', 'tBodyAccJerk.mad.X', 'tBodyAccJerk.mad.Y', 'tBodyAccJerk.mad.Z', 'tBodyAccJerk.max.X', 'tBodyAccJerk.max.Y', 'tBodyAccJerk.max.Z', 'tBodyAccJerk.min.X', 'tBodyAccJerk.min.Y', 'tBodyAccJerk.min.Z', 'tBodyAccJerk.sma', 'tBodyAccJerk.energy.X', 'tBodyAccJerk.energy.Y', 'tBodyAccJerk.energy.Z', 'tBodyAccJerk.iqr.X', 'tBodyAccJerk.iqr.Y', 'tBodyAccJerk.iqr.Z', 'tBodyAccJerk.entropy.X', 'tBodyAccJerk.entropy.Y', 'tBodyAccJerk.entropy.Z', 'tBodyAccJerk.arCoeff.X.1', 'tBodyAccJerk.arCoeff.X.2', 'tBodyAccJerk.arCoeff.X.3', 'tBodyAccJerk.arCoeff.X.4', 'tBodyAccJerk.arCoeff.Y.1', 'tBodyAccJerk.arCoeff.Y.2', 'tBodyAccJerk.arCoeff.Y.3', 'tBodyAccJerk.arCoeff.Y.4', 'tBodyAccJerk.arCoeff.Z.1', 'tBodyAccJerk.arCoeff.Z.2', 'tBodyAccJerk.arCoeff.Z.3', 'tBodyAccJerk.arCoeff.Z.4', 'tBodyAccJerk.correlation.X.Y', 'tBodyAccJerk.correlation.X.Z', 'tBodyAccJerk.correlation.Y.Z', 'tBodyGyro.mean.X', 'tBodyGyro.mean.Y', 'tBodyGyro.mean.Z', 'tBodyGyro.std.X', 'tBodyGyro.std.Y', 'tBodyGyro.std.Z', 'tBodyGyro.mad.X', 'tBodyGyro.mad.Y', 'tBodyGyro.mad.Z', 'tBodyGyro.max.X', 'tBodyGyro.max.Y', 'tBodyGyro.max.Z', 'tBodyGyro.min.X', 'tBodyGyro.min.Y', 'tBodyGyro.min.Z', 'tBodyGyro.sma', 'tBodyGyro.energy.X', 'tBodyGyro.energy.Y', 'tBodyGyro.energy.Z', 'tBodyGyro.iqr.X', 'tBodyGyro.iqr.Y', 'tBodyGyro.iqr.Z', 'tBodyGyro.entropy.X', 'tBodyGyro.entropy.Y', 'tBodyGyro.entropy.Z', 'tBodyGyro.arCoeff.X.1', 'tBodyGyro.arCoeff.X.2', 'tBodyGyro.arCoeff.X.3', 'tBodyGyro.arCoeff.X.4', 'tBodyGyro.arCoeff.Y.1', 'tBodyGyro.arCoeff.Y.2', 'tBodyGyro.arCoeff.Y.3', 'tBodyGyro.arCoeff.Y.4', 'tBodyGyro.arCoeff.Z.1', 'tBodyGyro.arCoeff.Z.2', 'tBodyGyro.arCoeff.Z.3', 'tBodyGyro.arCoeff.Z.4', 'tBodyGyro.correlation.X.Y', 'tBodyGyro.correlation.X.Z', 'tBodyGyro.correlation.Y.Z', 'tBodyGyroJerk.mean.X', 'tBodyGyroJerk.mean.Y', 'tBodyGyroJerk.mean.Z', 'tBodyGyroJerk.std.X', 'tBodyGyroJerk.std.Y', 'tBodyGyroJerk.std.Z', 'tBodyGyroJerk.mad.X', 'tBodyGyroJerk.mad.Y', 'tBodyGyroJerk.mad.Z', 'tBodyGyroJerk.max.X', 'tBodyGyroJerk.max.Y', 'tBodyGyroJerk.max.Z', 'tBodyGyroJerk.min.X', 'tBodyGyroJerk.min.Y', 'tBodyGyroJerk.min.Z', 'tBodyGyroJerk.sma', 'tBodyGyroJerk.energy.X', 'tBodyGyroJerk.energy.Y', 'tBodyGyroJerk.energy.Z', 'tBodyGyroJerk.iqr.X', 'tBodyGyroJerk.iqr.Y', 'tBodyGyroJerk.iqr.Z', 'tBodyGyroJerk.entropy.X', 'tBodyGyroJerk.entropy.Y', 'tBodyGyroJerk.entropy.Z', 'tBodyGyroJerk.arCoeff.X.1', 'tBodyGyroJerk.arCoeff.X.2', 'tBodyGyroJerk.arCoeff.X.3', 'tBodyGyroJerk.arCoeff.X.4', 'tBodyGyroJerk.arCoeff.Y.1', 'tBodyGyroJerk.arCoeff.Y.2', 'tBodyGyroJerk.arCoeff.Y.3', 'tBodyGyroJerk.arCoeff.Y.4', 'tBodyGyroJerk.arCoeff.Z.1', 'tBodyGyroJerk.arCoeff.Z.2', 'tBodyGyroJerk.arCoeff.Z.3', 'tBodyGyroJerk.arCoeff.Z.4', 'tBodyGyroJerk.correlation.X.Y', 'tBodyGyroJerk.correlation.X.Z', 'tBodyGyroJerk.correlation.Y.Z', 'tBodyAccMag.mean', 'tBodyAccMag.std', 'tBodyAccMag.mad', 'tBodyAccMag.max', 'tBodyAccMag.min', 'tBodyAccMag.sma', 'tBodyAccMag.energy', 'tBodyAccMag.iqr', 'tBodyAccMag.entropy', 'tBodyAccMag.arCoeff1', 'tBodyAccMag.arCoeff2', 'tBodyAccMag.arCoeff3', 'tBodyAccMag.arCoeff4', 'tGravityAccMag.mean', 'tGravityAccMag.std', 'tGravityAccMag.mad', 'tGravityAccMag.max', 'tGravityAccMag.min', 'tGravityAccMag.sma', 'tGravityAccMag.energy', 'tGravityAccMag.iqr', 'tGravityAccMag.entropy', 'tGravityAccMag.arCoeff1', 'tGravityAccMag.arCoeff2', 'tGravityAccMag.arCoeff3', 'tGravityAccMag.arCoeff4', 'tBodyAccJerkMag.mean', 'tBodyAccJerkMag.std', 'tBodyAccJerkMag.mad', 'tBodyAccJerkMag.max', 'tBodyAccJerkMag.min', 'tBodyAccJerkMag.sma', 'tBodyAccJerkMag.energy', 'tBodyAccJerkMag.iqr', 'tBodyAccJerkMag.entropy', 'tBodyAccJerkMag.arCoeff1', 'tBodyAccJerkMag.arCoeff2', 'tBodyAccJerkMag.arCoeff3', 'tBodyAccJerkMag.arCoeff4', 'tBodyGyroMag.mean', 'tBodyGyroMag.std', 'tBodyGyroMag.mad', 'tBodyGyroMag.max', 'tBodyGyroMag.min', 'tBodyGyroMag.sma', 'tBodyGyroMag.energy', 'tBodyGyroMag.iqr', 'tBodyGyroMag.entropy', 'tBodyGyroMag.arCoeff1', 'tBodyGyroMag.arCoeff2', 'tBodyGyroMag.arCoeff3', 'tBodyGyroMag.arCoeff4', 'tBodyGyroJerkMag.mean', 'tBodyGyroJerkMag.std', 'tBodyGyroJerkMag.mad', 'tBodyGyroJerkMag.max', 'tBodyGyroJerkMag.min', 'tBodyGyroJerkMag.sma', 'tBodyGyroJerkMag.energy', 'tBodyGyroJerkMag.iqr', 'tBodyGyroJerkMag.entropy', 'tBodyGyroJerkMag.arCoeff1', 'tBodyGyroJerkMag.arCoeff2', 'tBodyGyroJerkMag.arCoeff3', 'tBodyGyroJerkMag.arCoeff4', 'fBodyAcc.mean.X', 'fBodyAcc.mean.Y', 'fBodyAcc.mean.Z', 'fBodyAcc.std.X', 'fBodyAcc.std.Y', 'fBodyAcc.std.Z', 'fBodyAcc.mad.X', 'fBodyAcc.mad.Y', 'fBodyAcc.mad.Z', 'fBodyAcc.max.X', 'fBodyAcc.max.Y', 'fBodyAcc.max.Z', 'fBodyAcc.min.X', 'fBodyAcc.min.Y', 'fBodyAcc.min.Z', 'fBodyAcc.sma', 'fBodyAcc.energy.X', 'fBodyAcc.energy.Y', 'fBodyAcc.energy.Z', 'fBodyAcc.iqr.X', 'fBodyAcc.iqr.Y', 'fBodyAcc.iqr.Z', 'fBodyAcc.entropy.X', 'fBodyAcc.entropy.Y', 'fBodyAcc.entropy.Z', 'fBodyAcc.maxInds.X', 'fBodyAcc.maxInds.Y', 'fBodyAcc.maxInds.Z', 'fBodyAcc.meanFreq.X', 'fBodyAcc.meanFreq.Y', 'fBodyAcc.meanFreq.Z', 'fBodyAcc.skewness.X', 'fBodyAcc.kurtosis.X', 'fBodyAcc.skewness.Y', 'fBodyAcc.kurtosis.Y', 'fBodyAcc.skewness.Z', 'fBodyAcc.kurtosis.Z', 'fBodyAcc.bandsEnergy.1.8', 'fBodyAcc.bandsEnergy.9.16', 'fBodyAcc.bandsEnergy.17.24', 'fBodyAcc.bandsEnergy.25.32', 'fBodyAcc.bandsEnergy.33.40', 'fBodyAcc.bandsEnergy.41.48', 'fBodyAcc.bandsEnergy.49.56', 'fBodyAcc.bandsEnergy.57.64', 'fBodyAcc.bandsEnergy.1.16', 'fBodyAcc.bandsEnergy.17.32', 'fBodyAcc.bandsEnergy.33.48', 'fBodyAcc.bandsEnergy.49.64', 'fBodyAcc.bandsEnergy.1.24', 'fBodyAcc.bandsEnergy.25.48', 'fBodyAcc.bandsEnergy.1.8.1', 'fBodyAcc.bandsEnergy.9.16.1', 'fBodyAcc.bandsEnergy.17.24.1', 'fBodyAcc.bandsEnergy.25.32.1', 'fBodyAcc.bandsEnergy.33.40.1', 'fBodyAcc.bandsEnergy.41.48.1', 'fBodyAcc.bandsEnergy.49.56.1', 'fBodyAcc.bandsEnergy.57.64.1', 'fBodyAcc.bandsEnergy.1.16.1', 'fBodyAcc.bandsEnergy.17.32.1', 'fBodyAcc.bandsEnergy.33.48.1', 'fBodyAcc.bandsEnergy.49.64.1', 'fBodyAcc.bandsEnergy.1.24.1', 'fBodyAcc.bandsEnergy.25.48.1', 'fBodyAcc.bandsEnergy.1.8.2', 'fBodyAcc.bandsEnergy.9.16.2', 'fBodyAcc.bandsEnergy.17.24.2', 'fBodyAcc.bandsEnergy.25.32.2', 'fBodyAcc.bandsEnergy.33.40.2', 'fBodyAcc.bandsEnergy.41.48.2', 'fBodyAcc.bandsEnergy.49.56.2', 'fBodyAcc.bandsEnergy.57.64.2', 'fBodyAcc.bandsEnergy.1.16.2', 'fBodyAcc.bandsEnergy.17.32.2', 'fBodyAcc.bandsEnergy.33.48.2', 'fBodyAcc.bandsEnergy.49.64.2', 'fBodyAcc.bandsEnergy.1.24.2', 'fBodyAcc.bandsEnergy.25.48.2', 'fBodyAccJerk.mean.X', 'fBodyAccJerk.mean.Y', 'fBodyAccJerk.mean.Z', 'fBodyAccJerk.std.X', 'fBodyAccJerk.std.Y', 'fBodyAccJerk.std.Z', 'fBodyAccJerk.mad.X', 'fBodyAccJerk.mad.Y', 'fBodyAccJerk.mad.Z', 'fBodyAccJerk.max.X', 'fBodyAccJerk.max.Y', 'fBodyAccJerk.max.Z', 'fBodyAccJerk.min.X', 'fBodyAccJerk.min.Y', 'fBodyAccJerk.min.Z', 'fBodyAccJerk.sma', 'fBodyAccJerk.energy.X', 'fBodyAccJerk.energy.Y', 'fBodyAccJerk.energy.Z', 'fBodyAccJerk.iqr.X', 'fBodyAccJerk.iqr.Y', 'fBodyAccJerk.iqr.Z', 'fBodyAccJerk.entropy.X', 'fBodyAccJerk.entropy.Y', 'fBodyAccJerk.entropy.Z', 'fBodyAccJerk.maxInds.X', 'fBodyAccJerk.maxInds.Y', 'fBodyAccJerk.maxInds.Z', 'fBodyAccJerk.meanFreq.X', 'fBodyAccJerk.meanFreq.Y', 'fBodyAccJerk.meanFreq.Z', 'fBodyAccJerk.skewness.X', 'fBodyAccJerk.kurtosis.X', 'fBodyAccJerk.skewness.Y', 'fBodyAccJerk.kurtosis.Y', 'fBodyAccJerk.skewness.Z', 'fBodyAccJerk.kurtosis.Z', 'fBodyAccJerk.bandsEnergy.1.8', 'fBodyAccJerk.bandsEnergy.9.16', 'fBodyAccJerk.bandsEnergy.17.24', 'fBodyAccJerk.bandsEnergy.25.32', 'fBodyAccJerk.bandsEnergy.33.40', 'fBodyAccJerk.bandsEnergy.41.48', 'fBodyAccJerk.bandsEnergy.49.56', 'fBodyAccJerk.bandsEnergy.57.64', 'fBodyAccJerk.bandsEnergy.1.16', 'fBodyAccJerk.bandsEnergy.17.32', 'fBodyAccJerk.bandsEnergy.33.48', 'fBodyAccJerk.bandsEnergy.49.64', 'fBodyAccJerk.bandsEnergy.1.24', 'fBodyAccJerk.bandsEnergy.25.48', 'fBodyAccJerk.bandsEnergy.1.8.1', 'fBodyAccJerk.bandsEnergy.9.16.1', 'fBodyAccJerk.bandsEnergy.17.24.1', 'fBodyAccJerk.bandsEnergy.25.32.1', 'fBodyAccJerk.bandsEnergy.33.40.1', 'fBodyAccJerk.bandsEnergy.41.48.1', 'fBodyAccJerk.bandsEnergy.49.56.1', 'fBodyAccJerk.bandsEnergy.57.64.1', 'fBodyAccJerk.bandsEnergy.1.16.1', 'fBodyAccJerk.bandsEnergy.17.32.1', 'fBodyAccJerk.bandsEnergy.33.48.1', 'fBodyAccJerk.bandsEnergy.49.64.1', 'fBodyAccJerk.bandsEnergy.1.24.1', 'fBodyAccJerk.bandsEnergy.25.48.1', 'fBodyAccJerk.bandsEnergy.1.8.2', 'fBodyAccJerk.bandsEnergy.9.16.2', 'fBodyAccJerk.bandsEnergy.17.24.2', 'fBodyAccJerk.bandsEnergy.25.32.2', 'fBodyAccJerk.bandsEnergy.33.40.2', 'fBodyAccJerk.bandsEnergy.41.48.2', 'fBodyAccJerk.bandsEnergy.49.56.2', 'fBodyAccJerk.bandsEnergy.57.64.2', 'fBodyAccJerk.bandsEnergy.1.16.2', 'fBodyAccJerk.bandsEnergy.17.32.2', 'fBodyAccJerk.bandsEnergy.33.48.2', 'fBodyAccJerk.bandsEnergy.49.64.2', 'fBodyAccJerk.bandsEnergy.1.24.2', 'fBodyAccJerk.bandsEnergy.25.48.2', 'fBodyGyro.mean.X', 'fBodyGyro.mean.Y', 'fBodyGyro.mean.Z', 'fBodyGyro.std.X', 'fBodyGyro.std.Y', 'fBodyGyro.std.Z', 'fBodyGyro.mad.X', 'fBodyGyro.mad.Y', 'fBodyGyro.mad.Z', 'fBodyGyro.max.X', 'fBodyGyro.max.Y', 'fBodyGyro.max.Z', 'fBodyGyro.min.X', 'fBodyGyro.min.Y', 'fBodyGyro.min.Z', 'fBodyGyro.sma', 'fBodyGyro.energy.X', 'fBodyGyro.energy.Y', 'fBodyGyro.energy.Z', 'fBodyGyro.iqr.X', 'fBodyGyro.iqr.Y', 'fBodyGyro.iqr.Z', 'fBodyGyro.entropy.X', 'fBodyGyro.entropy.Y', 'fBodyGyro.entropy.Z', 'fBodyGyro.maxInds.X', 'fBodyGyro.maxInds.Y', 'fBodyGyro.maxInds.Z', 'fBodyGyro.meanFreq.X', 'fBodyGyro.meanFreq.Y', 'fBodyGyro.meanFreq.Z', 'fBodyGyro.skewness.X', 'fBodyGyro.kurtosis.X', 'fBodyGyro.skewness.Y', 'fBodyGyro.kurtosis.Y', 'fBodyGyro.skewness.Z', 'fBodyGyro.kurtosis.Z', 'fBodyGyro.bandsEnergy.1.8', 'fBodyGyro.bandsEnergy.9.16', 'fBodyGyro.bandsEnergy.17.24', 'fBodyGyro.bandsEnergy.25.32', 'fBodyGyro.bandsEnergy.33.40', 'fBodyGyro.bandsEnergy.41.48', 'fBodyGyro.bandsEnergy.49.56', 'fBodyGyro.bandsEnergy.57.64', 'fBodyGyro.bandsEnergy.1.16', 'fBodyGyro.bandsEnergy.17.32', 'fBodyGyro.bandsEnergy.33.48', 'fBodyGyro.bandsEnergy.49.64', 'fBodyGyro.bandsEnergy.1.24', 'fBodyGyro.bandsEnergy.25.48', 'fBodyGyro.bandsEnergy.1.8.1', 'fBodyGyro.bandsEnergy.9.16.1', 'fBodyGyro.bandsEnergy.17.24.1', 'fBodyGyro.bandsEnergy.25.32.1', 'fBodyGyro.bandsEnergy.33.40.1', 'fBodyGyro.bandsEnergy.41.48.1', 'fBodyGyro.bandsEnergy.49.56.1', 'fBodyGyro.bandsEnergy.57.64.1', 'fBodyGyro.bandsEnergy.1.16.1', 'fBodyGyro.bandsEnergy.17.32.1', 'fBodyGyro.bandsEnergy.33.48.1', 'fBodyGyro.bandsEnergy.49.64.1', 'fBodyGyro.bandsEnergy.1.24.1', 'fBodyGyro.bandsEnergy.25.48.1', 'fBodyGyro.bandsEnergy.1.8.2', 'fBodyGyro.bandsEnergy.9.16.2', 'fBodyGyro.bandsEnergy.17.24.2', 'fBodyGyro.bandsEnergy.25.32.2', 'fBodyGyro.bandsEnergy.33.40.2', 'fBodyGyro.bandsEnergy.41.48.2', 'fBodyGyro.bandsEnergy.49.56.2', 'fBodyGyro.bandsEnergy.57.64.2', 'fBodyGyro.bandsEnergy.1.16.2', 'fBodyGyro.bandsEnergy.17.32.2', 'fBodyGyro.bandsEnergy.33.48.2', 'fBodyGyro.bandsEnergy.49.64.2', 'fBodyGyro.bandsEnergy.1.24.2', 'fBodyGyro.bandsEnergy.25.48.2', 'fBodyAccMag.mean', 'fBodyAccMag.std', 'fBodyAccMag.mad', 'fBodyAccMag.max', 'fBodyAccMag.min', 'fBodyAccMag.sma', 'fBodyAccMag.energy', 'fBodyAccMag.iqr', 'fBodyAccMag.entropy', 'fBodyAccMag.maxInds', 'fBodyAccMag.meanFreq', 'fBodyAccMag.skewness', 'fBodyAccMag.kurtosis', 'fBodyBodyAccJerkMag.mean', 'fBodyBodyAccJerkMag.std', 'fBodyBodyAccJerkMag.mad', 'fBodyBodyAccJerkMag.max', 'fBodyBodyAccJerkMag.min', 'fBodyBodyAccJerkMag.sma', 'fBodyBodyAccJerkMag.energy', 'fBodyBodyAccJerkMag.iqr', 'fBodyBodyAccJerkMag.entropy', 'fBodyBodyAccJerkMag.maxInds', 'fBodyBodyAccJerkMag.meanFreq', 'fBodyBodyAccJerkMag.skewness', 'fBodyBodyAccJerkMag.kurtosis', 'fBodyBodyGyroMag.mean', 'fBodyBodyGyroMag.std', 'fBodyBodyGyroMag.mad', 'fBodyBodyGyroMag.max', 'fBodyBodyGyroMag.min', 'fBodyBodyGyroMag.sma', 'fBodyBodyGyroMag.energy', 'fBodyBodyGyroMag.iqr', 'fBodyBodyGyroMag.entropy', 'fBodyBodyGyroMag.maxInds', 'fBodyBodyGyroMag.meanFreq', 'fBodyBodyGyroMag.skewness', 'fBodyBodyGyroMag.kurtosis', 'fBodyBodyGyroJerkMag.mean', 'fBodyBodyGyroJerkMag.std', 'fBodyBodyGyroJerkMag.mad', 'fBodyBodyGyroJerkMag.max', 'fBodyBodyGyroJerkMag.min', 'fBodyBodyGyroJerkMag.sma', 'fBodyBodyGyroJerkMag.energy', 'fBodyBodyGyroJerkMag.iqr', 'fBodyBodyGyroJerkMag.entropy', 'fBodyBodyGyroJerkMag.maxInds', 'fBodyBodyGyroJerkMag.meanFreq', 'fBodyBodyGyroJerkMag.skewness', 'fBodyBodyGyroJerkMag.kurtosis', 'angle.tBodyAccMean.gravity', 'angle.tBodyAccJerkMean.gravityMean', 'angle.tBodyGyroMean.gravityMean', 'angle.tBodyGyroJerkMean.gravityMean', 'angle.X.gravityMean', 'angle.Y.gravityMean', 'angle.Z.gravityMean' ], target_column_name='activity' )
def test_header_feature_column_index_order(): h = Header(column_names=["a", "b", "c", "d"], target_column_name="c") assert h.feature_column_indices == [0, 1, 3]