public void TestListMovie() { Movie m = new Movie(27, "Krecik", 1999, "Karolina DudziĆska", 4.0, 15, "bla bla bla"); LoM l = new LoM(); l.Dodaj(m); Assert.AreEqual(1, l.Lista.Count); }
// ........................................................................ Initializers public override void Init(DataSet data, string attributeName, bool isMetaVis = false) { base.Init(data, isMetaVis); this.attributeName = attributeName; //this.attributeID = data.IDOf(attributeName); this.lom = data.TypeOf(attributeName); this.max = 0; this.length = 1f; //dict1 = new Dictionary<int, string>(); dict2 = new Dictionary <string, int>(); SetUpAxes(); // .................................................................... initialize switch (lom) { case LoM.NOMINAL: var mN = data.nominalStatistics[attributeName]; uniqueVals = mN.uniqueValues; //dict1 = mN.idValues; dict2 = mN.valueIDs; max = mN.distMax; break; case LoM.ORDINAL: var mO = data.ordinalStatistics[attributeName]; uniqueVals = mO.uniqueValues; //dict1 = mO.orderedValueIDs; dict2 = mO.orderedIDValues; max = mO.distMax; break; default: // Nothing break; } dim = uniqueVals.Length; this.absMapValues = new int[dim]; this.barHeights = new float[dim]; switch (lom) { case LoM.NOMINAL: InitNominal(data, attributeName); break; case LoM.ORDINAL: InitOrdinal(data, attributeName); break; default: break; } ChangeColoringScheme(ETVColorSchemes.SplitHSV); }
public AttributeStats(LoM type, string name) { this.type = type; this.name = name; }
/// <summary> /// Parses the given files contents and puts them into an instance of DataSet /// </summary> /// <param name="csvFile">file to parse</param> /// <returns>DataSet filled with the files contents</returns> private DataSet ImportDataSet(TextAsset csvFile) { // Initialize Sets var nominalAttributes = new Dictionary <string, string[]>(); var ordinalAtributes = new Dictionary <string, int[]>(); var intervalAttributes = new Dictionary <string, int[]>(); var ratioAttributes = new Dictionary <string, float[]>(); var attributeLoMs = new Dictionary <string, LoM>(); var intervalTranslators = new Dictionary <string, string>(); // Initialize Grid to store values var grid = CSVReader.SplitCsvGrid(csvFile.text); var attributes = new string[grid.Length]; var loms = new LoM[grid.Length]; LoM type; // For every column / variable in grid for (int variable = 0; variable < grid.Length; variable++) { // Extract variable name from first row var currentVariableName = grid[variable][0]; attributes[variable] = currentVariableName; // Extract Level of Measurement from second row var lom = grid[variable][1]; // Detect level of measurement switch (lom) { case "ordinal": type = LoM.ORDINAL; break; case "interval": type = LoM.INTERVAL; break; case "ratio": type = LoM.RATIO; break; default: type = LoM.NOMINAL; break; } // If interval, get translator name if (lom.Split("+"[0]).Length > 1) { string[] intv = lom.Split("+"[0]); intervalTranslators.Add(currentVariableName, intv[1]); type = LoM.INTERVAL; } loms[variable] = type; attributeLoMs.Add(currentVariableName, type); switch (type) { case LoM.ORDINAL: int parseResultI = 0; int[] newDataSetInt = new int[grid[variable].Length - 2]; ordinalAtributes.Add(currentVariableName, newDataSetInt); // For every row in this column for (int i = 2; i < grid[variable].Length; i++) { if (int.TryParse(grid[variable][i], out parseResultI)) { newDataSetInt[i - 2] = parseResultI; } else { newDataSetInt[i - 2] = int.MinValue; } } break; case LoM.INTERVAL: int parseResultI2 = 0; int[] newDataSetInt2 = new int[grid[variable].Length - 2]; intervalAttributes.Add(currentVariableName, newDataSetInt2); // For every row in this column for (int i = 2; i < grid[variable].Length; i++) { if (int.TryParse(grid[variable][i], out parseResultI2)) { newDataSetInt2[i - 2] = parseResultI2; } else { newDataSetInt2[i - 2] = int.MinValue; } } break; case LoM.RATIO: float parseResultF = 0; float[] newDataSetFloat = new float[grid[variable].Length - 2]; ratioAttributes.Add(currentVariableName, newDataSetFloat); // For every row in this column for (int i = 2; i < grid[variable].Length; i++) { if (float.TryParse(grid[variable][i], NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out parseResultF)) { newDataSetFloat[i - 2] = parseResultF; } else { newDataSetFloat[i - 2] = float.NaN; } } break; default: string[] newDataSetString = new string[grid[variable].Length - 2]; nominalAttributes.Add(currentVariableName, newDataSetString); for (int i = 2; i < grid[variable].Length; i++) { string value = grid[variable][i]; newDataSetString[i - 2] = (value == null || value.Length == 0) ? "missingValue" : value; } break; } } return(AssembleDataSet( attributes, nominalAttributes, ordinalAtributes, intervalAttributes, ratioAttributes, ParseDictionaries(), intervalTranslators)); }
private GameObject Create1DIconAndInsert(string name, LoM lom) { return(CreateIconAndInsertInCollection(new string[] { name }, new LoM[] { lom })); }
/// <summary> /// Instantiates an attribute of the given data type. /// </summary> /// <param name="name">Name of the attribute</param> /// <param name="value">Value of the attribute</param> /// <param name="lom">Level of Measurement</param> public Attribute(string name, T value, LoM lom) { this.value = value; this.name = name; this.lom = lom; }
// ........................................................................ Initializers public override void Init( DataSet data, string attributeNameX, string attributeNameY, float lengthA = 1f, float lengthB = 1f, bool isMetaVis = false) { base.Init(data, isMetaVis); this.attributeNameA = attributeNameX; this.attributeNameB = attributeNameY; this.attributeIDA = data.IDOf(attributeNameX); this.attributeIDB = data.IDOf(attributeNameY); this.lomA = data.TypeOf(attributeNameX); this.lomB = data.TypeOf(attributeNameY); this.max = 0; this.lengthA = lengthA; this.lengthB = lengthB; dictA = new Dictionary <string, int>(); dictB = new Dictionary <string, int>(); switch (lomA) { case LoM.NOMINAL: var mN = data.nominalStatistics[attributeNameX]; uniqueValsA = mN.uniqueValues; //distributionA = mN.GetDistributionValues(); dictA = mN.valueIDs; break; case LoM.ORDINAL: var mO = data.ordinalStatistics[attributeNameX]; uniqueValsA = mO.uniqueValues; //distributionA = mO.GetDistributionValues(); dictA = mO.orderedIDValues; break; default: throw new Exception("Illegal LoM"); } switch (lomB) { case LoM.NOMINAL: var mN = data.nominalStatistics[attributeNameY]; uniqueValsB = mN.uniqueValues; //distributionB = mN.GetDistributionValues(); //dictB1 = mN.idValues; //dictB2 = mN.valueIDs; break; case LoM.ORDINAL: var mO = data.ordinalStatistics[attributeNameY]; uniqueValsB = mO.uniqueValues; //distributionB = mO.GetDistributionValues(); //dictB1 = mO.orderedValueIDs; //dictB2 = mO.orderedIDValues; break; default: throw new Exception("Illegal LoM"); } dimA = uniqueValsA.Length; dimB = uniqueValsB.Length; this.absMapValues = new int[dimA, dimB]; this.barHeights = new float[dimA, dimB]; // For every possible value of attribute 1 for (int vID1 = 0; vID1 < dimA; vID1++) { string v1 = uniqueValsA[vID1]; // For every possible value of attribute 2 for (int vID2 = 0; vID2 < dimB; vID2++) { string v2 = uniqueValsB[vID2]; // Count how many object match both values int count; if (lomA == LoM.NOMINAL && lomB == LoM.NOMINAL) { count = AttributeProcessor.Nominal.CountObjectsMatchingTwoCattegories( data.infoObjects, attributeIDA, attributeIDB, v1, v2); } else if (lomA == LoM.ORDINAL && lomB == LoM.ORDINAL) { count = AttributeProcessor.Ordinal.CountObjectsMatchingTwoCattegories( data.infoObjects, attributeIDA, attributeIDB, dictA[v1], dictB[v2]); } else if (lomA == LoM.NOMINAL && lomB == LoM.ORDINAL) { count = AttributeProcessor.Categorial.CountObjectsMatchingTwoCategoriesNomOrd( data.infoObjects, attributeNameX, attributeNameY, v1, dictB[v2]); } else if (lomA == LoM.ORDINAL && lomB == LoM.NOMINAL) { count = AttributeProcessor.Categorial.CountObjectsMatchingTwoCategoriesNomOrd( data.infoObjects, attributeNameY, attributeNameX, v2, dictA[v1]); } else { count = 0; } if (count > max) { max = count; } absMapValues[vID1, vID2] = count; } } for (int vID1 = 0; vID1 < dimA; vID1++) { for (int vID2 = 0; vID2 < dimB; vID2++) { barHeights[vID1, vID2] = absMapValues[vID1, vID2] / ((float)max); } } if (max > 0) { SetUpAxes(); DrawGraph(); foreach (var o in data.infoObjects) { bool valAMissing = data.IsValueMissing(o, attributeNameA); bool valBMissing = data.IsValueMissing(o, attributeNameB); if (!(valAMissing || valBMissing)) { Bar3D bar; if (lomA == LoM.NOMINAL && lomB == LoM.NOMINAL) { bar = bars[ dictA[o.NomValueOf(attributeNameA)], dictB[o.NomValueOf(attributeNameB)] ]; } else if (lomA == LoM.ORDINAL && lomB == LoM.ORDINAL) { bar = bars[ o.OrdValueOf(attributeNameA), o.OrdValueOf(attributeNameB) ]; } else if (lomA == LoM.NOMINAL && lomB == LoM.ORDINAL) { bar = bars[ dictA[o.NomValueOf(attributeNameA)], o.OrdValueOf(attributeNameB) ]; } else if (lomA == LoM.ORDINAL && lomB == LoM.NOMINAL) { bar = bars[ o.OrdValueOf(attributeNameA), dictB[o.NomValueOf(attributeNameB)] ]; } else { bar = new Bar3D(); } RememberRelationOf(o, bar); } } } }