Skip to content

Instantly share code, notes, and snippets.

Andy Butland AndyButland

  • Zone
  • Bassano del Grappa, Italy
Block or report user

Report or block AndyButland

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ml.net-8.cs
private static void ReportOnFeatureImportance(MLContext context, ITransformer model, IDataView data)
{
...
var results = featureNames
.Select((t, i) => new FeatureImportance
{
Name = t,
RSquaredMean = Math.Abs(permutationMetrics[i].RSquared.Mean),
CorrelationCoefficient = CalculateSingleFactorCorrelationCoefficient(context, data, t)
})
View ml.net-7.cs
private static void ReportOnFeatureImportance(MLContext context, ITransformer model, IDataView data)
{
// Need to cast from the ITransformer interface to gain access to the LastTransformer property.
var typedModel = (TransformerChain<RegressionPredictionTransformer<FastForestRegressionModelParameters>>)model;
// Calculate metrics.
var permutationMetrics = context.Regression.PermutationFeatureImportance(typedModel.LastTransformer, model.Transform(data), PredictionLabel);
// Combine metrics with feature names and format for display.
var columnsToExclude = new[] { PredictionLabel, "Code", "Name", "IdPreservationColumn" };
View ml.net-6.cs
private static void TestSinglePrediction(MLContext context)
{
// For this test we'll load the model back from disk.
using (var stream = new FileStream(ModelPath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
var loadedModel = context.Model.Load(stream);
var predictionFunction = loadedModel.CreatePredictionEngine<CountryData, CountryHappinessScorePrediction>(context);
// Record of Italy - expected 5.964
View ml.net-5.cs
private static void EvaluateModel(MLContext context, ITransformer model, IDataView data)
{
var predictions = model.Transform(data);
var metrics = context.Regression.Evaluate(predictions, "Label", "Score");
OutputEvaluationResults(metrics);
}
private static void OutputEvaluationResults(RegressionMetrics metrics)
{
View ml.net-4.cs
public static void Main(string[] args)
{
var context = new MLContext();
var data = GetTrainAndTestData(context, InputDataPath);
var model = TrainModel(context, data.TrainSet);
...
}
View ml.net-3.cs
public class CountryData
{
[LoadColumn(0)]
public string Code;
[LoadColumn(1)]
public string Name;
[LoadColumn(3)]
public float HappinessScore;
View ml.net-2.cs
public static void Main(string[] args)
{
var context = new MLContext();
var data = GetTrainAndTestData(context, InputDataPath);
...
}
private static TrainCatalogBase.TrainTestData GetTrainAndTestData(MLContext context, string dataPath)
View ml.net-1.cs
public static void Main(string[] args)
{
var context = new MLContext();
...
}
View bot-framework-v4-14.cs
public abstract class BaseHandleIntentStrategy
{
public abstract string IntentName { get; }
public abstract Task HandleMessage(ITurnContext turnContext, ConversationData conversationData, IDictionary<string, object> entities);
protected static string GetStringEntityValue(IDictionary<string, object> entities, string key)
{
return entities[key] as string;
}
View bot-framework-v4-13.cs
public abstract class BaseHandlePersonIntentStrategy : BaseHandleIntentStrategy
{
protected BaseHandlePersonIntentStrategy(IPersonService personService)
{
PersonService = personService;
}
public IPersonService PersonService { get; }
protected static string GetPersonEntityValue(IDictionary<string, object> entities)
You can’t perform that action at this time.