You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/code/MlNetCookBook.md
+56Lines changed: 56 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -578,6 +578,60 @@ var biases = modelParameters.GetBiases();
578
578
579
579
```
580
580
581
+
## How do I get a model's weights to look at the global feature importance?
582
+
The below snippet shows how to get a model's weights to help determine the feature importance of the model for a linear model.
583
+
584
+
```csharp
585
+
varlinearModel=model.LastTransformer.Model;
586
+
587
+
varweights=linearModel.Weights;
588
+
```
589
+
590
+
The below snipper shows how to get the weights for a fast tree model.
591
+
592
+
```csharp
593
+
vartreeModel=model.LastTransformer.Model;
594
+
595
+
varweights=newVBuffer<float>();
596
+
treeModel.GetFeatureWeights(refweights);
597
+
```
598
+
599
+
## How do I look at the global feature importance?
600
+
The below snippet shows how to get a glimpse of the the feature importance. Permutation Feature Importance works by computing the change in the evaluation metrics when each feature is replaced by a random value. In this case, we are investigating the change in the root mean squared error. For more information on permutation feature importance, review the [documentation](https://docs.microsoft.com/en-us/dotnet/machine-learning/how-to-guides/determine-global-feature-importance-in-model).
## What is normalization and why do I need to care?
582
636
583
637
In ML.NET we expose a number of [parametric and non-parametric algorithms](https://machinelearningmastery.com/parametric-and-nonparametric-machine-learning-algorithms/).
@@ -788,6 +842,7 @@ var transformedData = pipeline.Fit(data).Transform(data);
[Cross-validation](https://en.wikipedia.org/wiki/Cross-validation_(statistics)) is a useful technique for ML applications. It helps estimate the variance of the model quality from one run to another and also eliminates the need to extract a separate test set for evaluation.
@@ -838,6 +893,7 @@ var microAccuracies = cvResults.Select(r => r.Metrics.AccuracyMicro);
838
893
Console.WriteLine(microAccuracies.Average());
839
894
840
895
```
896
+
841
897
## Can I mix and match static and dynamic pipelines?
842
898
843
899
Yes, we can have both of them in our codebase. The static pipelines are just a statically-typed way to build dynamic pipelines.
0 commit comments