Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Include Fusion tests * Include Deepnet tests
- Loading branch information
Showing
13 changed files
with
394 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Newtonsoft.Json.Linq; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
|
||
namespace BigML | ||
{ | ||
public partial class Fusion | ||
{ | ||
public class Arguments : Arguments<Fusion> | ||
{ | ||
public Arguments() | ||
{ | ||
|
||
} | ||
|
||
/// <summary> | ||
/// A list of model IDs used to create the fusion or a list of | ||
/// objects including model propperties like the weight | ||
/// </summary> | ||
public List<dynamic> Models | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
|
||
public override JObject ToJson() | ||
{ | ||
dynamic json = base.ToJson(); | ||
|
||
if (Models.Count > 0) { | ||
json.models = new JArray(Models.Select(t => (JValue)t)); | ||
} | ||
return json; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Threading.Tasks; | ||
using System.Collections.Generic; | ||
|
||
namespace BigML | ||
{ | ||
public partial class Client | ||
{ | ||
/// <summary> | ||
/// Create a fusion using supplied arguments. | ||
/// </summary> | ||
public Task<Fusion> CreateFusion(Fusion.Arguments arguments) | ||
{ | ||
return Create<Fusion>(arguments); | ||
} | ||
|
||
/// <summary> | ||
/// Create a Fusion. | ||
/// </summary> | ||
/// <param name="models">A list of Models</param> | ||
/// <param name="name">The name you want to give to the new fusion.</param> | ||
/// <param name="arguments">Other extra parameters.</param> | ||
public Task<Fusion> CreateFusion(List<dynamic> models, string name = null, | ||
Fusion.Arguments arguments = null) | ||
{ | ||
arguments = arguments ?? new Fusion.Arguments(); | ||
if (!string.IsNullOrWhiteSpace(name)) | ||
arguments.Name = name; | ||
arguments.Models = models; | ||
return Create<Fusion>(arguments); | ||
} | ||
|
||
/// <summary> | ||
/// List all the Fusion | ||
/// </summary> | ||
public Query<Fusion.Filterable, Fusion.Orderable, Fusion> ListFusion() | ||
{ | ||
return new FusionListing(List<Fusion>); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using BigML.Meta; | ||
|
||
namespace BigML | ||
{ | ||
public partial class Fusion | ||
{ | ||
/// <summary> | ||
/// Filterable properties for fusions | ||
/// </summary> | ||
public class Filterable : Filterable<Fusion> | ||
{ | ||
/// <summary> | ||
/// The current number of batch predictions that use this fusion | ||
/// </summary> | ||
public Int NumberOfBatchpredictions | ||
{ | ||
get { return Object.number_of_batchpredictions; } | ||
} | ||
|
||
/// <summary> | ||
/// The current number of evaluations that use this fusion | ||
/// </summary> | ||
public Int NumberOfEvaluations | ||
{ | ||
get { return Object.number_of_evaluations; } | ||
} | ||
|
||
/// <summary> | ||
/// The current number of predictions that use this fusion | ||
/// </summary> | ||
public Int NumberOfPredictions | ||
{ | ||
get { return Object.number_of_predictions; } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace BigML | ||
{ | ||
/// <summary> | ||
/// Fusions are a special type of composite for which all submodels satisfy | ||
/// the following constraints: they're all either classifications or | ||
/// regressions over the same kind of data or compatible fields, with the | ||
/// same objective field. | ||
/// The complete and updated reference with all available parameters is in | ||
/// our <a href="https://bigml.com/api/fusions"> documentation</a> website. | ||
/// </summary> | ||
public partial class Fusion : Response | ||
{ | ||
|
||
/// <summary> | ||
/// The name of the Fusion as your provided or based on the name | ||
/// of the dataset by default. | ||
/// </summary> | ||
public string Name | ||
{ | ||
get { return Object.name; } | ||
} | ||
|
||
|
||
/// <summary> | ||
/// The models that was used to build the fusion. | ||
/// </summary> | ||
public List<dynamic> Models | ||
{ | ||
get { return Object.models; } | ||
} | ||
|
||
|
||
/// <summary> | ||
/// A description of the status of the fusion. | ||
/// It includes a code, a message, and some extra information. | ||
/// </summary> | ||
public Status StatusMessage | ||
{ | ||
get { return new Status(Object.status); } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
|
||
namespace BigML | ||
{ | ||
public class FusionListing : Query<Fusion.Filterable, Fusion.Orderable, Fusion> | ||
{ | ||
public FusionListing(Func<string, Task<Listing<Fusion>>> client) | ||
: base(client) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using BigML.Meta; | ||
|
||
namespace BigML | ||
{ | ||
using Meta.Key; | ||
|
||
public partial class Fusion | ||
{ | ||
/// <summary> | ||
/// Orderable properties for fusions | ||
/// </summary> | ||
public class Orderable : Orderable<Fusion> | ||
{ | ||
/// <summary> | ||
/// The current number of batch predictions that use this fusion | ||
/// </summary> | ||
public Int NumberOfBatchpredictions | ||
{ | ||
get { return Object.number_of_batchpredictions; } | ||
} | ||
|
||
/// <summary> | ||
/// The current number of evaluations that use this fusion | ||
/// </summary> | ||
public Int NumberOfEvaluations | ||
{ | ||
get { return Object.number_of_evaluations; } | ||
} | ||
|
||
/// <summary> | ||
/// The current number of predictions that use this fusion | ||
/// </summary> | ||
public Int NumberOfPredictions | ||
{ | ||
get { return Object.number_of_predictions; } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using Newtonsoft.Json.Linq; | ||
|
||
namespace BigML | ||
{ | ||
public partial class Fusion | ||
{ | ||
/// <summary> | ||
/// Creating a Fusion is a process that can take just a few | ||
/// seconds. This time depends on the quantity of models used | ||
/// and on the work load of BigML's systems. | ||
/// The Fusion goes through a number of states until its fully | ||
/// completed. | ||
/// Through the status field in the Fusion you can determine | ||
/// when the Fusion has been fully completed. | ||
/// </summary> | ||
public class Status : Status<Fusion> | ||
{ | ||
internal Status(JObject status): base(status) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// How far BigML.io has progressed processing the fusion. | ||
/// </summary> | ||
public double Progress | ||
{ | ||
get { return _status.progress; } | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Threading.Tasks; | ||
using BigML; | ||
|
||
namespace BigMLTest | ||
{ | ||
/// <summary> | ||
/// Test resources related with Deepnets | ||
/// </summary> | ||
[TestClass] | ||
public class TestDeepnets | ||
{ | ||
string userName = "myUser"; | ||
string apiKey = "8169dabca34b6ae5612a47b63dd97bead3bfeXXX"; | ||
|
||
[TestMethod] | ||
public async Task CreateDeepnetFromRemoteSource() | ||
{ | ||
// Prepare connection | ||
Client c = new Client(userName, apiKey); | ||
|
||
// Create source | ||
Source.Arguments args = new Source.Arguments(); | ||
args.Add("remote", "http://static.bigml.com/csv/iris.csv"); | ||
Source s = await c.CreateSource(args); | ||
s = await c.Wait<Source>(s.Resource); | ||
|
||
Assert.AreEqual(s.StatusMessage.StatusCode, Code.Finished); | ||
|
||
// Create dataset | ||
DataSet.Arguments argsDS = new DataSet.Arguments(); | ||
argsDS.Add("source", s.Resource); | ||
DataSet ds = await c.CreateDataset(argsDS); | ||
ds = await c.Wait<DataSet>(ds.Resource); | ||
|
||
Assert.AreEqual(ds.StatusMessage.StatusCode, Code.Finished); | ||
|
||
// Create deepnet | ||
Deepnet.Arguments argsDn = new Deepnet.Arguments(); | ||
argsDn.Add("dataset", ds.Resource); | ||
Deepnet dn = await c.CreateDeepnet(argsDn); | ||
dn = await c.Wait<Deepnet>(dn.Resource); | ||
|
||
Assert.AreEqual(dn.StatusMessage.StatusCode, Code.Finished); | ||
|
||
// test UPDATE method | ||
Newtonsoft.Json.Linq.JObject changes = new Newtonsoft.Json.Linq.JObject(); | ||
Newtonsoft.Json.Linq.JArray tags = new Newtonsoft.Json.Linq.JArray(); | ||
tags.Add("Bindings C# test"); | ||
changes.Add("tags", tags); | ||
dn = await c.Update<Deepnet>(dn.Resource, changes); | ||
Assert.AreEqual(dn.Code, System.Net.HttpStatusCode.Accepted); | ||
|
||
// test DELETE method | ||
await c.Delete(s); | ||
await c.Delete(ds); | ||
await c.Delete(dn); | ||
} | ||
} | ||
} |
Oops, something went wrong.