Skip to content

More pigstensions #1084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 28, 2018
Merged

More pigstensions #1084

merged 11 commits into from
Sep 28, 2018

Conversation

sfilipi
Copy link
Member

@sfilipi sfilipi commented Sep 27, 2018

ongoing work to address #754.
This PR adds the xtensions for AP, OGD, LR, Multi-LR, and Poisson Regression.

adding pigstensions for lr, multilr, possion
Removing the AP xtension that produces the probability column.
/// the linear model that was trained. Note that this action cannot change the result in any way; it is only a way for the caller to
/// be informed about what was learnt.</param>
/// <returns>The predicted output.</returns>
public static (Scalar<float> score, Scalar<float> probability, Scalar<bool> predictedLabel) LogisticRegression(this BinaryClassificationContext.BinaryClassificationTrainers ctx,
Copy link
Member Author

@sfilipi sfilipi Sep 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LogisticRegression [](start = 100, length = 18)

rename to LogisticRegressionBinaryClassifier #Resolved

}
return trainer;
*/

Copy link
Member Author

@sfilipi sfilipi Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove #Resolved

/// <summary>
/// Predict a target using a linear binary classification model trained with the SDCA trainer, and a custom loss.
/// Note that because we cannot be sure that all loss functions will produce naturally calibrated outputs, setting
/// a custom loss function will not produce a calibrated probability column.
Copy link
Member Author

@sfilipi sfilipi Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove #Resolved

.Append(r => (r.label, preds: ctx.Trainers.Sdca(r.label, r.features,
maxIterations: 2,
loss: loss, onFit: p => pred = p)));
.Append(r => (r.label, preds: ctx.Trainers.AveragedPerceptron(loss, r.label, r.features,
Copy link
Member Author

@sfilipi sfilipi Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AveragedPerceptron [](start = 59, length = 18)

revert #Resolved

using Microsoft.ML.StaticPipe;
using Microsoft.ML.StaticPipe.Runtime;

namespace Microsoft.ML.Trainers
Copy link
Member Author

@sfilipi sfilipi Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Microsoft.ML.Trainers [](start = 10, length = 21)

change namespace #Closed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussion on the other comment.


In reply to: 221111414 [](ancestors = 221111414)

using Microsoft.ML.StaticPipe.Runtime;
using System;

namespace Microsoft.ML.Trainers
Copy link
Member Author

@sfilipi sfilipi Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Microsoft.ML.Trainers [](start = 10, length = 21)

change namespace #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually moving to ML.StaticPipe namespace won't fix it by itself. All the contexts are in Microsoft.ML.

@TomFinley move the contexts in StaticPipe as well?


In reply to: 221111449 [](ancestors = 221111449)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. If the user opts into the static pipe, they will see the trainers. It's good enough for me


In reply to: 221299214 [](ancestors = 221299214,221111449)

Copy link
Member Author

@sfilipi sfilipi Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The context is in Microsoft.ML, i don't see anything import staticPipe.


In reply to: 221307154 [](ancestors = 221307154,221299214,221111449)

@sfilipi sfilipi self-assigned this Sep 28, 2018
@sfilipi sfilipi added the API Issues pertaining the friendly API label Sep 28, 2018
@@ -25,7 +25,7 @@ public void OnlineLinearWorkout()

var trainData = pipe.Fit(data).Transform(data).AsDynamic;

IEstimator<ITransformer> est = new OnlineGradientDescentTrainer(Env, new OnlineGradientDescentTrainer.Arguments());
IEstimator<ITransformer> est = new OnlineGradientDescentTrainer(Env, "Label", "Features");
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Label" [](start = 81, length = 7)

Any chance I can convince you to use DefaultColumnNames.Label? #Pending

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can change, it; it won't be any better than it is.
This is "Label", because in like 20 we defined r.Label.

There is no way to type the the member name to be the same as a particular string.
(might be the only thing i miss from javascript :P)


In reply to: 221112970 [](ancestors = 221112970)

/// <param name="weightsColumn">The name of the weights column.</param>
/// <param name="lossFunction">The custom loss functions. Defaults to <see cref="SquaredLoss"/> if not provided.</param>
public OnlineGradientDescentTrainer(IHostEnvironment env,
string labelColumn,
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

labelColumn [](start = 19, length = 11)

any reason not to use default values here? #Pending

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we have marked the label and feature columns as required everywhere.


In reply to: 221113276 [](ancestors = 221113276)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we were not consistent.


In reply to: 221298419 [](ancestors = 221298419,221113276)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Zruty0 which one are you referring too? Change anything?


In reply to: 221307649 [](ancestors = 221307649,221298419,221113276)

L1Weight = Args.L1Weight;
OptTol = Args.OptTol;
MemorySize = Args.MemorySize;
Contracts.CheckParam(l2Weight >= 0, nameof(l2Weight), "Must be non-negative, if provided.");
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contracts [](start = 12, length = 9)

why not Host? #Resolved

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!


In reply to: 221114697 [](ancestors = 221114697)

Action<LinearBinaryPredictor> onFit = null
)
{
Contracts.CheckValue(label, nameof(label));
Copy link
Contributor

@Ivanidzo4ka Ivanidzo4ka Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contracts [](start = 12, length = 9)

technically you have ctx.Environment #Pending

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx is just the trainers, not the context. I don't have the env.


In reply to: 221115177 [](ancestors = 221115177)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you do. You need to call StaticPipeUtils.GetEnvironment to get it


In reply to: 221295921 [](ancestors = 221295921,221115177)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That requires a SchemaBearing, as argument. Doesn't seem worth to construct one to just check on the params..


In reply to: 221307369 [](ancestors = 221307369,221295921,221115177)


}

internal sealed class LbfgsStaticsUtils{
Copy link
Contributor

@Zruty0 Zruty0 Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Statics [](start = 31, length = 7)

static ? #Resolved

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the class itself should be static


In reply to: 221307856 [](ancestors = 221307856)

Copy link
Contributor

@Zruty0 Zruty0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

/// <param name="features">The features, or independent variables.</param>
/// <param name="weights">The optional example weights.</param>
/// <param name="enoforceNoNegativity">Enforce non-negative weights.</param>
/// <param name="l1Weight">Weight of L1 regularizer term.</param>
Copy link
Contributor

@artidoro artidoro Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it is more standard to say regularization, instead of regularizer. #Resolved

@artidoro
Copy link
Contributor

artidoro commented Sep 28, 2018

using Float = System.Single;

If you have time, would be a good idea to clean this up. #Resolved


Refers to: src/Microsoft.ML.StandardLearners/Standard/Online/OnlineGradientDescent.cs:5 in f414717. [](commit_id = f414717, deletion_comment = False)

string labelColumn,
string featureColumn,
float learningRate = Arguments.OgdDefaultArgs.LearningRate,
bool decreaseLearningRate =Arguments.OgdDefaultArgs.DecreaseLearningRate,
Copy link
Contributor

@artidoro artidoro Sep 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a space after equal. #Resolved

@@ -46,10 +46,22 @@ public sealed class Arguments : ArgumentsBase
/// <param name="labelColumn">The name of the label column.</param>
/// <param name="featureColumn">The name of the feature column.</param>
/// <param name="weightColumn">The name for the example weight column.</param>
/// <param name="enforceNoNegativity">Enforce non-negative weights.</param>
/// <param name="l1Weight">Weight of L1 regularizer term.</param>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regularizer [](start = 48, length = 11)

regularizer pops up in many files, let me see if I can help you find them.

Copy link
Contributor

@artidoro artidoro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@sfilipi sfilipi merged commit 0b9ca00 into dotnet:master Sep 28, 2018
@sfilipi sfilipi deleted the morePigstensions branch September 28, 2018 21:02
@ghost ghost locked as resolved and limited conversation to collaborators Mar 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
API Issues pertaining the friendly API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants