Commands\ShowSchemaCommand.cs (6)
140var type = schema[col].Type;
155DataViewType typeNames;
193var type = metaColumn.Type;
207private static void ShowMetadataValue(IndentedTextWriter itw, DataViewSchema schema, int col, string kind, DataViewType type)
222Action<IndentedTextWriter, DataViewSchema, int, string, DataViewType> del = ShowMetadataValue<int>;
227private static void ShowMetadataValue<T>(IndentedTextWriter itw, DataViewSchema schema, int col, string kind, DataViewType type)
Data\Conversion.cs (20)
367public ValueMapper<TSrc, TDst> GetStandardConversion<TSrc, TDst>(DataViewType typeSrc, DataViewType typeDst,
381public bool TryGetStandardConversion<TSrc, TDst>(DataViewType typeSrc, DataViewType typeDst,
403public Delegate GetStandardConversion(DataViewType typeSrc, DataViewType typeDst)
416public bool TryGetStandardConversion(DataViewType typeSrc, DataViewType typeDst,
470public ValueMapper<TSrc, SB> GetStringConversion<TSrc>(DataViewType type)
486public bool TryGetStringConversion<TSrc>(DataViewType type, out ValueMapper<TSrc, SB> conv)
538public TryParseMapper<TDst> GetTryParseConversion<TDst>(DataViewType typeDst)
620public InPredicate<T> GetIsDefaultPredicate<T>(DataViewType type)
626var t = type;
634public InPredicate<T> GetIsNAPredicate<T>(DataViewType type)
642public bool TryGetIsNAPredicate<T>(DataViewType type, out InPredicate<T> pred)
659public bool TryGetIsNAPredicate(DataViewType type, out Delegate del)
664var t = type;
705public T GetNAOrDefault<T>(DataViewType type)
723public T GetNAOrDefault<T>(DataViewType type, out bool isDefault)
753public ValueGetter<T> GetNAOrDefaultGetter<T>(DataViewType type)
Data\DataViewTypeManager.cs (16)
15/// A singleton class for managing the map between ML.NET <see cref="DataViewType"/> and C# <see cref="Type"/>.
17/// should be registered with a class derived from <see cref="DataViewType"/>.
37/// Mapping from a <see cref="Type"/> plus its <see cref="Attribute"/>s to a <see cref="DataViewType"/>.
39private static readonly Dictionary<TypeWithAttributes, DataViewType> _rawTypeToDataViewTypeMap = new Dictionary<TypeWithAttributes, DataViewType>();
42/// Mapping from a <see cref="DataViewType"/> to a <see cref="Type"/> plus its <see cref="Attribute"/>s.
44private static readonly Dictionary<DataViewType, TypeWithAttributes> _dataViewTypeToRawTypeMap = new Dictionary<DataViewType, TypeWithAttributes>();
52/// Returns the <see cref="DataViewType"/> registered for <paramref name="type"/> and its <paramref name="typeAttributes"/>.
54internal static DataViewType GetDataViewType(Type type, IEnumerable<Attribute> typeAttributes = null)
77if (!_rawTypeToDataViewTypeMap.TryGetValue(rawType, out DataViewType dataViewType))
86/// If <paramref name="type"/> has been registered with a <see cref="DataViewType"/>, this function returns <see langword="true"/>.
124internal static bool Knows(DataViewType dataViewType)
145public static void Register(DataViewType dataViewType, Type type, IEnumerable<Attribute> typeAttributes)
176public static void Register(DataViewType dataViewType, Type type, DataViewTypeAttribute typeAttribute = null)
196var associatedDataViewType = _rawTypeToDataViewTypeMap[rawType];
Data\RowCursorUtils.cs (18)
53public static Delegate GetGetterAs(DataViewType typeDst, DataViewRow row, int col)
61var typeSrc = row.Schema[col].Type;
64Func<DataViewType, DataViewType, DataViewRow, int, ValueGetter<int>> del = GetGetterAsCore<int, int>;
73public static ValueGetter<TDst> GetGetterAs<TDst>(DataViewType typeDst, DataViewRow row, int col)
82var typeSrc = row.Schema[col].Type;
85Func<DataViewType, DataViewType, DataViewRow, int, ValueGetter<TDst>> del = GetGetterAsCore<int, TDst>;
90private static ValueGetter<TDst> GetGetterAsCore<TSrc, TDst>(DataViewType typeSrc, DataViewType typeDst, DataViewRow row, int col)
115/// <see cref="Conversions.GetStringConversion{TSrc}(DataViewType)"/> on the input
127var typeSrc = row.Schema[col].Type;
132private static ValueGetter<StringBuilder> GetGetterAsStringBuilderCore<TSrc>(DataViewType typeSrc, DataViewRow row, int col)
308DataViewType type = cursor.Schema[col].Type;
336public static string TestGetLabelGetter(DataViewType type)
341public static string TestGetLabelGetter(DataViewType type, bool allowKeys)
354var type = cursor.Schema[labelIndex].Type;
376var type = cursor.Schema[labelIndex].Type;
DataLoadSave\Binary\BinarySaver.cs (8)
348private delegate IValueCodec WriteMetadataCoreDelegate(Stream stream, DataViewSchema schema, int col, string kind, DataViewType type, out CompressionKind compression);
350private IValueCodec WriteMetadataCore<T>(Stream stream, DataViewSchema schema, int col, string kind, DataViewType type, out CompressionKind compressionKind)
637public bool IsColumnSavable(DataViewType type)
718DataViewType type = schema[colIndices[c]].Type;
805public bool TryWriteTypeDescription(Stream stream, DataViewType type, out int bytesWritten)
829public DataViewType LoadTypeDescriptionOrNull(Stream stream)
847public bool TryWriteTypeAndValue<T>(Stream stream, DataViewType type, ref T value, out int bytesWritten)
882public bool TryLoadTypeAndValue(Stream stream, out DataViewType type, out object value)
DataView\DataViewConstructionUtils.cs (9)
204private static readonly FuncInstanceMethodInfo1<InputRowBase<TRow>, Delegate, DataViewType, Delegate> _createKeyGetterDelegateMethodInfo
205= FuncInstanceMethodInfo1<InputRowBase<TRow>, Delegate, DataViewType, Delegate>.Create(target => target.CreateKeyGetterDelegate<int>);
234private Delegate CreateGetter(DataViewType colType, InternalSchemaDefinition.Column column, Delegate peek)
375private Delegate CreateKeyGetterDelegate<TDst>(Delegate peekDel, DataViewType colType)
831public DataViewType AnnotationType;
842private protected AnnotationInfo(string kind, DataViewType annotationType)
875public AnnotationInfo(string kind, T value, DataViewType annotationType = null)
887annotationType = isVector ? new VectorDataViewType(primitiveItemType) : (DataViewType)primitiveItemType;
900DataViewType annotationItemType = annotationVectorType?.ItemType ?? annotationType;
DataView\InternalSchemaDefinition.cs (9)
27public readonly DataViewType ColumnType;
35public Column(string columnName, DataViewType columnType, MemberInfo memberInfo) :
39public Column(string columnName, DataViewType columnType, MemberInfo memberInfo,
44public Column(string columnName, DataViewType columnType, Delegate generator) :
48public Column(string columnName, DataViewType columnType, Delegate generator,
53private Column(string columnName, DataViewType columnType, MemberInfo memberInfo = null,
264DataViewType colType;
269colType = isVector ? new VectorDataViewType(itemType) : (DataViewType)itemType;
281DataViewType itemType = columnVectorType?.ItemType ?? col.ColumnType;
DataView\LambdaColumnMapper.cs (8)
21string src, string dst, DataViewType typeSrc, DataViewType typeDst, ValueMapper<TSrc, TDst> mapper,
49var typeOrig = input.Schema[colSrc].Type;
72Func<IHostEnvironment, string, IDataView, Column, DataViewType, ValueMapper<int, int>,
85DataViewType typeDst, ValueMapper<T1, T2> map1, ValueMapper<T2, T3> map2,
102private readonly DataViewType _typeDst;
107DataViewType typeDst, ValueMapper<T1, T2> map1, ValueMapper<T2, T3> map2 = null,
148protected override DataViewType GetColumnTypeCore(int iinfo)
Evaluators\EvaluatorUtils.cs (28)
87var columnType = schema[col].Annotations.Schema.GetColumnOrNull(AnnotationUtils.Kinds.ScoreColumnKind)?.Type;
99var columnType = schema[col].Annotations.Schema.GetColumnOrNull(AnnotationUtils.Kinds.ScoreColumnKind)?.Type;
164int colScore, string valueKind, Func<DataViewType, bool> testType)
186var type = schema[colScore].Annotations.Schema.GetColumnOrNull(AnnotationUtils.Kinds.ScoreColumnSetId)?.Type;
222var type = schema[col].Annotations.Schema.GetColumnOrNull(AnnotationUtils.Kinds.ScoreColumnKind)?.Type;
244public static void CheckWeightType(IExceptionContext ectx, DataViewType type)
288var type = cursor.Schema[stratCol].Type;
306var type = schema[i].Type;
376DataViewType typeSrc, string value, string registrationName)
404var inputColType = input.Schema[0].Type;
410DataViewType typeSrc, int keyCount, int value, string registrationName, ValueGetter<VBuffer<ReadOnlyMemory<char>>> keyValueGetter)
446var inputColType = input.Schema[inputCol].Type;
469var typeSrc = new DataViewType[numIdvs];
478var type = typeSrc[i] = idv.Schema[col].Type;
568var type = schema[indices[i]].Type;
569var keyValueType = schema[indices[i]].Annotations.Schema.GetColumnOrNull(AnnotationUtils.Kinds.KeyValues)?.Type;
574DataViewType keyValueItemType = (keyValueType as VectorDataViewType)?.ItemType ?? keyValueType;
577DataViewType typeItemType = vectorType?.ItemType ?? type;
602public static void ReconcileKeyValues(IHostEnvironment env, IDataView[] views, string columnName, DataViewType keyValueType)
672public static void ReconcileVectorKeyValues(IHostEnvironment env, IDataView[] views, string columnName, DataViewType keyValueType)
725var type = views[i].Schema[columnIndices[i]].Type;
815DataViewType labelColKeyValuesType = null;
833var type = dv.Schema[i].Type;
1009var type = schema[i].Type;
1115var type = cursor.Schema[stratCol].Type;
1230var type = schema[i].Type;
1484var stratType = cursor.Schema[stratCol].Type;
1775var type = data.Schema[stratCol].Type;
Scorers\MulticlassClassificationScorer.cs (17)
85private readonly Func<ISchemaBoundMapper, DataViewType, bool> _canWrap;
108string metadataKind, Func<ISchemaBoundMapper, DataViewType, bool> canWrap)
114string metadataKind, Func<ISchemaBoundMapper, DataViewType, bool> canWrap)
139DataViewType type;
239string metadataKind, Func<ISchemaBoundMapper, DataViewType, bool> canWrap)
262private readonly Func<ISchemaBoundMapper, DataViewType, bool> _canWrap;
283string metadataKind, Func<ISchemaBoundMapper, DataViewType, bool> canWrap)
437internal static bool CanWrapTrainingLabels(ISchemaBoundMapper mapper, DataViewType labelNameType)
439if (GetTypesForWrapping(mapper, labelNameType, AnnotationUtils.Kinds.TrainingLabelValues, out var scoreType))
445internal static bool GetTypesForWrapping(ISchemaBoundMapper mapper, DataViewType labelNameType, string metaKind, out DataViewType scoreType)
477internal static bool CanWrapSlotNames(ISchemaBoundMapper mapper, DataViewType labelNameType)
479if (GetTypesForWrapping(mapper, labelNameType, AnnotationUtils.Kinds.SlotNames, out var scoreType))
493var type = trainSchema.Label.Value.Annotations.Schema.GetColumnOrNull(AnnotationUtils.Kinds.KeyValues)?.Type;
603private static DataViewType GetPredColType(DataViewType scoreType, ISchemaBoundRowMapper mapper) => new KeyDataViewType(typeof(uint), scoreType.GetVectorSize());
605private static bool OutputTypeMatches(DataViewType scoreType) =>
Scorers\PredictedLabelScorerBase.cs (20)
40public readonly DataViewType PredColType;
53bool user, int scoreColIndex, DataViewType predColType, string predictedLabelColumnName = DefaultColumnNames.PredictedLabel)
94string scoreColKind, int scoreColIndex, DataViewType predColType, string predictedLabelColumnName = DefaultColumnNames.PredictedLabel)
127Func<DataViewType, bool> outputTypeMatches, Func<DataViewType, ISchemaBoundRowMapper, DataViewType> getPredColType)
151var scoreType = mapper.OutputSchema[scoreColIndex].Type;
153var predColType = getPredColType(scoreType, rowMapper);
171protected override DataViewType GetColumnTypeCore(int iinfo)
179protected override IEnumerable<KeyValuePair<string, DataViewType>> GetAnnotationTypesCore(int iinfo)
192yield return new KeyValuePair<string, DataViewType>(sch[i].Name, sch[i].Type);
202protected override DataViewType GetAnnotationTypeCore(string kind, int iinfo)
284Func<DataViewType, bool> outputTypeMatches, Func<DataViewType, ISchemaBoundRowMapper, DataViewType> getPredColType, string predictedLabelColumnName = DefaultColumnNames.PredictedLabel)
300var scoreType = mapper.OutputSchema[scoreColIndex].Type;
302var predColType = getPredColType(scoreType, rowMapper);
318Func<DataViewType, bool> outputTypeMatches, Func<DataViewType, ISchemaBoundRowMapper, DataViewType> getPredColType)
Transforms\MetadataDispatcher.cs (13)
73public readonly DataViewType Type;
75protected GetterInfo(string kind, DataViewType type)
89protected GetterInfo(string kind, DataViewType type)
104public GetterInfoDelegate(string kind, DataViewType type, AnnotationUtils.AnnotationGetter<TValue> getter)
126public GetterInfoPrimitive(string kind, DataViewType type, TValue value)
204public IEnumerable<KeyValuePair<string, DataViewType>> GetMetadataTypes(int index)
210return Enumerable.Empty<KeyValuePair<string, DataViewType>>();
214private IEnumerable<KeyValuePair<string, DataViewType>> GetTypesCore(int index, ColInfo info)
226yield return new KeyValuePair<string, DataViewType>(g.Kind, g.Type);
236foreach (var kvp in info.SchemaSrc[info.IndexSrc].Annotations.Schema.Select(c => new KeyValuePair<string, DataViewType>(c.Name, c.Type)))
250public DataViewType GetMetadataTypeOrNull(string kind, int index)
406public void AddGetter<TValue>(string kind, DataViewType type,
423public void AddPrimitive<TValue>(string kind, DataViewType type, TValue value)
Transforms\NormalizeColumn.cs (27)
197public string TestType(DataViewType type)
199DataViewType itemType = type;
426public abstract void AttachMetadata(MetadataDispatcher.Builder bldr, DataViewType typeSrc);
430public static AffineColumnFunction Create(ModelLoadContext ctx, IHost host, DataViewType typeSrc)
461public override void AttachMetadata(MetadataDispatcher.Builder bldr, DataViewType typeSrc)
494public override void AttachMetadata(MetadataDispatcher.Builder bldr, DataViewType typeSrc)
546public abstract void AttachMetadata(MetadataDispatcher.Builder bldr, DataViewType typeSrc);
549public static CdfColumnFunction Create(ModelLoadContext ctx, IHost host, DataViewType typeSrc)
583public override void AttachMetadata(MetadataDispatcher.Builder bldr, DataViewType typeSrc)
614public override void AttachMetadata(MetadataDispatcher.Builder bldr, DataViewType typeSrc)
678public void AttachMetadata(MetadataDispatcher.Builder bldr, DataViewType typeSrc)
685public static BinColumnFunction Create(ModelLoadContext ctx, IHost host, DataViewType typeSrc)
812var type = row.Schema[col].Type;
967int icol, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
980int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
1004int icol, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
1018int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
1044int icol, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
1057int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
1084int icol, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
1098int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
1124int icol, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
1132var labelColumnType = cursor.Schema[labelColumnId].Type;
1151string labelColumn, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
1158int labelColumnId, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
1196int icol, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
1211int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
Transforms\NormalizeColumnDbl.cs (8)
665public static new ImplOne Create(ModelLoadContext ctx, IHost host, DataViewType typeSrc)
990public static new ImplOne Create(ModelLoadContext ctx, IHost host, DataViewType typeSrc)
1173public static new ImplOne Create(ModelLoadContext ctx, IHost host, DataViewType typeSrc)
1551public static IColumnFunctionBuilder Create(NormalizingEstimator.MinMaxColumnOptions column, IHost host, DataViewType srcType,
1665public static IColumnFunctionBuilder Create(NormalizingEstimator.MeanVarianceColumnOptions column, IHost host, DataViewType srcType,
1672public static IColumnFunctionBuilder Create(NormalizingEstimator.LogMeanVarianceColumnOptions column, IHost host, DataViewType srcType,
1867public static IColumnFunctionBuilder Create(NormalizingEstimator.BinningColumnOptions column, IHost host, DataViewType srcType,
2084public static IColumnFunctionBuilder Create(NormalizingEstimator.RobustScalingColumnOptions column, IHost host, DataViewType srcType,
Transforms\NormalizeColumnSng.cs (8)
823public static new ImplOne Create(ModelLoadContext ctx, IHost host, DataViewType typeSrc)
1150public static new ImplOne Create(ModelLoadContext ctx, IHost host, DataViewType typeSrc)
1334public static new ImplOne Create(ModelLoadContext ctx, IHost host, DataViewType typeSrc)
1714public static IColumnFunctionBuilder Create(NormalizingEstimator.MinMaxColumnOptions column, IHost host, DataViewType srcType,
1828public static IColumnFunctionBuilder Create(NormalizingEstimator.MeanVarianceColumnOptions column, IHost host, DataViewType srcType,
1835public static IColumnFunctionBuilder Create(NormalizingEstimator.LogMeanVarianceColumnOptions column, IHost host, DataViewType srcType,
2030public static IColumnFunctionBuilder Create(NormalizingEstimator.BinningColumnOptions column, IHost host, DataViewType srcType,
2248public static IColumnFunctionBuilder Create(NormalizingEstimator.RobustScalingColumnOptions column, IHost host, DataViewType srcType,
Transforms\Normalizer.cs (18)
144internal abstract IColumnFunctionBuilder MakeBuilder(IHost host, int srcIndex, DataViewType srcType, DataViewRowCursor cursor);
187internal override IColumnFunctionBuilder MakeBuilder(IHost host, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
205internal override IColumnFunctionBuilder MakeBuilder(IHost host, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
223internal override IColumnFunctionBuilder MakeBuilder(IHost host, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
239internal override IColumnFunctionBuilder MakeBuilder(IHost host, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
263internal override IColumnFunctionBuilder MakeBuilder(IHost host, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
283internal override IColumnFunctionBuilder MakeBuilder(IHost host, int srcIndex, DataViewType srcType, DataViewRowCursor cursor)
413internal readonly DataViewType InputType;
416internal ColumnOptions(string name, string inputColumnName, DataViewType inputType, IColumnFunction columnFunction)
425internal static DataViewType LoadType(ModelLoadContext ctx)
442return isVectorOld ? (DataViewType)(new VectorDataViewType(itemTypeOld, vectorSize)) : itemTypeOld;
462internal static void SaveType(ModelSaveContext ctx, DataViewType type)
475DataViewType itemType = vectorType?.ItemType ?? type;
540var srcTypes = new DataViewType[columns.Length];
626var typeSrc = ColumnOptions.LoadType(ctx);
647var typeSrc = input.Schema[ColumnPairs[iinfo].inputColumnName].Type;
705var colType = inputSchema[srcCol].Type;
709DataViewType itemType = vectorType?.ItemType ?? colType;
Transforms\TransformBase.cs (22)
277public readonly DataViewType TypeSrc;
280public ColInfo(string name, int colSrc, DataViewType typeSrc, VectorDataViewType slotTypeSrc)
328ITransposeDataView transposedInput, Func<DataViewType, string> testType)
349var type = inputSchema[colSrc].Type;
365ITransposeDataView transposeInput, Func<DataViewType, string> testType)
398var type = inputSchema[colSrc].Type;
452protected override DataViewType GetColumnTypeCore(int iinfo)
457protected override IEnumerable<KeyValuePair<string, DataViewType>> GetAnnotationTypesCore(int iinfo)
462protected override DataViewType GetAnnotationTypeCore(string kind, int iinfo)
499IDataView input, Func<DataViewType, string> testType)
513IDataView input, Func<DataViewType, string> testType)
527IDataView input, Func<DataViewType, string> testType)
544IDataView newInput, Func<DataViewType, string> checkType)
666protected abstract DataViewType GetColumnTypeCore(int iinfo);
703protected Delegate GetSrcGetter(DataViewType typeDst, DataViewRow row, int iinfo)
925protected static string TestIsText(DataViewType type)
932protected static string TestIsTextItem(DataViewType type)
939protected static string TestIsTextVector(DataViewType type)
946protected static string TestIsFloatItem(DataViewType type)
953protected static string TestIsFloatVector(DataViewType type)
961protected static string TestIsKnownSizeFloatVector(DataViewType type)
971protected static string TestIsKey(DataViewType type)