public void copy(SVC rhs) { _param = rhs._param == null ? null : (SVMParam)rhs._param.Clone(); _crossValidation = rhs._crossValidation; model = rhs.model == null ? null : (SVMModel)rhs.model.Clone(); quiet = rhs.quiet; }
public static void SolveBinaryClassificationProblem() { SVC svc = new SVC(); List <KeyValuePair <double[], bool> > data = new List <KeyValuePair <double[], bool> >(); for (int i = 0; i < 100; ++i) { double[] x = new double[2]; x[0] = i / 50.0; x[1] = (i + 1) / 100.0; bool y = Math.Sin((x[0] + x[1]) * Math.PI) > 0; data.Add(new KeyValuePair <double[], bool>(x, y)); } var tuple = TrainTestSplit(data); var train_data = tuple.Item1; var test_data = tuple.Item2; var metric = svc.Fit(train_data, test_data); Console.WriteLine("Train Acc: {0}, Test Acc: {1}", metric.TrainAccuracy, metric.TestAccuracy); foreach (KeyValuePair <double[], bool> entry in test_data.GetRange(0, 10)) { double[] x = entry.Key; bool y = entry.Value; double output = svc.Predict(x); bool prediction = output > 0; Console.WriteLine("Predicted: {0} Actual: {1}", prediction, y); } }
public Object Clone() { SVC clone = new SVC(); clone.copy(this); return(clone); }