/// <summary> /// Auto-detect purpose for the data view columns. /// </summary> public static PurposeInference.Column[] InferPurposes(MLContext context, IDataView data, string label, PurposeInference.Column[] columnOverrides = null) { var labelColumn = data.GetColumn(label); // select columns to include in inferencing var columnIndices = CalcIncludedIndices(data.Schema.Count, labelColumn.Index, columnOverrides); // do purpose inferencing var intermediateCols = InferPurposes(context, data, columnIndices); // result to return to caller var result = new PurposeInference.Column[data.Schema.Count]; // add label column to result result[labelColumn.Index] = (new IntermediateColumn(data, labelColumn.Index, ColumnPurpose.Label)).GetColumn(); // add inferred columns to result foreach (var intermediateCol in intermediateCols) { result[intermediateCol.ColumnIndex] = intermediateCol.GetColumn(); } // add overrides to result if (columnOverrides != null) { foreach (var columnOverride in columnOverrides) { result[columnOverride.ColumnIndex] = columnOverride; } } return(result); }
internal PurposeInference.Column[] ToInternalColumnPurposes() { var columnIndexList = AutoMlUtils.GetColumnIndexList(Source); var result = new PurposeInference.Column[columnIndexList.Count]; for (var i = 0; i < columnIndexList.Count; i++) { var internalColumn = new PurposeInference.Column(columnIndexList[i], ColumnPurpose, Type); result[i] = internalColumn; } return(result); }
public IntermediateColumn(IDataView data, PurposeInference.Column column) { _data = data; _columnId = column.ColumnIndex; _purpose = column.Purpose; _type = new Lazy <ColumnType>(() => _data.Schema[_columnId].Type); _columnName = new Lazy <string>(() => _data.Schema[_columnId].Name); _hasMissing = new Lazy <bool>(() => { if (Type.ItemType() != NumberType.R4) { return(false); } return(Type.IsVector() ? HasMissingVector() : HasMissingOne()); }); }