public string writeModel(string outModelPath) { outPath = outModelPath; using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outPath)) { sw.WriteLine(modelTypes.LinearRegression.ToString()); sw.WriteLine(InTablePath); sw.WriteLine(String.Join(",", IndependentFieldNames)); sw.WriteLine(String.Join(",", DependentFieldNames)); sw.WriteLine(String.Join(",", ClassFieldNames)); sw.WriteLine(SampleSize.ToString()); sw.WriteLine(NumberOfVariables.ToString()); sw.WriteLine(InterceptThroughOrigin.ToString()); sw.WriteLine(RMSE); sw.WriteLine(FValue.ToString()); sw.WriteLine(PValue.ToString()); sw.WriteLine(Rsquared.ToString()); sw.WriteLine(AdjustedRsquared.ToString()); sw.WriteLine(String.Join(" ", (from double d in Coefficients select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in StandardErrors select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in minValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in maxValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in sumValues select d.ToString()).ToArray())); sw.Close(); } return(outPath); }
// Full constructor takes Capture instance and specific values for // channels, bits, and samples. internal SoundFormat(Capture captureDevice, SampleRate rate, SampleSize size, short channels) { if (captureDevice == null) { throw new ArgumentNullException("captureDevice"); } this._captureDevice = captureDevice; try { // Test the supplied format characteristics. this._currentFormat = ConstructFormat((int)rate, (short)size, (short)channels); } catch (Exception ex) { string errMsg = string.Format("Sound format not supported: {0} samples/sec, {1} bits/sample, {2} channels.", (int)rate, (short)size, (short)channels); throw new Exception(errMsg, ex); } this._channels = channels; this._bitsPerSample = (short)size; this._samplesPerSecond = (int)rate; }
public void getReport(double alpha) { Forms.RunningProcess.frmRunningProcessDialog rd = new Forms.RunningProcess.frmRunningProcessDialog(false); rd.Text = "GLM Results"; rd.TopLevel = true; rd.pgbProcess.Visible = false; rd.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; rd.addMessage("Dependent field = " + DependentFieldNames[0]); rd.addMessage("Independent fields = " + String.Join(", ", IndependentFieldNames)); rd.addMessage("Sample size = " + SampleSize.ToString()); rd.addMessage("Iteration = " + Iterations.ToString()); rd.addMessage("Delta Convergence " + DeltaC.ToString()); rd.addMessage("Chi-Sqr = " + ChiSquare.ToString() + " p-value = " + PValue.ToString()); rd.addMessage("Deviance = " + Deviance.ToString()); rd.addMessage("Log Likelihood = " + LogLikelihood.ToString()); rd.addMessage("Log Likelihood Ratio = " + LogLikelihoodratio.ToString() + "\n\nCoefficents and standard errors:\n"); rd.addMessage("Param: Intercept, " + String.Join(", ", IndependentFieldNames)); rd.addMessage("Coef: " + string.Join(", ", (from double d in Coefficients select d.ToString()).ToArray())); rd.addMessage("STE: " + string.Join(", ", (from double d in StdError select d.ToString()).ToArray()) + "\n"); try { if (ModelHelper.chartingAvailable() && System.Windows.Forms.MessageBox.Show("Do you want to build distribution graphs?", "Graphs", System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { createRegChart(); } } catch { System.Windows.Forms.MessageBox.Show("Cannot create charts."); } rd.Show(); rd.enableClose(); }
public IEnumerable <INode> ReadNodeCollectionFile(SampleSize sampleSize) { string fileName = string.Empty; switch (sampleSize) { case SampleSize.Small: { fileName = "SmallSample"; break; } case SampleSize.Medium: { fileName = "MediumSample"; break; } case SampleSize.Large: { fileName = "LargeSample"; break; } case SampleSize.CrazyBalls: { fileName = "CrazyBallsSample"; break; } } JsonParser jsonParser = new JsonParser(); return(jsonParser.ReadJson <IEnumerable <INode> >(_fileReader.ReadSample(fileName))); }
public string writeModel(string outModelPath) { outPath = outModelPath; using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outPath)) { sw.WriteLine(modelTypes.GLM.ToString()); sw.WriteLine(InTablePath); sw.WriteLine(String.Join(",", IndependentFieldNames)); sw.WriteLine(String.Join(",", DependentFieldNames)); sw.WriteLine(String.Join(",", ClassFieldNames)); sw.WriteLine(SampleSize.ToString()); sw.WriteLine(NumberOfVariables.ToString()); sw.WriteLine(Iterations.ToString()); sw.WriteLine(DeltaC.ToString()); sw.WriteLine(LogLikelihood); sw.WriteLine(LogLikelihoodratio); sw.WriteLine(PValue.ToString()); sw.WriteLine(Deviance.ToString()); sw.WriteLine(ChiSquare.ToString()); sw.WriteLine(linkfunction.ToString()); sw.WriteLine(String.Join(" ", (from double d in Coefficients select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in StdError select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in waldTestValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in waldTestPValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in minValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in maxValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in sumValues select d.ToString()).ToArray())); sw.Close(); } return(outPath); }
public static int GetSampleResolution(SampleSize size) { switch (size) { case SampleSize._32: return(32); case SampleSize._64: return(64); case SampleSize._128: return(128); case SampleSize._256: return(256); case SampleSize._512: return(512); case SampleSize._1024: return(1024); case SampleSize._2048: return(2048); default: return(256); } }
public string writeModel(string outModelPath) { outPath = outModelPath; string outPathSvm = outModelPath.Replace(".mdl", ".svm"); svmMachine.Save(outPathSvm); using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outPath)) { sw.WriteLine(modelTypes.SVM.ToString()); sw.WriteLine(InTablePath); sw.WriteLine(String.Join(",", IndependentFieldNames)); sw.WriteLine(String.Join(",", DependentFieldNames)); if (ClassFieldNames != null) { sw.WriteLine(String.Join(",", ClassFieldNames)); } else { sw.WriteLine(); } sw.WriteLine(SampleSize.ToString()); sw.WriteLine(NumberOfVariables.ToString()); sw.WriteLine(sserror.ToString()); sw.WriteLine(kTyp.ToString()); sw.WriteLine(String.Join(" ", (from double d in minValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in maxValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in sumValues select d.ToString()).ToArray())); sw.Close(); } return(outPath); }
public void getReport(double alpha) { Forms.RunningProcess.frmRunningProcessDialog rd = new Forms.RunningProcess.frmRunningProcessDialog(false); rd.Text = "Regression Results"; rd.TopLevel = true; rd.pgbProcess.Visible = false; rd.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; rd.addMessage("Dependent field = " + DependentFieldNames[0]); rd.addMessage("Independent fields = " + String.Join(", ", IndependentFieldNames)); rd.addMessage("Sample size = " + SampleSize.ToString()); rd.addMessage("Intercept Through Origin = " + InterceptThroughOrigin.ToString()); rd.addMessage("F-statistic = " + FValue.ToString() + " p-value = " + PValue.ToString()); rd.addMessage("RMSE = " + RMSE.ToString()); rd.addMessage("R2 = " + Rsquared.ToString()); rd.addMessage("Adj-R2 = " + AdjustedRsquared.ToString() + "\n\nCoefficents and standard errors:\n"); rd.addMessage("Param: Intercept, " + String.Join(", ", IndependentFieldNames)); rd.addMessage("Coef: " + string.Join(", ", (from double d in Coefficients select d.ToString()).ToArray())); rd.addMessage("STE: " + string.Join(", ", (from double d in StandardErrors select d.ToString()).ToArray()) + "\n"); try { if (ModelHelper.chartingAvailable()) { regChart(); } } catch { System.Windows.Forms.MessageBox.Show("Cannot create charts"); } rd.Show(); rd.enableClose(); }
public void getReport() { Forms.RunningProcess.frmRunningProcessDialog rd = new Forms.RunningProcess.frmRunningProcessDialog(false); rd.Text = "SVM Results"; rd.TopLevel = true; rd.pgbProcess.Visible = false; rd.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; rd.addMessage("Dependent field = " + DependentFieldNames[0]); rd.addMessage("Independent fields = " + String.Join(", ", IndependentFieldNames)); rd.addMessage("Sample size = " + SampleSize.ToString()); rd.addMessage("Sum of Squared Error: " + sserror.ToString()); rd.Show(); rd.enableClose(); }
/// <summary> /// Converts sample size format to specified sample size, if /// sample size is not supported will throw a FormatException. /// Good idea to surround with a try catch block if you don't /// know the specified sample size /// </summary> /// <param name="sampleSize">Size of sample in bytes</param> public void ConvertTo(SampleSize sampleSize) { if (this.Data.Length == (int)sampleSize) { return; } else { decimal value = this.GetValue(); this.Data = new byte[(int)sampleSize]; this.SetValue(value); } throw new FormatException(); }
public void getReport() { Forms.RunningProcess.frmRunningProcessDialog rd = new Forms.RunningProcess.frmRunningProcessDialog(false); rd.Text = "LDA Results"; rd.TopLevel = true; rd.pgbProcess.Visible = false; rd.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; rd.addMessage("Dependent field = " + DependentFieldNames[0]); rd.addMessage("Independent fields = " + String.Join(", ", IndependentFieldNames)); rd.addMessage("Sample size = " + SampleSize.ToString()); rd.addMessage("Means: " + string.Join(", ", (from double d in meanValues select d.ToString()).ToArray())); rd.addMessage("Standard Dev: " + string.Join(", ", (from double d in stdValues select d.ToString()).ToArray()) + "\n"); rd.Show(); rd.enableClose(); }
/// <summary> /// Create a new sound recorder. /// </summary> /// <param name="type">Sound capture device.</param> /// <param name="rate">Desired sample rate.</param> /// <param name="size">Desired sample size.</param> /// <param name="channels">Desired channels to use.</param> public SoundRecorder(SoundDeviceType type, SampleRate rate, SampleSize size, short channels) { this._desiredDeviceType = type; this._devices = new CaptureDevicesCollection(); if (this._devices == null || this._devices.Count < 1) { throw new InvalidOperationException("No sound capture devices detected."); } this.Find(type); InitDirectSound(); this._recorderFormat = new SoundFormat(this._applicationDevice, rate, size, channels); }
public override int GetHashCode() { unchecked { var hashCode = Id?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ (Chromosome?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ Start.GetHashCode(); hashCode = (hashCode * 397) ^ End.GetHashCode(); hashCode = (hashCode * 397) ^ VariantType.GetHashCode(); hashCode = (hashCode * 397) ^ SampleSize.GetHashCode(); hashCode = (hashCode * 397) ^ ObservedGains.GetHashCode(); hashCode = (hashCode * 397) ^ ObservedLosses.GetHashCode(); hashCode = (hashCode * 397) ^ (VariantFreqAll?.GetHashCode() ?? 0); return(hashCode); } }
public override int GetHashCode() { int hash = 1; if (Id.Length != 0) { hash ^= Id.GetHashCode(); } if (Algorithm != 0) { hash ^= Algorithm.GetHashCode(); } if (ErrorTolerance != 0D) { hash ^= ErrorTolerance.GetHashCode(); } if (File.Length != 0) { hash ^= File.GetHashCode(); } if (Support != 0D) { hash ^= Support.GetHashCode(); } if (SampleSize != 0) { hash ^= SampleSize.GetHashCode(); } if (K != 0) { hash ^= K.GetHashCode(); } if (UseTopK != false) { hash ^= UseTopK.GetHashCode(); } if (DBSize != 0) { hash ^= DBSize.GetHashCode(); } if (ShutdownServer != false) { hash ^= ShutdownServer.GetHashCode(); } return(hash); }
public string writeModel(string outModelPath) { if (lm == null) { getMnlModel(); } outPath = outModelPath; double[,] coef = null; alglib.mnlunpack(lm, out coef, out nvars, out nclasses); using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outPath)) { sw.WriteLine(modelTypes.SoftMax.ToString()); sw.WriteLine(InTablePath); sw.WriteLine(SampleSize.ToString()); sw.WriteLine(String.Join(",", IndependentFieldNames)); sw.WriteLine(String.Join(",", DependentFieldNames)); sw.WriteLine(String.Join(",", ClassFieldNames)); sw.WriteLine(string.Join(",", Categories)); sw.WriteLine(NumberOfVariables.ToString()); sw.WriteLine(NumberOfClasses.ToString()); sw.WriteLine(RMSE.ToString()); sw.WriteLine(AverageCrossEntropyError.ToString()); sw.WriteLine(AverageError.ToString()); sw.WriteLine(AverageRelativeError.ToString()); sw.WriteLine(ClassificationError.ToString()); sw.WriteLine(RelativeClassificationError.ToString()); sw.WriteLine(String.Join(",", (from double d in minValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(",", (from double d in maxValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(",", (from double d in sumValues select d.ToString()).ToArray())); int rws = coef.GetUpperBound(1); int clms = coef.GetUpperBound(0); for (int r = 0; r <= rws; r++) { string[] ln = new string[clms + 1]; for (int c = 0; c <= clms; c++) { ln[c] = coef[c, r].ToString(); } sw.WriteLine(String.Join(" ", ln)); } sw.Close(); } return(outPath); }
protected override void afterPopulateProps() { RetestSampleRegime.SetOnBeforeRender(delegate(CswNbtNodeProp Prop) { CswNbtObjClassLevel LevelNode = _CswNbtResources.Nodes.GetNode(Level.RelatedNodeId); if (null != LevelNode && LevelNode.LabUseOnly.Checked == CswEnumTristate.True) //On Add, LevelNode will be null { Prop.setHidden(true, false); } }); SampleSize.SetOnBeforeRender(delegate(CswNbtNodeProp Prop) { if (false == IsTemp) { SampleSize.View = _getSampleSizeUnitsView(); } }); }
public string writeModel(string outModelPath) { outPath = outModelPath; using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outPath)) { sw.WriteLine(modelTypes.LDA.ToString()); sw.WriteLine(InTablePath); sw.WriteLine(String.Join(",", IndependentFieldNames)); sw.WriteLine(String.Join(",", DependentFieldNames)); sw.WriteLine(String.Join(",", ClassFieldNames)); sw.WriteLine(SampleSize.ToString()); sw.WriteLine(NumberOfVariables.ToString()); sw.WriteLine(String.Join(" ", (from double d in minValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in maxValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in sumValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in meanValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in stdValues select d.ToString()).ToArray())); sw.Close(); } return(outPath); }
public void WriteXml(XmlWriter writer) { writer.WriteAttributeString("nominal", Nominal.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("mean", Mean.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("standardDeviation", StandardDeviation.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("lowerSpecLimit", LowerSpecLimit.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("upperSpecLimit", UpperSpecLimit.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("cp", Cp.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("cpk", Cpk.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("distribution", Distribution); writer.WriteAttributeString("skewness", Skewness.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("kurtosis", Kurtosis.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("sampleSize", SampleSize.ToString(CultureInfo.InvariantCulture)); writer.WriteStartElement("Sample"); Sample.WriteXml(writer); writer.WriteEndElement(); writer.WriteStartElement("Estimate"); Estimate.WriteXml(writer); writer.WriteEndElement(); }
public IEnumerable <INode> GetNodes(SampleSize sampleSize) { return(_dataInterfaceProvider.ReadNodeCollectionFile(sampleSize)); }
/// <summary> /// Sample constructor /// </summary> /// <param name="sampleSize">Sample size in bytes</param> public Sample(SampleSize sampleSize) : this((int)sampleSize) { // Skip }
static void Main(string[] args) { bool showUsage = true; if (args.Length >= 1) // requires port at least { try { // todo: validate with a regex (ip or name) int port = int.Parse(args[0]); if (port > 0 && port < 65536) { showUsage = false; String adrs = "127.0.0.1"; if (args.Length >= 2) { adrs = args[1]; } // todo: retreive list of devices and select from/display it in Show Usage // todo: parse and set these parameters SampleRate rate = SampleRate.Rate11KHz; SampleSize size = SampleSize.Bits8; short channels = 1; SoundRecorder recorder = new SoundRecorder(SoundDeviceType.Default, rate, size, channels); UdpClient udpClient = new UdpClient(adrs, port); Console.WriteLine("Sending sound packets on UDP port " + port); try { recorder.Start(""); while (recorder.Capturing()) { //Sit here and wait for a message to arrive recorder.NotificationEvent.WaitOne(System.Threading.Timeout.Infinite, true); recorder.SendCapturedData(udpClient); } } catch (Exception e) { Console.WriteLine(e.ToString()); Console.WriteLine("Hit any key to continue"); Console.ReadKey(); } finally { recorder.Stop(); udpClient.Close(); } } } catch (Exception e) { Console.WriteLine(e); } } if (showUsage) { Console.WriteLine("Send direct sound data as UDP packets."); Console.WriteLine("USAGE: UDPSoundSender targetIP port [8000 8 1]"); Console.WriteLine("where:"); Console.WriteLine(" targetIP is address where to send the packets (yes, multicast addresses should works!)"); Console.WriteLine(" port is the one of the target ip listening"); Console.WriteLine(" [optional parameters]"); Console.WriteLine(" 8000 is the default sample rate (choose 8000, 11025, 22050, 44100 or 48000 sample/sec)"); Console.WriteLine(" 8 is the default bit depth (choose 8 or 16 bits)"); Console.WriteLine(" 1 is the channels selected (choose 1 or 2 channels)"); Console.WriteLine("Hit any key to exit"); Console.Read(); } }
/** * Load and parse data from dat_mes.csv */ internal static void LoadData(StudyData studyData) { if (IsDataLoaded) { return; } List <string[]> rows = new List <string[]>(); using (StreamReader reader = File.OpenText("Data/dat_mes.csv")) { while (reader.Peek() >= 0) { string line = reader.ReadLine(); string[] rowArray = CSVRowToStringArray(line); if (rowArray.Length > 0) { rows.Add(rowArray); } } } string[] headers = rows[0]; rows.Remove(headers); /** * Parse each row array into a Study object. * Assumes CSV column ordering: * id,PublicationYear,n,r,VariablesControlled,StudyDesign, * AdherenceMeasure,ConscientiousnessMeasure ,MeanAge,MethodologicalQuality */ foreach (string[] row in rows) { PublicationYear publicationYear = studyData.PublicationYears.AddUnique(row[1]); CorrelationCoefficient correlationCoefficient = studyData.CorrelationCoefficients.AddUnique(row[2]); SampleSize sampleSize = studyData.SampleSizes.AddUnique(row[3]); VariablesControlled variablesControlled = studyData.VariablesControlled.AddUnique(row[4]); StudyDesign studyDesign = studyData.StudyDesigns.AddUnique(row[5]); AdherenceMeasure adherenceMeasure = studyData.AdherenceMeasures.AddUnique(row[6]); ConscientiousnessMeasure conscientiousnessMeasure = studyData.ConscientiousnessMeasures.AddUnique(row[7]); MeanAge meanAge = studyData.MeanAges.AddUnique(row[8]); MethodologicalQuality methodologicalQuality = studyData.MethodologicalQualities.AddUnique(row[9]); Study newStudy = new Study { Id = row[0], PublicationYear = publicationYear, CorrelationCoefficient = correlationCoefficient, SampleSize = sampleSize, VariablesControlled = variablesControlled, StudyDesign = studyDesign, AdherenceMeasure = adherenceMeasure, ConscientiousnessMeasure = conscientiousnessMeasure, MeanAge = meanAge, MethodologicalQuality = methodologicalQuality }; studyData.Studies.Add(newStudy); } IsDataLoaded = true; }