PTransform
s for transforming
data in a pipeline.See: Description
| Interface | Description |
|---|---|
| Aggregator<InputT,OutputT> |
An
Aggregator<InputT> enables monitoring of values of type InputT ,
to be combined across all bundles. |
| Combine.AccumulatingCombineFn.Accumulator<InputT,AccumT,OutputT> |
The type of mutable accumulator values used by this
AccumulatingCombineFn . |
| CombineFnBase.GlobalCombineFn<InputT,AccumT,OutputT> |
A
GloballyCombineFn<InputT, AccumT, OutputT> specifies how to combine a
collection of input values of type InputT into a single
output value of type OutputT . |
| CombineFnBase.PerKeyCombineFn<K,InputT,AccumT,OutputT> |
A
PerKeyCombineFn<K, InputT, AccumT, OutputT> specifies how to combine
a collection of input values of type InputT , associated with
a key of type K , into a single output value of type
OutputT . |
| CombineWithContext.RequiresContextInternal |
An internal interface for signaling that a
GloballyCombineFn
or a PerKeyCombineFn needs to access CombineWithContext.Context . |
| DoFn.RequiresWindowAccess |
Interface for signaling that a
DoFn needs to access the window the
element is being processed in, via DoFn.ProcessContext.window() . |
| DoFnReflector.DoFnInvoker<InputT,OutputT> |
Interface for invoking the
DoFn processing methods. |
| DoFnWithContext.ExtraContextFactory<InputT,OutputT> |
Interface for runner implementors to provide implementations of extra context information.
|
| Partition.PartitionFn<T> |
A function object that chooses an output partition for an element.
|
| SerializableComparator<T> |
A
Comparator that is also Serializable . |
| SerializableFunction<InputT,OutputT> |
A function that computes an output value of type
OutputT from an input value of type
InputT and is Serializable . |
| Class | Description |
|---|---|
| AggregatorRetriever |
An internal class for extracting
Aggregators from DoFns . |
| AppliedPTransform<InputT extends PInput,OutputT extends POutput,TransformT extends PTransform<? super InputT,OutputT>> |
Represents the application of a
PTransform to a specific input to produce
a specific output. |
| ApproximateQuantiles |
PTransform s for getting an idea of a PCollection 's
data distribution using approximate N -tiles (e.g. |
| ApproximateQuantiles.ApproximateQuantilesCombineFn<T,ComparatorT extends Comparator<T> & Serializable> |
The
ApproximateQuantilesCombineFn combiner gives an idea
of the distribution of a collection of values using approximate
N -tiles. |
| ApproximateUnique |
PTransform s for estimating the number of distinct elements
in a PCollection , or the number of distinct values
associated with each key in a PCollection of KV s. |
| ApproximateUnique.ApproximateUniqueCombineFn<T> |
CombineFn that computes an estimate of the number of
distinct values that were combined. |
| ApproximateUnique.ApproximateUniqueCombineFn.LargestUnique |
A heap utility class to efficiently track the largest added elements.
|
| Combine |
PTransform s for combining PCollection elements
globally and per-key. |
| Combine.AccumulatingCombineFn<InputT,AccumT extends Combine.AccumulatingCombineFn.Accumulator<InputT,AccumT,OutputT>,OutputT> |
A
CombineFn that uses a subclass of
Combine.AccumulatingCombineFn.Accumulator as its accumulator
type. |
| Combine.BinaryCombineDoubleFn |
An abstract subclass of
Combine.CombineFn for implementing combiners that are more
easily and efficiently expressed as binary operations on double s. |
| Combine.BinaryCombineFn<V> |
An abstract subclass of
Combine.CombineFn for implementing combiners that are more
easily expressed as binary operations. |
| Combine.BinaryCombineIntegerFn |
An abstract subclass of
Combine.CombineFn for implementing combiners that are more
easily and efficiently expressed as binary operations on int s |
| Combine.BinaryCombineLongFn |
An abstract subclass of
Combine.CombineFn for implementing combiners that are more
easily and efficiently expressed as binary operations on long s. |
| Combine.CombineFn<InputT,AccumT,OutputT> |
A
CombineFn<InputT, AccumT, OutputT> specifies how to combine a
collection of input values of type InputT into a single
output value of type OutputT . |
| Combine.Globally<InputT,OutputT> |
Combine.Globally<InputT, OutputT> takes a PCollection<InputT>
and returns a PCollection<OutputT> whose elements are the result of
combining all the elements in each window of the input PCollection ,
using a specified CombineFn<InputT, AccumT, OutputT> . |
| Combine.GloballyAsSingletonView<InputT,OutputT> |
Combine.GloballyAsSingletonView<InputT, OutputT> takes a PCollection<InputT>
and returns a PCollectionView<OutputT> whose elements are the result of
combining all the elements in each window of the input PCollection ,
using a specified CombineFn<InputT, AccumT, OutputT> . |
| Combine.GroupedValues<K,InputT,OutputT> |
GroupedValues<K, InputT, OutputT> takes a
PCollection<KV<K, Iterable<InputT>>> , such as the result of
GroupByKey , applies a specified
KeyedCombineFn<K, InputT, AccumT, OutputT>
to each of the input KV<K, Iterable<InputT>> elements to
produce a combined output KV<K, OutputT> element, and returns a
PCollection<KV<K, OutputT>> containing all the combined output
elements. |
| Combine.Holder<V> |
Holds a single value value of type
V which may or may not be present. |
| Combine.IterableCombineFn<V> | |
| Combine.KeyedCombineFn<K,InputT,AccumT,OutputT> |
A
KeyedCombineFn<K, InputT, AccumT, OutputT> specifies how to combine
a collection of input values of type InputT , associated with
a key of type K , into a single output value of type
OutputT . |
| Combine.PerKey<K,InputT,OutputT> |
PerKey<K, InputT, OutputT> takes a
PCollection<KV<K, InputT>> , groups it by key, applies a
combining function to the InputT values associated with each
key to produce a combined OutputT value, and returns a
PCollection<KV<K, OutputT>> representing a map from each
distinct key of the input PCollection to the corresponding
combined value. |
| Combine.PerKeyWithHotKeyFanout<K,InputT,OutputT> |
Like
Combine.PerKey , but sharding the combining of hot keys. |
| Combine.SimpleCombineFn<V> | Deprecated |
| CombineFnBase |
This class contains the shared interfaces and abstract classes for different types of combine
functions.
|
| CombineFns |
Static utility methods that create combine function instances.
|
| CombineFns.CoCombineResult |
A tuple of outputs produced by a composed combine functions.
|
| CombineFns.ComposeCombineFnBuilder |
A builder class to construct a composed
CombineFnBase.GlobalCombineFn . |
| CombineFns.ComposedCombineFn<DataT> |
A composed
Combine.CombineFn that applies multiple CombineFns . |
| CombineFns.ComposedCombineFnWithContext<DataT> |
A composed
CombineWithContext.CombineFnWithContext that applies multiple
CombineFnWithContexts . |
| CombineFns.ComposedKeyedCombineFn<DataT,K> |
A composed
Combine.KeyedCombineFn that applies multiple KeyedCombineFns . |
| CombineFns.ComposedKeyedCombineFnWithContext<DataT,K> |
A composed
CombineWithContext.KeyedCombineFnWithContext that applies multiple
KeyedCombineFnWithContexts . |
| CombineFns.ComposeKeyedCombineFnBuilder |
A builder class to construct a composed
CombineFnBase.PerKeyCombineFn . |
| CombineWithContext |
This class contains combine functions that have access to
PipelineOptions and side inputs
through CombineWithContext.Context . |
| CombineWithContext.CombineFnWithContext<InputT,AccumT,OutputT> |
A combine function that has access to
PipelineOptions and side inputs through
CombineWithContext.Context . |
| CombineWithContext.Context |
Information accessible to all methods in
CombineFnWithContext
and KeyedCombineFnWithContext . |
| CombineWithContext.KeyedCombineFnWithContext<K,InputT,AccumT,OutputT> |
A keyed combine function that has access to
PipelineOptions and side inputs through
CombineWithContext.Context . |
| Count |
PTransorm s to count the elements in a PCollection . |
| Count.PerElement<T> |
Count.PerElement<T> takes a PCollection<T> and returns a
PCollection<KV<T, Long>> representing a map from each distinct element of the input
PCollection to the number of times that element occurs in the input. |
| Create<T> |
Create<T> takes a collection of elements of type T
known when the pipeline is constructed and returns a
PCollection<T> containing the elements. |
| Create.TimestampedValues<T> |
A
PTransform that creates a PCollection whose elements have
associated timestamps. |
| Create.Values<T> |
A
PTransform that creates a PCollection from a set of in-memory objects. |
| DoFn<InputT,OutputT> |
The argument to
ParDo providing the code to use to process
elements of the input
PCollection . |
| DoFnReflector |
Utility implementing the necessary reflection for working with
DoFnWithContext s. |
| DoFnTester<InputT,OutputT> |
A harness for unit-testing a
DoFn . |
| DoFnWithContext<InputT,OutputT> |
The argument to
ParDo providing the code to use to process
elements of the input
PCollection . |
| Filter<T> |
PTransform s for filtering from a PCollection the
elements satisfying a predicate, or satisfying an inequality with
a given value based on the elements' natural ordering. |
| FlatMapElements<InputT,OutputT> |
PTransform s for mapping a simple function that returns iterables over the elements of a
PCollection and merging the results. |
| FlatMapElements.MissingOutputTypeDescriptor<InputT,OutputT> |
An intermediate builder for a
FlatMapElements transform. |
| Flatten |
Flatten<T> takes multiple PCollection<T> s bundled
into a PCollectionList<T> and returns a single
PCollection<T> containing all the elements in all the input
PCollection s. |
| Flatten.FlattenIterables<T> |
FlattenIterables<T> takes a PCollection<Iterable<T>> and returns a
PCollection<T> that contains all the elements from each iterable. |
| Flatten.FlattenPCollectionList<T> |
A
PTransform that flattens a PCollectionList
into a PCollection containing all the elements of all
the PCollection s in its input. |
| GroupByKey<K,V> |
GroupByKey<K, V> takes a PCollection<KV<K, V>> ,
groups the values by key and windows, and returns a
PCollection<KV<K, Iterable<V>>> representing a map from
each distinct key and window of the input PCollection to an
Iterable over all the values associated with that key in
the input per window. |
| IntraBundleParallelization |
Provides multi-threading of
DoFn s, using threaded execution to
process multiple elements concurrently within a bundle. |
| IntraBundleParallelization.Bound<InputT,OutputT> |
A
PTransform that, when applied to a PCollection<InputT> ,
invokes a user-specified DoFn<InputT, OutputT> on all its elements,
with all its outputs collected into an output
PCollection<OutputT> . |
| IntraBundleParallelization.MultiThreadedIntraBundleProcessingDoFn<InputT,OutputT> |
A multi-threaded
DoFn wrapper. |
| IntraBundleParallelization.Unbound |
An incomplete
IntraBundleParallelization transform, with unbound input/output types. |
| Keys<K> |
Keys<K> takes a PCollection of KV<K, V> s and
returns a PCollection<K> of the keys. |
| KvSwap<K,V> |
KvSwap<K, V> takes a PCollection<KV<K, V>> and
returns a PCollection<KV<V, K>> , where all the keys and
values have been swapped. |
| MapElements<InputT,OutputT> |
PTransform s for mapping a simple function over the elements of a PCollection . |
| MapElements.MissingOutputTypeDescriptor<InputT,OutputT> |
An intermediate builder for a
MapElements transform. |
| Max |
PTransform s for computing the maximum of the elements in a PCollection , or the
maximum of the values associated with each key in a PCollection of KV s. |
| Max.MaxDoubleFn |
A
CombineFn that computes the maximum of a collection of Double s, useful as an
argument to Combine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) or Combine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) . |
| Max.MaxFn<T> |
A
CombineFn that computes the maximum of a collection of elements of type T
using an arbitrary Comparator , useful as an argument to Combine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) or
Combine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) . |
| Max.MaxIntegerFn |
A
CombineFn that computes the maximum of a collection of Integer s, useful as an
argument to Combine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) or Combine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) . |
| Max.MaxLongFn |
A
CombineFn that computes the maximum of a collection of Long s, useful as an
argument to Combine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) or Combine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) . |
| Mean |
PTransform s for computing the arithmetic mean
(a.k.a. |
| Min |
PTransform s for computing the minimum of the elements in a PCollection , or the
minimum of the values associated with each key in a PCollection of KV s. |
| Min.MinDoubleFn |
A
CombineFn that computes the minimum of a collection of Double s, useful as an
argument to Combine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) or Combine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) . |
| Min.MinFn<T> |
A
CombineFn that computes the maximum of a collection of elements of type T
using an arbitrary Comparator , useful as an argument to Combine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) or
Combine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) . |
| Min.MinIntegerFn |
A
CombineFn that computes the minimum of a collection of Integer s, useful as an
argument to Combine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) or Combine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) . |
| Min.MinLongFn |
A
CombineFn that computes the minimum of a collection of Long s, useful as an
argument to Combine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) or Combine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) . |
| ParDo |
ParDo is the core element-wise transform in Google Cloud
Dataflow, invoking a user-specified function on each of the elements of the input
PCollection to produce zero or more output elements, all
of which are collected into the output PCollection . |
| ParDo.Bound<InputT,OutputT> |
A
PTransform that, when applied to a PCollection<InputT> ,
invokes a user-specified DoFn<InputT, OutputT> on all its elements,
with all its outputs collected into an output
PCollection<OutputT> . |
| ParDo.BoundMulti<InputT,OutputT> |
A
PTransform that, when applied to a
PCollection<InputT> , invokes a user-specified
DoFn<InputT, OutputT> on all its elements, which can emit elements
to any of the PTransform 's main and side output
PCollection s, which are bundled into a result
PCollectionTuple . |
| ParDo.Unbound |
An incomplete
ParDo transform, with unbound input/output types. |
| ParDo.UnboundMulti<OutputT> |
An incomplete multi-output
ParDo transform, with unbound
input type. |
| Partition<T> |
Partition takes a PCollection<T> and a
PartitionFn , uses the PartitionFn to split the
elements of the input PCollection into N partitions, and
returns a PCollectionList<T> that bundles N
PCollection<T> s containing the split elements. |
| PTransform<InputT extends PInput,OutputT extends POutput> | |
| RemoveDuplicates<T> |
RemoveDuplicates<T> takes a PCollection<T> and
returns a PCollection<T> that has all the elements of the
input but with duplicate elements removed such that each element is
unique within each window. |
| RemoveDuplicates.WithRepresentativeValues<T,IdT> |
A
RemoveDuplicates PTransform that uses a SerializableFunction to
obtain a representative value for each input element. |
| Sample |
PTransform s for taking samples of the elements in a
PCollection , or samples of the values associated with each
key in a PCollection of KV s. |
| Sample.FixedSizedSampleFn<T> |
CombineFn that computes a fixed-size sample of a
collection of values. |
| Sample.SampleAny<T> |
A
PTransform that takes a PCollection<T> and a limit, and
produces a new PCollection<T> containing up to limit
elements of the input PCollection . |
| SimpleFunction<InputT,OutputT> |
A
SerializableFunction which is not a functional interface. |
| Sum |
PTransform s for computing the sum of the elements in a
PCollection , or the sum of the values associated with
each key in a PCollection of KV s. |
| Sum.SumDoubleFn |
A
SerializableFunction that computes the sum of an
Iterable of Double s, useful as an argument to
Combine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) or Combine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) . |
| Sum.SumIntegerFn |
A
SerializableFunction that computes the sum of an
Iterable of Integer s, useful as an argument to
Combine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) or Combine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) . |
| Sum.SumLongFn |
A
SerializableFunction that computes the sum of an
Iterable of Long s, useful as an argument to
Combine.globally(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) or Combine.perKey(org.apache.beam.sdk.transforms.SerializableFunction<java.lang.Iterable<V>, V>) . |
| Top |
PTransform s for finding the largest (or smallest) set
of elements in a PCollection , or the largest (or smallest)
set of values associated with each key in a PCollection of
KV s. |
| Top.Largest<T extends Comparable<? super T>> |
A
Serializable Comparator that that uses the compared elements' natural
ordering. |
| Top.Smallest<T extends Comparable<? super T>> |
Serializable Comparator that that uses the reverse of the compared elements'
natural ordering. |
| Top.TopCombineFn<T,ComparatorT extends Comparator<T> & Serializable> |
CombineFn for Top transforms that combines a
bunch of T s into a single count -long
List<T> , using compareFn to choose the largest
T s. |
| Values<V> |
Values<V> takes a PCollection of KV<K, V> s and
returns a PCollection<V> of the values. |
| View |
Transforms for creating
PCollectionViews from
PCollections (to read them as side inputs). |
| View.AsIterable<T> |
Not intended for direct use by pipeline authors; public only so a
PipelineRunner may
override its behavior. |
| View.AsList<T> |
Not intended for direct use by pipeline authors; public only so a
PipelineRunner may
override its behavior. |
| View.AsMap<K,V> |
Not intended for direct use by pipeline authors; public only so a
PipelineRunner may
override its behavior. |
| View.AsMultimap<K,V> |
Not intended for direct use by pipeline authors; public only so a
PipelineRunner may
override its behavior. |
| View.AsSingleton<T> |
Not intended for direct use by pipeline authors; public only so a
PipelineRunner may
override its behavior. |
| View.CreatePCollectionView<ElemT,ViewT> |
Creates a primitive
PCollectionView . |
| WithKeys<K,V> |
WithKeys<K, V> takes a PCollection<V> , and either a
constant key of type K or a function from V to
K , and returns a PCollection<KV<K, V>> , where each
of the values in the input PCollection has been paired with
either the constant key or a key computed from the value. |
| WithTimestamps<T> |
A
PTransform for assigning timestamps to all the elements of a PCollection . |
| Enum | Description |
|---|---|
| DoFnTester.CloningBehavior |
Whether or not a
DoFnTester should clone the DoFn under test. |
| Annotation Type | Description |
|---|---|
| DoFnWithContext.FinishBundle |
Annotation for the method to use to prepare an instance for processing a batch of elements.
|
| DoFnWithContext.ProcessElement |
Annotation for the method to use for processing elements.
|
| DoFnWithContext.StartBundle |
Annotation for the method to use to prepare an instance for processing a batch of elements.
|
PTransform
s for transforming
data in a pipeline.
A PTransform
is an operation that takes an
InputT
(some subtype of PInput
)
and produces an
OutputT
(some subtype of POutput
).
Common PTransforms include root PTransforms like
TextIO.Read
and
Create
, processing and
conversion operations like ParDo
,
GroupByKey
,
CoGroupByKey
,
Combine
, and
Count
, and outputting
PTransforms like
TextIO.Write
.
New PTransforms can be created by composing existing PTransforms. Most PTransforms in this package are composites, and users can also create composite PTransforms for their own application-specific logic.
Copyright © 2016 The Apache Software Foundation. All rights reserved.


{% extends "main.html" %} {% block content %} {% include "header.html" %}
Explore data portals and learn how you can contribute and access their data.


Why should we test code?
Why should we write testable code?
So we don't end up with 1600 line Winform button clicks.
It happens all the time.
Office layout for software department at my first job out of college.
This was typical.
Private Sub btnOrderCreate_Click(sender As object, e As EventArgs) Handles btnOrderCreate.Click
...

' Create Order
ElseIf something or other Then
...
Else
...
End If
...
End Sub
This happened over 12 years.
Testing this code was a very manual, tedious, and inprecise process.
I haven't listed the other 20,000 lines in this one file.
Did I mention there are hundreds of forms?
The code was too complicated and no separation of concerns made unit tests near impossible.
High-level modules should not depend on low-level modules. Both should depend on abstractions.
Abstractions should not depend on details. Details should depend on abstractions.
Now might be a good time to spoil the ending to the concepts here.
Dependency injection by adding ASP.NET Core Services.
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddSingleton<ICacheResults, InMemoryCache>();
}
One day I walked into work after a late night deployment of a major software update...
A LOT of work had been done in this file, and we knew something was breaking in this 3000 line button click based on pictures from the client.
Private Sub btnOrderCreate_Click(sender As object, e As EventArgs) Handles btnOrderCreate.Click
...

' Create Order
ElseIf something or other Then
...
Else
...
End If
...
End Sub
When a client can't take orders, that's the most important problem.
How can I find the problem?
I suppose that I need to run the code by stepping through the code and debugging it and
guessing.
Is it safe to run the code?
The same skills you use to debug software, is the same skills you use to refactor code to write tests for the code.
Enough of my problems for a bit, here's the software I want to write tests for today.
// GET api/meetup
[HttpGet()]
public IEnumerable<string> Get()
{
return this.searchRankings.GetRecentSearchResults();
}
// GET api/meetup/knox-net
[HttpGet("{name}")]
public async Task<IEnumerable<string>> Get(string name)
{
if(string.IsNullOrWhiteSpace(name)) {
return new string[0];
}
this.searchRankings.AddRecentSearch(name);
HttpResponseMessage response = await httpClient.GetAsync($"{name}/events?key={this.meetupApiKey}&status=past");
var events = await response.Content.ReadAsAsync<List<MeetupEvent>>();
return events.Select(x => x.name);
}
private readonly string meetupApiKey;
private readonly HttpClient httpClient;
private readonly ICacheResults searchRankings;
public MeetupController(IConfiguration configuration, ICacheResults searchRankings)
{
meetupApiKey = configuration.GetValue<string>("MEETUP_API_KEY");
httpClient = new HttpClient() {
BaseAddress = new Uri("https://api.meetup.com/")
};
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
this.searchRankings = searchRankings;
}
https://dev.azure.com/knoxdevops/knoxdevops
The problems with testing this code.
Note: I'm ignoring the argument whether API controllers should be tested, this depends on company and team.
To get back to my life, it's getting close to noon.
And the store running this Point-Of-Sale interface couldn't take orders.
My problems from back then are mildly relevant because I was
To test the "business logic", I need to make sure the Production Meetup API doesn't influence my
tests.
Mock objects are simulated objects that mimic the behavior of real objects in controlled ways.
(wikipedia definition)
To simulate objects, we need to know what behavior they have.
public interface IMeetupApi
{
Task<IEnumerable<string>> GetPastEventNames(string meetupName);
}
Identifying, isolating, and mocking external dependencies is the single most important thing to writing unit tests.
Instead of creating HttpClient, I use an injected IMeetupApi.
private readonly IMeetupApi meetupApi;
private readonly ICacheResults searchRankings;
public BetterMeetupController(IMeetupApi meetupApi, ICacheResults searchRankings)
{
this.meetupApi = meetupApi;
this.searchRankings = searchRankings;
}
Now the controller doesn't care about HttpClient.
// GET api/BetterMeetup/knox-net
[HttpGet("{name}")]
public async Task<IEnumerable<string>> Get(string name)
{
if(string.IsNullOrWhiteSpace(name)) {
return new string[0];
}
this.searchRankings.AddRecentSearch(name);
return await this.meetupApi.GetPastEventNames(name);
}
I can create a dummy API that given an expected value, returns expected results.
The point isn't to test the API, it's to test the code that calls the API.
private class DummyApiClient: IMeetupApi
{
public Task<IEnumerable<string>> GetPastEventNames(string meetupName)
{
Assert.Equal("knox-net", meetupName);
var results = new[]
{
"Event1",
"Event2"
};
return Task.FromResult((IEnumerable<string>)results);
}
}
Now I can write a test for the Meetup Controller using the DummyApiClient.
[Fact]
public async Task TestMeetupApi()
{
var inMemoryCache = new InMemoryCache();
var meetupController =
new BetterMeetupController(
new DummyApiClient(),
inMemoryCache
);
Assert.Empty(inMemoryCache.GetRecentSearchResults());
var events = await meetupController.Get("knox-net");
Assert.Equal(new[]
{
"Event1",
"Event2"
}, events);
Assert.NotEmpty(inMemoryCache.GetRecentSearchResults());
}
The implementation of the MeetupApi doesn't even matter, it shouldn't be different code than it was before. It's just in a different place.
public class MeetupApiClient: IMeetupApi
{
private readonly string meetupApiKey;
private readonly HttpClient httpClient;
public MeetupApiClient(HttpClient httpClient, IConfiguration configuration)
{
this.meetupApiKey = configuration.GetValue<string>("MEETUP_API_KEY");
this.httpClient = httpClient;
}
public async Task<IEnumerable<string>> GetPastEventNames(string meetupName)
{
HttpResponseMessage response = await httpClient.GetAsync($"{meetupName}/events?key={this.meetupApiKey}&status=past");
var events = await response.Content.ReadAsAsync<List<MeetupEvent>>();
return events.Select(x => x.name);
}
}
If you notice, when I say "isolate", I could be saying Don't Repeat Yourself.
Be sure to add the new MeetupApi implementation to the Startup.cs class.
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddSingleton<ICacheResults, InMemoryCache>();
services.AddHttpClient<IMeetupApi, MeetupApiClient>(client =>
{
client.BaseAddress = new Uri("https://api.meetup.com/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
});
}
Sometime later in the day, we got more logs that said something about a "SQLException".
This was very unusual and extremely bad for me, because we software developers were very much
*required* to test all our prepared inline SQL
statements by hand.
We start going SQL statement by SQL query throughout the entire 3000 lines of code.
About halfway through, my boss sees something he gets suspicious about.
He tells me to test this statement. I step through the code to that statement, and it passes.
He walks away.
Five minutes later, he comes to me and tells me that this statement is only valid on SQL Server 2008
and above, which is what our in-house test environment was running.
The client was running SQL Server 2005
A unit test wouldn't have caught this, but the lack of tests didn't rule out the other 2600 lines that weren't SQL.
Microsoft MVP
Website: olivercoding.com
Twitter: @a_software_dev
Github: danieloliver
Slides: https://dotnet-testing-talk.olivercoding.com/


Toggle navigation
Brand
Link
(current)
Link
Dropdown
Action
Another action
Something else here
Separated link
One more separated link
More
Action
Another action
Something else here
Separated link
About
Quick Links
News
Wiki
Media
Links
Anthony Rendon News
Profile
Stats
Advanced
Data


Channels are JSON files hosted on a URL that contains a list of repository URLs. See example-channel.json for the format. When a user requests to install a package, their channels are queried for a list of repositories. By default, a single channel is included with Package Control, https://packagecontrol.io/channel.json. The only reason to create another channel is if you want to create a private distribution for a closed group of people.
Repositories are JSON files hosted on a URL that contain a list of one or more packages. See example-repository.json for the format. The JSON structure allows for specifying platforms (windows, osx, linux), compatible versions of Sublime Text, labels, URLs and more. The default channel includes a number of third-party repositories, but also a single, centralized repository for developers who are using GitHub or BitBucket tag-based releases. This way a package only ever needs to be added to the repository once and almost all futher updates to the package can be performed via the GitHub or BitBucket user interfaces.


HOME
ABOUT
CONTACT
SEARCH
Sign Up
Login
Best Furniture
Add to cart
Add to cart
Add to cart
Add to cart
Add to cart
Add to cart
Add to cart
Add to cart
Add to cart
Add to cart
Add to cart
Add to cart


--- layout: page title: "404" permalink: /404 ---
If you've followed a link expecting something to be here, you can contact me.


Natsuko's Blog
-
Meeting the Community
The weekend has been the most breakthrough weekend for us in terms of getting to know people. We were especially keen to meet the expat community because even though we’ve been here three months now, we hadn’t gotten to know the foreigners like us residing in Nepal. And we were...
-
Reflection of 'Moving Asia' - Photo Kathmandu
Today I had the opportunity to attend a panel discussions titled “Moving Asia” - a dialogue sessions by photo journalists about migration in South Asia. This panel discussion was among the many events held throughout the week as part of the Photo Kathmandu initiative, the only international photography festival in...
-
Happy Dashain!
Last week were on a week long Dashain holiday, the largest holiday in Nepal. Dashain, also known as Vijaya Dashami, celebrates the “triumph over evil”, commemorating the victory of gods over the demons. The goddess Durga, who played an instrumental role in the battle between Lord Ram against the wicked...
-
Achieving product/market fit
In my previous blog “Let’s talk about startup failure and how to deal with it”, I talked a little bit about how we pivoted to releasing a completely remote course, without really elaborating on it or following up with the results. I’d like to look at our pivot here in...
-
What are your work productivity hacks?
One thing about my self, I’m a person that gets distracted pretty easily. I’m not good at focusing on one task at the same time for hours on end, like my partner Take. His focus is truly amazing – he would be on his computer the whole day coding if...


matchzoo.engine package¶
Submodules¶
matchzoo.engine.base_metric module¶
Metric base class and some related utilities.
-
class
matchzoo.engine.base_metric.
BaseMetric
¶ Bases:
abc.ABC
Metric base class.
-
ALIAS
= 'base_metric'¶
-
-
matchzoo.engine.base_metric.
parse_metric
(metric)¶ Parse input metric in any form into a
BaseMetric
instance.Parameters: metric ( Union
[str
,Type
[BaseMetric
],BaseMetric
]) – Input metric in any form.Returns: A BaseMetric
instance- Examples::
>>> from matchzoo import engine, metrics
- Use str as keras native metrics:
>>> engine.parse_metric('mse') 'mse'
- Use str as MatchZoo metrics:
>>> mz_metric = engine.parse_metric('map') >>> type(mz_metric) <class 'matchzoo.metrics.mean_average_precision.MeanAveragePrecision'>
- Use
matchzoo.engine.BaseMetric
subclasses as MatchZoo metrics: >>> type(engine.parse_metric(metrics.AveragePrecision)) <class 'matchzoo.metrics.average_precision.AveragePrecision'>
- Use
matchzoo.engine.BaseMetric
instances as MatchZoo metrics: >>> type(engine.parse_metric(metrics.AveragePrecision())) <class 'matchzoo.metrics.average_precision.AveragePrecision'>
-
matchzoo.engine.base_metric.
sort_and_couple
(labels, scores)¶ Zip the labels with scores into a single list.
Return type: <built-in function array>
matchzoo.engine.base_model module¶
Base Model.
-
class
matchzoo.engine.base_model.
BaseModel
(params=None, backend=None)¶ Bases:
abc.ABC
Abstract base class of all matchzoo models.
-
BACKEND_WEIGHTS_FILENAME
= 'backend_weights.h5'¶
-
PARAMS_FILENAME
= 'params.dill'¶
-
backend
¶ return model backend, a keras model instance.
Return type: Model
-
build
()¶ Build model, each sub class need to impelemnt this method.
Example
>>> BaseModel() # doctest: +ELLIPSIS Traceback (most recent call last): ... TypeError: Can't instantiate abstract class BaseModel ... >>> class MyModel(BaseModel): ... def build(self): ... pass >>> assert MyModel()
-
compile
()¶ Compile model for training.
Only keras native metrics are compiled together with backend. MatchZoo metrics are evaluated only through
evaluate()
. Notice that keras count loss as one of the metrics while MatchZoomatchzoo.engine.BaseTask
does not.Examples
>>> from matchzoo import models >>> model = models.NaiveModel() >>> model.guess_and_fill_missing_params(verbose=0) >>> model.params['task'].metrics = ['mse', 'map'] >>> model.params['task'].metrics ['mse', mean_average_precision(0)] >>> model.build() >>> model.compile()
-
evaluate
(x, y, batch_size=128, verbose=1)¶ Evaluate the model.
See
keras.models.Model.evaluate()
for more details.Parameters: - x (
Union
[ndarray
,List
[ndarray
],Dict
[str
,ndarray
]]) – input data - y (
ndarray
) – labels - batch_size (
int
) – number of samples per gradient update - verbose (
int
) – verbosity mode, 0 or 1
Return type: Dict
[str
,float
]Returns: scalar test loss (if the model has a single output and no metrics) or list of scalars (if the model has multiple outputs and/or metrics). The attribute model.backend.metrics_names will give you the display labels for the scalar outputs.
- Examples::
>>> import matchzoo as mz >>> data_pack = mz.datasets.toy.load_data() >>> preprocessor = mz.preprocessors.NaivePreprocessor() >>> data_pack = preprocessor.fit_transform(data_pack) >>> m = mz.models.DenseBaselineModel() >>> m.params['task'] = mz.tasks.Ranking() >>> m.params['task'].metrics = [ ... 'acc', 'mse', 'mae', 'ce', ... 'average_precision', 'precision', 'dcg', 'ndcg', ... 'mean_reciprocal_rank', 'mean_average_precision', 'mrr', ... 'map', 'MAP', ... mz.metrics.AveragePrecision(threshold=1), ... mz.metrics.Precision(k=2, threshold=2), ... mz.metrics.DiscountedCumulativeGain(k=2), ... mz.metrics.NormalizedDiscountedCumulativeGain( ... k=3, threshold=-1), ... mz.metrics.MeanReciprocalRank(threshold=2), ... mz.metrics.MeanAveragePrecision(threshold=3) ... ] >>> m.guess_and_fill_missing_params(verbose=0) >>> m.build() >>> m.compile() >>> x, y = data_pack.unpack() >>> evals = m.evaluate(x, y, verbose=0) >>> type(evals) <class 'dict'>
- x (
-
fit
(x, y, batch_size=128, epochs=1, verbose=1, **kwargs)¶ Fit the model.
See
keras.models.Model.fit()
for more details.Parameters: - x (
Union
[ndarray
,List
[ndarray
]]) – input data. - y (
ndarray
) – labels. - batch_size (
int
) – number of samples per gradient update. - epochs (
int
) – number of epochs to train the model. - verbose (
int
) – 0, 1, or 2. Verbosity mode. 0 = silent, 1 = verbose, 2 = one log line per epoch.
Key word arguments not listed above will be propagated to keras’s fit.
Return type: History
Returns: A keras.callbacks.History instance. Its history attribute contains all information collected during training. - x (
-
fit_generator
(generator, epochs=1, verbose=1, **kwargs)¶ Fit the model with matchzoo generator.
See
keras.models.Model.fit_generator()
for more details.Parameters: - generator (
DataGenerator
) – A generator, an instance ofengine.DataGenerator
. - epochs (
int
) – Number of epochs to train the model. - verbose (
int
) – 0, 1, or 2. Verbosity mode. 0 = silent, 1 = verbose, 2 = one log line per epoch.
Return type: History
Returns: A keras.callbacks.History instance. Its history attribute contains all information collected during training.
- generator (
-
classmethod
get_default_params
(with_embedding=False, with_multi_layer_perceptron=False)¶ Model default parameters.
- The common usage is to instantiate
matchzoo.engine.ModelParams
- first, then set the model specific parametrs.
Examples
>>> class MyModel(BaseModel): ... def build(self): ... print(self._params['num_eggs'], 'eggs') ... print('and', self._params['ham_type']) ... ... @classmethod ... def get_default_params(cls): ... params = engine.ParamTable() ... params.add(engine.Param('num_eggs', 512)) ... params.add(engine.Param('ham_type', 'Parma Ham')) ... return params >>> my_model = MyModel() >>> my_model.build() 512 eggs and Parma Ham
Notice that all parameters must be serialisable for the entire model to be serialisable. Therefore, it’s strongly recommended to use python native data types to store parameters.
Return type: ParamTable
Returns: model parameters - The common usage is to instantiate
-
classmethod
get_default_preprocessor
()¶ Model default preprocessor.
The preprocessor’s transform should produce a correctly shaped data pack that can be used for training. Some extra configuration (e.g. setting input_shapes in
matchzoo.models.DSSMModel
may be required on the user’s end.Return type: BasePreprocessor
Returns: Default preprocessor.
-
guess_and_fill_missing_params
(verbose=1)¶ Guess and fill missing parameters in
params
.Use this method to automatically fill-in hyper parameters. This involves some guessing so the parameter it fills could be wrong. For example, the default task is Ranking, and if we do not set it to Classification manaully for data packs prepared for classification, then the shape of the model output and the data will mismatch.
Parameters: verbose – Verbosity.
-
load_embedding_matrix
(embedding_matrix, name='embedding')¶ Load an embedding matrix.
Load an embedding matrix into the model’s embedding layer. The name of the embedding layer is specified by name. For models with only one embedding layer, set name=’embedding’ when creating the keras layer, and use the default name when load the matrix. For models with more than one embedding layers, initialize keras layer with different layer names, and set name accordingly to load a matrix to a chosen layer.
Parameters: - embedding_matrix (
ndarray
) – Embedding matrix to be loaded. - name (
str
) – Name of the layer. (default: ‘embedding’)
- embedding_matrix (
-
params
¶ model parameters.
Type: return Return type: ParamTable
-
predict
(x, batch_size=128)¶ Generate output predictions for the input samples.
See
keras.models.Model.predict()
for more details.Parameters: - x (
Union
[ndarray
,List
[ndarray
]]) – input data - batch_size – number of samples per gradient update
Return type: ndarray
Returns: numpy array(s) of predictions
- x (
-
save
(dirpath)¶ Save the model.
A saved model is represented as a directory with two files. One is a model parameters file saved by pickle, and the other one is a model h5 file saved by keras.
Parameters: dirpath ( Union
[str
,Path
]) – directory path of the saved model
-
-
matchzoo.engine.base_model.
load_model
(dirpath)¶ Load a model. The reverse function of
BaseModel.save()
.Parameters: dirpath ( Union
[str
,Path
]) – directory path of the saved modelReturn type: BaseModel
Returns: a BaseModel
instance
matchzoo.engine.base_preprocessor module¶
BasePreprocessor
define input and ouutput for processors.
-
class
matchzoo.engine.base_preprocessor.
BasePreprocessor
¶ Bases:
object
BasePreprocessor
to input handle data.-
DATA_FILENAME
= 'preprocessor.dill'¶
-
context
¶ Return context.
-
fit
(data_pack, verbose=1)¶ Fit parameters on input data.
This method is an abstract base method, need to be implemented in the child class.
This method is expected to return itself as a callable object.
Parameters: - data_pack (
DataPack
) –Datapack
object to be fitted. - verbose – Verbosity.
Return type: - data_pack (
-
fit_transform
(data_pack, verbose=1)¶ Call fit-transform.
Parameters: data_pack ( DataPack
) –DataPack
object to be processed.Return type: DataPack
-
save
(dirpath)¶ Save the
DSSMPreprocessor
object.A saved
DSSMPreprocessor
is represented as a directory with the context object (fitted parameters on training data), it will be saved by pickle.Parameters: dirpath ( Union
[str
,Path
]) – directory path of the savedDSSMPreprocessor
.
-
transform
(data_pack, verbose=1)¶ Transform input data to expected manner.
This method is an abstract base method, need to be implemented in the child class.
Parameters: - data_pack (
DataPack
) –DataPack
object to be transformed. - verbose – Verbosity. or list of text-left, text-right tuples.
Return type: - data_pack (
-
-
matchzoo.engine.base_preprocessor.
load_preprocessor
(dirpath)¶ Load the fitted context. The reverse function of
save()
.Parameters: dirpath ( Union
[str
,Path
]) – directory path of the saved model.Return type: DataPack
Returns: a DSSMPreprocessor
instance.
-
matchzoo.engine.base_preprocessor.
validate_context
(func)¶ Validate context in the preprocessor.
matchzoo.engine.base_task module¶
Base task.
-
class
matchzoo.engine.base_task.
BaseTask
(loss=None, metrics=None)¶ Bases:
abc.ABC
Base Task, shouldn’t be used directly.
-
classmethod
convert_metrics
(metrics)¶ Convert metrics into properly formed list of metrics.
Examples
>>> BaseTask.convert_metrics(['mse']) ['mse'] >>> BaseTask.convert_metrics('map') [mean_average_precision(0)]
-
classmethod
list_available_losses
()¶ Return type: list
Returns: a list of available losses.
-
classmethod
list_available_metrics
()¶ Return type: list
Returns: a list of available metrics.
-
loss
¶ Loss used in the task.
Type: return
-
metrics
¶ Metrics used in the task.
Type: return
-
output_dtype
¶ output data type for specific task.
Type: return
-
output_shape
¶ output shape of a single sample of the task.
Type: return Return type: tuple
-
classmethod
matchzoo.engine.callbacks module¶
Callbacks.
-
class
matchzoo.engine.callbacks.
EvaluateAllMetrics
(model, x, y, once_every=1, batch_size=32, model_save_path=None, verbose=1)¶ Bases:
keras.callbacks.Callback
Callback to evaluate all metrics.
MatchZoo metrics can not be evaluated batch-wise since they require dataset-level information. As a result, MatchZoo metrics are not evaluated automatically when a Model fit. When this callback is used, all metrics, including MatchZoo metrics and Keras metrics, are evluated once every once_every epochs.
Parameters: - model (
BaseModel
) – Model to evaluate. - x (
Union
[ndarray
,List
[ndarray
]]) – - y (
ndarray
) – - once_every (
int
) – Evaluation only triggers when epoch % once_every == 0. (default: 1, i.e. evaluate on every epoch’s end) - batch_size (
int
) – Number of samples per evaluation. This only affects the evaluation of Keras metrics, since MatchZoo metrics are always evaluated using the full data. - model_save_path (
Optional
[str
]) – Directory path to save the model after each evaluate callback, (default: None, i.e., no saving.) - verbose – Verbosity.
-
on_epoch_end
(epoch, logs=None)¶ Called at the end of en epoch.
Parameters: - epoch – integer, index of epoch.
- logs – dictionary of logs.
Returns: dictionary of logs.
- model (
matchzoo.engine.hyper_spaces module¶
Hyper parameter search spaces wrapping hyperopt.
-
class
matchzoo.engine.hyper_spaces.
HyperoptProxy
(hyperopt_func, **kwargs)¶ Bases:
object
Hyperopt proxy class.
See hyperopt’s documentation for more details: https://github.com/hyperopt/hyperopt/wiki/FMin
Reason of these wrappers:
A hyper space in hyperopt requires a label to instantiate. This label is used later as a reference to original hyper space that is sampled. In matchzoo, hyper spaces are used inmatchzoo.engine.Param
. Only if a hyper space’s label matches its parentmatchzoo.engine.Param
’s name, matchzoo can correctly back-refrenced the parameter got sampled. This can be done by asking the user always use the same name for a parameter and its hyper space, but typos can occur. As a result, these wrappers are created to hide hyper spaces’ label, and always correctly bind them with its parameter’s name.- Examples::
>>> import matchzoo as mz >>> from hyperopt.pyll.stochastic import sample
- Basic Usage:
>>> model = mz.models.DenseBaselineModel() >>> sample(model.params.hyper_space) # doctest: +SKIP {'mlp_num_layers': 1.0, 'mlp_num_units': 274.0}
- Arithmetic Operations:
>>> new_space = 2 ** mz.hyper_spaces.quniform(2, 6) >>> model.params.get('mlp_num_layers').hyper_space = new_space >>> sample(model.params.hyper_space) # doctest: +SKIP {'mlp_num_layers': 8.0, 'mlp_num_units': 292.0}
-
convert
(name)¶ Attach name as hyperopt.hp’s label.
Parameters: name ( str
) –Return type: Apply
Returns: a hyperopt ready search space
-
class
matchzoo.engine.hyper_spaces.
choice
(options)¶ Bases:
matchzoo.engine.hyper_spaces.HyperoptProxy
hyperopt.hp.choice()
proxy.
-
class
matchzoo.engine.hyper_spaces.
quniform
(low, high, q=1)¶ Bases:
matchzoo.engine.hyper_spaces.HyperoptProxy
hyperopt.hp.quniform()
proxy.
-
class
matchzoo.engine.hyper_spaces.
uniform
(low, high)¶ Bases:
matchzoo.engine.hyper_spaces.HyperoptProxy
hyperopt.hp.uniform()
proxy.
matchzoo.engine.param module¶
Parameter class.
-
class
matchzoo.engine.param.
Param
(name, value=None, hyper_space=None, validator=None, desc=None)¶ Bases:
object
Parameter class.
Basic usages with a name and value:
>>> param = Param('my_param', 10) >>> param.name 'my_param' >>> param.value 10
Use with a validator to make sure the parameter always keeps a valid value.
>>> param = Param( ... name='my_param', ... value=5, ... validator=lambda x: 0 < x < 20 ... ) >>> param.validator # doctest: +ELLIPSIS <function <lambda> at 0x...> >>> param.value 5 >>> param.value = 10 >>> param.value 10 >>> param.value = -1 Traceback (most recent call last): ... ValueError: Validator not satifised. The validator's definition is as follows: validator=lambda x: 0 < x < 20
Use with a hyper space. Setting up a hyper space for a parameter makes the parameter tunable in a
matchzoo.engine.Tuner
.>>> from matchzoo.engine.hyper_spaces import quniform >>> param = Param( ... name='positive_num', ... value=1, ... hyper_space=quniform(low=1, high=5) ... ) >>> param.hyper_space # doctest: +ELLIPSIS <matchzoo.engine.hyper_spaces.quniform object at ...> >>> from hyperopt.pyll.stochastic import sample >>> hyperopt_space = param.hyper_space.convert(param.name) >>> samples = [sample(hyperopt_space) for _ in range(64)] >>> set(samples) == {1, 2, 3, 4, 5} True
The boolean value of a
Param
instance is only True when the value is not None. This is because some default falsy values like zero or an empty list are valid parameter values. In other words, the boolean value means to be “if the parameter value is filled”.>>> param = Param('dropout') >>> if param: ... print('OK') >>> param = Param('dropout', 0) >>> if param: ... print('OK') OK
A _pre_assignment_hook is initialized as a data type convertor if the value is set as a number to keep data type consistency of the parameter. This conversion supports python built-in numbers, numpy numbers, and any number that inherits
numbers.Number
.>>> param = Param('float_param', 0.5) >>> param.value = 10 >>> param.value 10.0 >>> type(param.value) <class 'float'>
-
desc
¶ Parameter description.
Type: return
-
hyper_space
¶ Hyper space of the parameter.
Type: return
-
name
¶ Name of the parameter.
Type: return Return type: str
-
set_default
(val, verbose=1)¶ Set default value, has no effect if already has a value.
Parameters: - val – Default value to set.
- verbose – Verbosity.
-
validator
¶ Validator of the parameter.
Type: return Return type: Callable
[[Any
],bool
]
-
value
¶ Value of the parameter.
Type: return Return type: Any
-
matchzoo.engine.param_table module¶
Parameters table class.
-
class
matchzoo.engine.param_table.
ParamTable
¶ Bases:
object
Parameter table class.
Example
>>> params = ParamTable() >>> params.add(Param('ham', 'Parma Ham')) >>> params.add(Param('egg', 'Over Easy')) >>> params['ham'] 'Parma Ham' >>> params['egg'] 'Over Easy' >>> print(params) ham Parma Ham egg Over Easy >>> params.add(Param('egg', 'Sunny side Up')) Traceback (most recent call last): ... ValueError: Parameter named egg already exists. To re-assign parameter egg value, use `params["egg"] = value` instead.
-
completed
()¶ Return type: bool
Returns: True if all params are filled, False otherwise. Example
>>> import matchzoo >>> model = matchzoo.models.NaiveModel() >>> model.params.completed() False >>> model.guess_and_fill_missing_params(verbose=0) >>> model.params.completed() True
-
hyper_space
¶ Hyper space of the table, a valid hyperopt graph.
Type: return Return type: dict
-
keys
()¶ Return type: Keysview
[~KT]Returns: Parameter table keys.
-
set
(key, param)¶ Set key to parameter param.
-


For full functionality of this site it is necessary to enable JavaScript. Here are the
instructions how to enable JavaScript in your web browser
.
Flickr Public Feed


Venus is the only planet that rotates clockwise.
Jupiter is bigger than all the other planets combined.


{% extends "views/base.html" %} {% block body %}
Request: {{wish.tagline}} Wisher: {{wish.user_key}} Fulfiller: {{wish.user_fulfiller_key}} Donation: ${{wish.cache_money}}


@mpSdk
Camera
Direction
Direction Enumeration
Usage of the SDK constitutes your agreement with the
Matterport SDK Agreement
. Email
<EMAIL_ADDRESS>with any questions.


Returns true if the grid is currently grouped by at least one column value.
(boolean) - True if the grid is grouped, false if not.
(boolean)
new DobyGrid(...).isGrouped();


Questions about the mortgage process?
If you’ve received a Loan Estimate, you may be wondering what to expect next. Reviewing your Loan Estimate and deciding whether to proceed with that loan offer is an important part of the mortgage process. Our tools and resources help you navigate the process and choose a mortgage that’s right for you.
What to do now
1. Review your Loan Estimate
Your Loan Estimate is the official government form that tells you important details about the costs and risks of your loan offer. It’s standardized, so you can easily compare offers.
Review our interactive sample Loan Estimate
2. Request additional Loan Estimates from different lenders
When you get Loan Estimates from multiple lenders, you can compare to see which lender is offering you your best deal. For the most useful comparison, request the same kind of loan from each lender.
Learn how to shop for multiple Loan Estimates
3. Check to see if your interest rate is locked
Some lenders may lock your rate as part of issuing the Loan Estimate, but some may not. Check at the top of page 1 on your Loan Estimate to see whether your rate is locked, and until when. If your rate is not locked, it can change at any time. If your interest rate is locked, your rate won’t change between now and closing, as long as you close within the specified timeframe and there are no changes to your application.
Learn more about what a rate lock is and how it works
What happens next
1. Decide if you want to proceed with your loan application and let the lender know
Once you’ve chosen a loan offer, you need to tell the lender you want to proceed with that loan application. This is called “expressing your intent to proceed.” Lenders have to wait until you express your intent to proceed with a particular application before they can charge you application or appraisal fees.
Learn more about expressing your intent to proceed
2. Look out for revised Loan Estimates between now and closing
When important information about your loan changes, your lender may give you a new Loan Estimate. This can happen if the home was appraised at less than the sales price or estimated value, if your credit score changes, or if your lender cannot document your income. You will also receive a revised Loan Estimate if you decide to get a different kind of loan, change your down payment amount, or request a rate lock after the lender issued the original Loan Estimate.
Learn more about when you might receive a revised Loan Estimate
{% include "_templates/ratings-form.html" %}


Previously viewed auctions:
Eiffel Tower is the symbol of Paris and named by Gustave Eiffel.
Director John Ford used Monument Valley for a number of his best-known films.
Mount Fuji is the highest mountain in Japan and a frequent attractive subject of Japanese art.
Tokyo Tower is a communications and observation tower located in Tokyo, Japan.


Times and locations may occasionally change each week so please check this page often. Office hours could be in Rashid Auditorium


uname - get name and information about current kernel
#include <sys/utsname.h>
int uname(struct utsname *buf);
uname() returns system information in the structure pointed to by
buf. The utsname struct is defined in
<sys/utsname.h>:
struct utsname {
char sysname[]; /* Operating system name (e.g., "Linux") */
char nodename[]; /* Name within "some implementation-defined
network" */
char release[]; /* Operating system release (e.g., "2.6.28") */
char version[]; /* Operating system version */
char machine[]; /* Hardware identifier */
#ifdef _GNU_SOURCE
char domainname[]; /* NIS or YP domain name */
#endif
};
The length of the arrays in a struct utsname is unspecified
(see NOTES); the fields are terminated by a null byte ('\0').
On success, zero is returned. On error, -1 is returned, and errno is set
appropriately.
POSIX.1-2001, POSIX.1-2008, SVr4. There is no uname() call in 4.3BSD.
The domainname member (the NIS or YP domain name) is a GNU
extension.
This is a system call, and the operating system presumably knows its name,
release and version. It also knows what hardware it runs on. So, four of the
fields of the struct are meaningful. On the other hand, the field
nodename is meaningless: it gives the name of the present machine in
some undefined network, but typically machines are in more than one network
and have several names. Moreover, the kernel has no way of knowing about such
things, so it has to be told what to answer here. The same holds for the
additional domainname field.
To this end, Linux uses the system calls sethostname(2) and
setdomainname(2). Note that there is no standard that says that the
hostname set by sethostname(2) is the same string as the
nodename field of the struct returned by uname() (indeed, some
systems allow a 256-byte hostname and an 8-byte nodename), but this is true
on Linux. The same holds for setdomainname(2) and the
domainname field.
The length of the fields in the struct varies. Some operating
systems or libraries use a hardcoded 9 or 33 or 65 or 257. Other systems use
SYS_NMLN or _SYS_NMLN or UTSLEN or
_UTSNAME_LENGTH. Clearly, it is a bad idea to use any of these
constants; just use sizeof(...). Often 257 is chosen in order to have room
for an internet hostname.
Part of the utsname information is also accessible via
/proc/sys/kernel/{ostype, hostname, osrelease,
version, domainname}.
Over time, increases in the size of the utsname structure have led to
three successive versions of uname(): sys_olduname() (slot
__NR_oldolduname), sys_uname() (slot __NR_olduname), and
sys_newuname() (slot __NR_uname). The first one used length 9
for all fields; the second used 65; the third also uses 65 but adds the
domainname field. The glibc uname() wrapper function hides these
details from applications, invoking the most recent version of the system call
provided by the kernel.
uname(1), getdomainname(2), gethostname(2),
uts_namespaces(7)
This page is part of release 5.05 of the Linux man-pages project. A
description of the project, information about reporting bugs, and the latest
version of this page, can be found at https://www.kernel.org/doc/man-pages/.


|
|
2. Contest open to all existing Coastline
Micro customers and any new customers registered during the term of
the contest, up to and including June 30, 2000. 3. Any new Coastline Micro customers who register
during the contest period will automatically receive an entry into the
Grand Prize drawing. 4. In addition to the entry at the time of
registration, for each purchase of a Coastline Micro equal to or greater
than $2,500, each registrant will receive an additional entry into the
drawing for the Grand Prize. No limit on the number of entries allowed.
Registrants must be 18 years or older to qualify for the Grand Prize. 5. The Grand Prize drawing will be held before
July 31, 2000. Odds of winning are based on the number of entries. The
winner will be selected by random drawing from among all entries. The
Grand Prize winner shall be notified by telephone, fax and/or mail.
The Grand Prize is not transferable and no substitutions are allowed.
The Grand Prize may not be redeemed for cash. Taxes, if any, are the
sole responsibility of the winner. This offer is void where prohibited
and is subject to all Federal and State laws. 6. The Grand Prize winner waives any and all
claims of liability and hereby releases, indemnifies and holds harmless
Coastline Micro, their affiliates, subsidiaries, advertising and promotional
agencies, and Pelican Hill Golf Club from any loss, accident, or injuring
occurring as a result or consequence of this program or any award received
through the program. Coastline Micro reserves the right to add, modify
or delete any of the policies and/or awards at any time with or without
prior notice. All policy interpretations and implementations will be
made by Coastline Micro. The Grand Prize winner hereby agrees that his/her
names, picture or likeness may be featured in Coastline Micro's publications
and promotionals, on and offline, without further compensation. Corporate
names and trademarks stated herein are the property of their respective
companies. 7. The Grand Prize is a complete round of
golf (18 holes) and a golf cart for two players at Pelican Hill Golf
Club at 22651 Pelican Hill Road South, Newport Coast, CA 92657. Grand
Prize winner is responsible for transportation to and from Pelican Hill
Golf Club. Grand Prize winner is responsible for abiding by Pelican
Hill Golf Club's rules, regulations, dress codes and hours of operation.
Grand Prize winner must make reservations for the round of golf no later
than one year after being notified of prize. For reservations and information,
call Pelican Hills Golf Club at<PHONE_NUMBER>.
|
|
© 1997-1999 Coastline Micro, Inc. Please send comments and questions
to<EMAIL_ADDRESS>|


--- ---
A Gentle Introduction to Python is 100% free, just like all OpenCourseWare. Anyone can join, and you're welcome to share your work.
Pick up Python from leading innovators in online learning. MIT's chops. Codecademy's exercises. OpenStudy's study groups. P2PU's community. Need we say more?
Make friends with some smarties, and start programming from Week 1. Open for signup now, course starts Fall 2013.


| UseOfDevice | ||
| DeviceUseStatement | Event | |
| id | ||
| meta | ||
| implicitRules | ||
| language | ||
| text | ||
| contained | ||
| extension | ||
| modifierExtension | ||
| identifier | Event.identifier | |
| basedOn | Event.basedOn | |
| status | Event.status | |
| subject | Event.subject | |
| derivedFrom | ||
| timing[x] | Event.occurrence[x] | |
| recordedOn | ||
| source | Event.performer.actor | |
| device | ||
| reasonCode | Event.reasonCode | |
| reasonReference | Event.reasonReference | |
| bodySite | Event.note | |
| note | Event.note |
| UseOfDevice | ||
| DeviceUseStatement | DeviceUsePerformanceOccurrence | |
| id | ||
| meta | ||
| implicitRules | ||
| language | ||
| text | ||
| contained | ||
| extension | ||
| modifierExtension | ||
| identifier | ClinicalStatement.identifier | |
| basedOn | ||
| status | …status | |
| subject | ClinicalStatement.subject | |
| derivedFrom | ||
| timing[x] | DeviceUse.applicationSchedule | |
| recordedOn | ClinicalStatement.statementDateTime | |
| source | ||
| device | DeviceUse.device | |
| reasonCode | Action.indication.reason | |
| reasonReference | ||
| bodySite | ||
| note | ClinicalStatement.additionalText |
| UseOfDevice | ||
| DeviceUseStatement | ||
| id | ||
| meta | ||
| implicitRules | ||
| language | ||
| text | ||
| contained | ||
| extension | ||
| modifierExtension | ||
| identifier | FiveWs.identifier | |
| basedOn | ||
| status | FiveWs.status | |
| subject | FiveWs.subject[x], FiveWs.subject | |
| derivedFrom | ||
| timing[x] | FiveWs.done[x] | |
| recordedOn | FiveWs.recorded | |
| source | FiveWs.actor | |
| device | FiveWs.actor | |
| reasonCode | FiveWs.why[x] | |
| reasonReference | FiveWs.why[x] | |
| bodySite | ||
| note |
| UseOfDevice | ||
| DeviceUseStatement | ||
| id | ||
| meta | ||
| implicitRules | ||
| language | ||
| text | ||
| contained | ||
| extension | ||
| modifierExtension | ||
| identifier | ||
| basedOn | ORC in proximity to EVN segment | |
| status | ||
| subject | ||
| derivedFrom | ||
| timing[x] | ||
| recordedOn | ||
| source | ||
| device | ||
| reasonCode | ||
| reasonReference | EVN.4 or by domain | |
| bodySite | ||
| note |
| UseOfDevice | ||
| DeviceUseStatement | Entity. Role, or Act | |
| id | ||
| meta | ||
| implicitRules | ||
| language | ||
| text | Act.text? | |
| contained | N/A | |
| extension | N/A | |
| modifierExtension | N/A | |
| identifier | ||
| basedOn | .outboundRelationship[typeCode=FLFS].target | |
| status | .statusCode | |
| subject | ||
| derivedFrom | ||
| timing[x] | ||
| recordedOn | ||
| source | ||
| device | ||
| reasonCode | ||
| reasonReference | .outboundRelationship[typeCode=RSON].target | |
| bodySite | targetSiteCode | |
| note |


Click here to see the manual in its own window.
Looks like your browser doesn't support embedding HTML files. Click here to see the manual.


By Saskia | January 7, 2019
This post has been stimulated by a discussion with a colleague who asked about the normalization method for the root mean square error (NRMSE) in the INDperform R package, which is based on the indicator testing framework outlined in my article (Otto et al. 2018)1. At the time of writing the article and package I simply used a common approach and didn’t test it much further. But sparked by this discussion I started to test it thoroughly (as you will see below), which will make me revise the package.
The Root Mean Square Error (RMSE)
In statistical modeling and particularly regression analyses, a common way of measuring the quality of the fit of the model is the RMSE (also called Root Mean Square Deviation), given by $$RMSE = \sqrt\frac{\sum_{i=1}^{n} \left(y_{i} - \hat{y}\right)^{2}} {n}$$
where \(y_{i}\) is the ith observation of y and ŷ the predicted y value given the model. If the predicted responses are very close to the true responses the RMSE will be small. If the predicted and true responses differ substantially - at least for some observations - the RMSE will be large. A value of zero would indicate a perfect fit to the data. Since the RMSE is measured on the same scale, with the same units as \(y\), one can expect 68% of the y values to be within 1 RMSE - given the data is normally distributed.
So calculating the MSE helps comparing different models that are based on the same y observations. But what if
- one wants to compare model fits of different response variables?
- the response variable y is modified in some models, e.g. standardized or sqrt- or log-transformed?
- And does the slitting of data into a training and test dataset (after the modification) and the RMSE calculation based on the test data an effect on point 1. and 2.?
The first two points are typical issues when comparing ecological indicator performances and the latter, so-called validation set approach2, is pretty common in statistical and machine learning. One solution to overcome these barriers - as done in INDperform - is to calculate the Normalized RMSE.
Normalized Root Mean Square Error (NRMSE)
There is a saying that apples shouldn’t be compared with oranges or in other words, don’t compare two items or group of items that are practically incomparable. But the lack of comparability can be overcome if the two items or groups are somehow standardized or brought on the same scale. For instance, when comparing the variances of two groups that are overall very different, such as the variance in size of bluefin tuna and blue whales, the coefficient of variation (CV) is the method of choice: the CV simply represents the variance of each group standardized by its group mean:
tuna <- c(150, 200, 250, 210,180, 305)
whale <- c(2300, 2000, 2250, 1900, 2100)
c( var(tuna), var(whale) )
## [1] 3004.167 28000.000
c( sd(tuna), sd(whale) )
## [1] 54.81028 167.33201
c( var(tuna)/mean(tuna), var(whale)/mean(whale) )
## [1] 13.91892 13.27014
While in absolute values the individual whales differ from each other much more than the tuna fish, this variation is rather small relative to the overall size of the whales and then comparable to tuna.
In the same way, normalizing the RMSE facilitates the comparison between datasets or models with different scales. You will find, however, various different methods of RMSE normalizations in the literature:
You can normalize by
the mean: \(NRMSE = \frac{RMSE}{\bar{y}}\) (similar to the CV and applied in INDperform)
the difference between maximum and minimum: \(NRMSE = \frac{RMSE}{y_{max} - y_{min}}\),
the standard deviation: \(NRMSE = \frac{RMSE}{\sigma}\), or
the interquartile range; \(NRMSE = \frac{RMSE}{Q1 - Q3}\), i.e. the difference between 25th and 75th percentile,
of observations.
If the response variables has few extreme values, choosing the interquartile range is a good option as it is less sensitive to outliers. But how do these methods compare in terms of data transformation and the validation set approach?
Comparison of different RMSE normalizations under different data treatments
In the following comparison I will compare the 4 methods using the original, standardized, sqrt- and log-transformed dataset. First I will use the full dataset to train and test the model (via RNMSE), then split the data into a training and test subset. In this case, I will assume the data is a time series and the validation is performed on the last years (so no random splitting) as done in many time series predictions.
To be able to link the results of the comparison to the approach in INDperform I will also use here Generalized Additive Models (GAM)3 based on the mgcv package.
Self-made functions
library(mgcv)
library(tidyverse)
Hand-made NRMSE function:
nrmse_func <- function(obs, pred, type = "sd") {
squared_sums <- sum((obs - pred)^2)
mse <- squared_sums/length(obs)
rmse <- sqrt(mse)
if (type == "sd") nrmse <- rmse/sd(obs)
if (type == "mean") nrmse <- rmse/mean(obs)
if (type == "maxmin") nrmse <- rmse/ (max(obs) - min(obs))
if (type == "iq") nrmse <- rmse/ (quantile(obs, 0.75) - quantile(obs, 0.25))
if (!type %in% c("mean", "sd", "maxmin", "iq")) message("Wrong type!")
nrmse <- round(nrmse, 3)
return(nrmse)
}
The following comp_func()
function does the actual modeling, prediction and NRMSE calculation for the different Y’s on the full or split data (split = TRUE
, taking the last 5 observations for testing):
# helper function for comp_func()
lowest <- function(x) {
x <- paste0(names(which(x == min(x))), collapse = ",")
return(x)
}
comp_func <- function(y, x, split = TRUE, test_n = 5) {
df <- data.frame(x = x, y = y)
# Add y transformations
df$y_stand = as.vector(scale(df$y))
df$y_sqrt = sqrt(df$y)
df$y_log = log(df$y)
# Split time series into training/test data (or not)
if (split == TRUE) {
df_train <- df[1:(nrow(df) - test_n), ]
df_test <- df[(nrow(df_train)+1):nrow(df), ]
} else {
df_train <- df
df_test <- df
}
# Models
m1 <- gam(y ~ s(x, k = 4), data = df_train)
m2 <- gam(y_stand ~ s(x, k = 4), data = df_train)
m3 <- gam(y_sqrt ~ s(x, k = 4), data = df_train)
m4 <- gam(y_log ~ s(x, k = 4), data = df_train)
# Predictions
df_comp <- df_test
df_comp$pred <- as.vector(predict(m1, newdata = df_test))
df_comp$pred_stand <- as.vector(predict(m2, newdata = df_test))
df_comp$pred_sqrt <- as.vector(predict(m3, newdata = df_test))
df_comp$pred_log <- as.vector(predict(m4, newdata = df_test))
# Back-transform the predictions for y_sqrt and y_log for comparison
df_comp$pred_sqrt_b<- df_comp$pred_sqrt ^2
df_comp$pred_log_b <- exp(df_comp$pred_log)
# Reorder variables for NRMSE loop (add y twice for back-transformed predictions)
df_loop <- df_comp[ ,c(2,3,4,2,5,2,6:8,10,9,11)]
# Calculate NRMSE for 4 different types of normalization
type_vec <- c("mean", "sd", "maxmin", "iq")
out <- data.frame(
type = type_vec,
y = rep(NA, 4), y_stand = rep(NA, 4),
y_sqrt = rep(NA, 4), y_sqrt_b = rep(NA, 4),
y_log = rep(NA, 4), y_log_b = rep(NA, 4)
)
for (i in 1:4) {
for (k in 1:6) {
out[i, k+1] <- nrmse_func(obs = df_loop[ ,k], pred = df_loop[ ,k+6], type = type_vec[i])
}
}
# Add column indicating whether y, y_sqr, y_sqr_b, y_log or y_log_b2
# has the lowest NRMSE
out$lowest <- unlist(apply(out[ ,c(2,4:7)], 1, FUN = lowest))
out
return(out)
}
Simulated datasets
set.seed(1)
simdat <- data.frame(
x1 = 1:20,
# add polynomial of second order to produce a non-linear decline
y1 = 170 + 2.5*1:20 - 0.5* (1:20)^2 + rnorm(20, 0, 40),
x2 = sample(seq(15, 30, 0.01), 20)
)
# produce linear positive trend
simdat$y2 <- 50 + 1.5 * simdat$x2 + rnorm(20, 0, 8)
# produce same trend but with increasing variance
simdat$y3 <- simdat$y2
for (i in 1:20) {
noise <- rnorm(1, 0, sd = 2*i)
simdat$y3[i] <- simdat$y3[i] + noise
}
par(mfrow = c(1,3))
plot(simdat$y1 ~ simdat$x1)
plot(simdat$y2 ~ simdat$x2)
plot(simdat$y3 ~ simdat$x2)
Comparison
Full data
fd1 <- comp_func(x = simdat$x1, y = simdat$y1, split = FALSE)
fd1 %>%
knitr::kable(
format = "html", align = "c",
col.names = c("Type", "Raw Y", "Standardized", "Sqrt-transf.", "Sqrt-backtransf.",
"Log-transf.", "Log-backtransf.", "Lowest NRMSE"),
caption = "Non-linear (full) dataset"
) %>%
kableExtra::kable_styling(
bootstrap_options = c("striped", "condensed", "responsive")
)
| Type | Raw Y | Standardized | Sqrt-transf. | Sqrt-backtransf. | Log-transf. | Log-backtransf. | Lowest NRMSE |
|---|---|---|---|---|---|---|---|
| mean | 0.256 | 2.90688e+15 | 0.159 | 0.264 | 0.094 | 0.310 | y_log |
| sd | 0.590 | 5.90000e-01 | 0.631 | 0.608 | 0.725 | 0.713 | y |
| maxmin | 0.156 | 1.56000e-01 | 0.160 | 0.161 | 0.174 | 0.188 | y |
| iq | 0.365 | 3.65000e-01 | 0.436 | 0.376 | 0.617 | 0.441 | y |
fd2 <- comp_func(x = simdat$x2, y = simdat$y2, split = FALSE)
| Type | Raw Y | Standardized | Sqrt-transf. | Sqrt-backtransf. | Log-transf. | Log-backtransf. | Lowest NRMSE |
|---|---|---|---|---|---|---|---|
| mean | 0.060 | 7.994036e+14 | 0.030 | 0.060 | 0.014 | 0.060 | y_log |
| sd | 0.554 | 5.540000e-01 | 0.543 | 0.552 | 0.533 | 0.551 | y_log |
| maxmin | 0.155 | 1.550000e-01 | 0.154 | 0.155 | 0.152 | 0.154 | y_log |
| iq | 0.608 | 6.080000e-01 | 0.610 | 0.606 | 0.615 | 0.604 | y_log_b |
fd3 <- comp_func(x = simdat$x2, y = simdat$y3, split = FALSE)
| Type | Raw Y | Standardized | Sqrt-transf. | Sqrt-backtransf. | Log-transf. | Log-backtransf. | Lowest NRMSE |
|---|---|---|---|---|---|---|---|
| mean | 0.321 | -5.439201e+15 | 0.168 | 0.323 | 0.085 | 0.328 | y_log |
| sd | 0.865 | 8.650000e-01 | 0.849 | 0.870 | 0.848 | 0.885 | y_log |
| maxmin | 0.194 | 1.940000e-01 | 0.184 | 0.195 | 0.179 | 0.198 | y_log |
| iq | 0.966 | 9.660000e-01 | 0.976 | 0.971 | 1.104 | 0.987 | y |
SUMMARY:
- NRMSE of the standardized Y is
- close to zero when using type mean → this is not surprising given the nature of the standardization itself (the “standardization”, also called “normalization” or “z-transformation”, standardizes the data to a mean of zero and a standard deviation of 1).
- exactly the same than the NRMSE for the original Y when using the other normalization methods
- NRMSE of the transformed Ys always deviates from the NRMSE of the original Y, no matter which method was used (except for the second dataset, when using the mean); however, back-transforming does bring the NRMSE closer to the original NRMSE! The degree of deviation depends also on the Y~X relationship and, hence, the model (smaller in the linear datasets)!
- Log-transforming Y deviates much greater and often leads to a lower NRMSE, although this also depends on the Y~X relationship.
- No clear pattern in the performance differences between the four normalization types (unless variables are standardized).
Test data
td1 <- comp_func(x = simdat$x1, y = simdat$y1, split = TRUE, test_n = 5)
| Type | Raw Y | Standardized | Sqrt-transf. | Sqrt-backtransf. | Log-transf. | Log-backtransf. | Lowest NRMSE |
|---|---|---|---|---|---|---|---|
| mean | 0.268 | -0.306 | 0.150 | 0.288 | 0.089 | 0.340 | y_log |
| sd | 1.077 | 1.077 | 1.147 | 1.157 | 1.367 | 1.365 | y |
| maxmin | 0.402 | 0.402 | 0.431 | 0.431 | 0.518 | 0.509 | y |
| iq | 1.469 | 1.469 | 1.675 | 1.578 | 2.164 | 1.863 | y |
td2 <- comp_func(x = simdat$x2, y = simdat$y2, split = TRUE, test_n = 5)
| Type | Raw Y | Standardized | Sqrt-transf. | Sqrt-backtransf. | Log-transf. | Log-backtransf. | Lowest NRMSE |
|---|---|---|---|---|---|---|---|
| mean | 0.058 | -2.271 | 0.030 | 0.060 | 0.014 | 0.063 | y_log |
| sd | 0.572 | 0.572 | 0.578 | 0.593 | 0.583 | 0.615 | y |
| maxmin | 0.230 | 0.230 | 0.233 | 0.238 | 0.236 | 0.247 | y |
| iq | 0.793 | 0.793 | 0.833 | 0.822 | 0.878 | 0.852 | y |
td3 <- comp_func(x = simdat$x2, y = simdat$y3, split = TRUE, test_n = 5)
| Type | Raw Y | Standardized | Sqrt-transf. | Sqrt-backtransf. | Log-transf. | Log-backtransf. | Lowest NRMSE |
|---|---|---|---|---|---|---|---|
| mean | 0.550 | 6.792 | 0.306 | 0.554 | 0.161 | 0.559 | y_log |
| sd | 0.928 | 0.928 | 0.879 | 0.934 | 0.855 | 0.944 | y_log |
| maxmin | 0.361 | 0.361 | 0.340 | 0.363 | 0.335 | 0.367 | y_log |
| iq | 0.822 | 0.822 | 0.894 | 0.827 | 1.102 | 0.836 | y |
SUMMARY:
- Overall, deviations between different data treatments are much greater when training the model on a training subset and computing the NRMSE for a test subset.
- Similar to using the full data, NRMSEs of the original and standardized Y are the same, except when using the mean to normalize.
- But beside the standardization, performances of the four normalization are comparable, even when using only a test subset.
- Again, transformed Ys always differ in their NRMSE from the original Y and this difference is
- greater in the log-transformed Ys
- but: back-transforming does not always reduce the difference as shown in the second, linear dataset with constant variance.
Conclusion
So what did we learn from this simulation?
First and foremost, comparing model performances between different response variables is not that trivial and there is no normalization method (of the one tested here) that is obviously superior. But there are a few implications that data analysts should bear in mind when computing the NRMSE for performance comparison:
- NRMSE should be better computed on the untransformed scale. That means, if the response variable Y was transformed prior to the modeling, to e.g. linearize the relationship, reduce heterogeneity, etc., the predicted values should be back-transformed and compared with the observed raw data when computing the NRMSE.
- Using the mean to normalize the NRMSE is ok as long as you compare models that are based on the same response variable and data treatment.
- Otherwise, use any of the other 3 methods:
- While maxmin is said to be more sensitive to the sample size, I did not find a big difference to the other methods, even when using a sample size of 5 (when splitting the data).
- The interquartile range is said to be less sensitive to extreme values → since I didn’t have extreme values in the simulated data I didn’t find a strong difference to the other methods
But who actually cares about comparing model performances of different response variables? One good example (where the package was made for) is the development of ecological indicators. One major criterion is the robustness or predictability given certain environmental changes. This could be quantified from a statistical model, in which the indicator is modelled as a function of specific environmental variable or pressure, by using the RMSE on the test data. To compare the robustness of different indicators, that are often on different scales and differently treated prior to the modeling, normalizing the NRMSE would be needed.
If the NRMSE is further categorized into let’s say low, medium or high performance, using the standard deviation to normalize could be a good option for the following reason: The sd-based NRMSE represent the ratio between the variation not explained by the regression vs the overall variation in Y. If the regression explains all of the variation in Y, nothing gets unexplained and the RMSE, and consequently NRMSE is zero. If the regression explains some part and leaves some other unexplained, which is at a similar scale than the overall variation, the ratio will be around 1. Anything beyond will indicate a much greater variation or noise than in the variable itself and consequently a low predictability.
Stay tuned for the next update of INDperform, where I will revise the NRMSE calculation (most likely using the sd method) and the cut-offs for scoring!
To cite this work: Otto, S.A. (2019, Jan.,7). How to normalize the RMSE [Blog post]. Retrieved from https://www.marinedatascience.co/blog/2019/01/07/normalizing-the-rmse/
Otto, S.A., Kadin, M., Casini, M., Torres, M.A. & Blenckner, T. (2018). A quantitative framework for selecting and validating food web indicators. Ecological Indicators, 84, 619-631, doi: 10.1016/j.ecolind.2017.05.045↩
James, G., Witten, D., Hastie, T. & Tibshirani, R. (2013). An Introduction to Statistical Learning - with Applications in R. Springer, New York.↩
Hastie, T.J. & Tibshirani, R.J. (1990). Generalized Additive Models. Chapman & Hall / CRC, Boca Raton, 352 p.↩


Class HttpClientAuthenticationConnection
Implements the IAuthenticationConnection using System.Net.Http.HttpClient which can be either supplied or automatically managed.
Inheritance
Inherited Members
Namespace: Auth0.AuthenticationApi
Assembly: Auth0.AuthenticationApi.dll
Syntax
public class HttpClientAuthenticationConnection : IAuthenticationConnection, IDisposable
Constructors
HttpClientAuthenticationConnection(HttpClient)
Initializes a new instance of the HttpClientAuthenticationConnection class.
Declaration
public HttpClientAuthenticationConnection(HttpClient httpClient = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Net.Http.HttpClient | httpClient | Optional System.Net.Http.HttpClient to use when sending requests. |
Remarks
If you supply a System.Net.Http.HttpClient it is your responsibility to manage its lifecycle and dispose it when appropriate. If you do not supply a System.Net.Http.HttpClient one will be created automatically and disposed of when this object is disposed.
HttpClientAuthenticationConnection(HttpMessageHandler)
Initializes a new instance of the HttpClientAuthenticationConnection class with a specific System.Net.Http.HttpMessageHandler.
Declaration
public HttpClientAuthenticationConnection(HttpMessageHandler handler)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Net.Http.HttpMessageHandler | handler | System.Net.Http.HttpMessageHandler to use within the managed System.Net.Http.HttpClient. |
Methods
Dispose()
Disposes of any owned disposable resources such as the underlying System.Net.Http.HttpClient if owned.
Declaration
public void Dispose()
Dispose(Boolean)
Disposes of any owned disposable resources such as the underlying System.Net.Http.HttpClient if owned.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | disposing | Whether we are actually disposing (true) or not (false). |
GetAsync<T>(Uri, IDictionary<String, String>, CancellationToken)
Send a HTTP GET request to the given uri
with optional headers
as
an asynchronous operation.
Declaration
public async Task<T> GetAsync<T>(Uri uri, IDictionary<string, string> headers = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Uri | uri | Absolute System.Uri to send the request to. |
| System.Collections.Generic.IDictionary<System.String, System.String> | headers | Optional dictionary containing additional headers to be sent. |
| System.Threading.CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<T> | The task object representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| T | Type of object to deserialize the result into. |
SendAsync<T>(HttpMethod, Uri, Object, IDictionary<String, String>, CancellationToken)
Send an HTTP request to uri
using the HTTP method
as an asynchronous operation.
Declaration
public async Task<T> SendAsync<T>(HttpMethod method, Uri uri, object body, IDictionary<string, string> headers = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
| Type | Name | Description |
|---|---|---|
| System.Net.Http.HttpMethod | method | System.Net.Http.HttpMethod to use. |
| System.Uri | uri | Absolute System.Uri to send the request to. |
| System.Object | body | Body of the HTTP request that will be sent. |
| System.Collections.Generic.IDictionary<System.String, System.String> | headers | Optional dictionary containing additional headers to be sent. |
| System.Threading.CancellationToken | cancellationToken | The cancellation token to cancel operation. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<T> | The task object representing the asynchronous operation. |
Type Parameters
| Name | Description |
|---|---|
| T | Type of object to deserialize the result into. |


TRAGEDY IMPACT
Andy Murray opens up on Dunblane school massacre and reveals tennis was his ‘escape’ from trauma
by Justin BowieANDY Murray has opened up about the Dunblane school massacre in a new Amazon Prime documentary.
The Scots tennis ace, 32, spoke about the horrific shooting in 1996 – and revealed he knew killer Thomas Hamilton as a child.
And he told how tennis was often an "escape" which helped him deal with his trauma.
The two-time Wimbledon champion left an emotional voice note for director Olivia Cappuccini as he lifted the lid on how he’s been impacted by the tragedy.
He said: “You asked me a while ago why tennis was important to me.
“Obviously I had the thing that happened at Dunblane. When I was around nine.”
Murray told how the shooting came a year before the divorce of his parents, and his brother Jamie moving away from home.
He said: “I am sure for all the kids there it would be difficult for different reasons.
“The fact we knew the guy, we went to his kids club, he had been in our car, we had driven and dropped him off at train stations and things.
“Within 12 months of that happening, our parents got divorced.
“It was a difficult time that for kids. To see that and not quite understand what is going on.
“And then six to 12 months after that, my brother also moved away from home. He went away to train to play tennis in Cambridge.
“We obviously used to do everything together. When he moved away that was also quite hard for me.
“Around that time and after that, for a year or so, I had lots of anxiety but that came out when I was playing tennis. When I was competing I would get really bad breathing problems.
“My feeling towards tennis is that it’s an escape for me in some ways. Because all of these things are stuff that I have bottled up.
“I don’t know because we don’t talk about these things. They are not things that are discussed.”
The new documentary, entitled Andy Murray: Resurfacing, will focus on the tennis superstar’s gruelling recovery from a career-threatening injury.
It will be released this Friday - and is being premiered at London's Curzon Bloomsbury's tonight.
The two-time Olympic gold medallist underwent hip surgery at the end of January.
Murray and wife Kim gave birth to a baby boy called Teddy last month.


BAPS SHAYONA - Saatvik Vegeterian Food
HOME
MENU
PHOTOS
ORDER NOW
CATERING SERVICES
Name
Mobile Number
Cater For
Order
Date
Time


Ask Question
Report a Problem
FAQ
Activity Log
Settings
Account
Change Picture
Change Password
Change Security Question
Logout
People
Home
NOB
Change Profile Picture


Semantics
The new semantic tags allows us to build simpler layouts and clearer html code.
You can use the tags header, footer, section, article, nav and aside in your layouts to define different page areas:
Layout:
This is the header
An article
Another article
Code:
This is the header Main navigation area Side menu

An article

Another article

 Section footer
You can have several headers and footers in a page, but only one 'nav' and one 'aside'. Each section or article can have its own header and its own footer:
Layout:
Section header
Article header
An article
Article header
Another article
Code:

 Section header
 Article header An article Article footer

 Article header Another article Article footer
 Section footer


{{explanation.code.trim()}}
is {{a(explanation.name)}} {{explanation.name}}.
[Docs]
🔬 This feature explains new and less-known syntax (e.g. ref struct
or @var
).
Your code either does not have any rare syntax, or the syntax is too new and not explained yet.
If you would like something explained, please report at language-syntax-explanations/issues.


When the modem driver receives notification that data has arrived on the port, it sends a pre-registered message to a specified object. (You specify both the object and the message when you call
ModemConnect()
.)
In the MTalk example, the driver sends MSG_MTALK_PROCESS_READ_DATA to the process object when data has arrived on the port. The handler for this message is shown in Receiving Data Over A Serial Connection .
To receive data, MTalk does the following:
ModemReceive()
(defined in modem.goc) to read incoming dataCode Display 9-3 Receiving Data Over A Serial Connection
@method MTalkProcessClass, MSG_MTALK_PROCESS_READ_DATA { /* * recvDataSize - Amout of data actually read in. * recvDataPtr - Pointer to data to read in. * retVal - Return value of ModemReceive(). */ word revDataSize; char * recvDataPtr; StreamError retVal;
/* * Check to see if connection is still open. Because of message queueing * delays, we may have received this data notification after the connection * has been closed. * * ConnectionOpen - global flag that keeps track of whether * the connection is open or closed. */ if ( ConnectionOpen == FALSE ) { return; }
/* * Lock the input buffer down on the heap, and obtain a pointer to it. * (Note: This buffer is a memory block that was allocated in the * "Connecting" example.) */ recvDataPtr = MemLock( recvBuffer );
/* * A NULL pointer means that the memory manager has gone ahead * and discarded the buffer block since the last time it was * unlocked. So we need to reallocate it here. Note that the * MemHandle is still in use; it just isn't bound to any block of memory. */ if ( recvDataPtr == NULL ) { /* * Reallocate the block, locking it immediately, * so it doesn't get discarded again. If the block cannot * be re-allocated, memory must be low so close the connection. */ if (( MemReAlloc( recvBuffer, RECV_BUFFER_SIZE, HAF_LOCK ) == NullHandle) { @send self::MSG_MTALK_PROCESS_CLOSE(); return; }
/* * After re-allocating the locked block, dereference its handle * to obtain a pointer to it. */ recvDataPtr = MemDeref( recvBuffer ); }
/* * Read available data up to the size of our buffer then display it. */ if ( ModemReceive( RECV_BUFFER_SIZE, (byte*)recvDataPtr, &recvDataSize ) == STREAM_NO_ERROR ) { @call MTalkOutText::MSG_VIS_TEXT_APPEND_PTR( recvDataPtr, recvDataSize ); }
/* * If the read data filled the entire buffer, there's a good * chance more data is available so send the message through the * process object's queue again. (We do not want to keep reading * in a loop in case the other side dumped a very large stream * of data; this would keep the process object from handling * other messages in its queue.) */
if ( RECV_BUFFER_SIZE == recvDataSize ) { @send ,forceQueue self::MSG_MTALK_PROCESS_READ_DATA(); }
/* * Once all the data has been read, unlock the buffer block. */ MemUnlock( recvBuffer );
} /* end of MSG_MTALK_PROCESS_READ_DATA */
Like
ModemSend()
,
ModemReceive()
calls a VirtualSerial routine,
VirtualSerialRead()
, to read incoming data. Because no blocking is specified,
VirtualSerialRead()
reads only data that is currently available in the stream. (If you want the routine to block until there is enough data in the stream to fill the entire buffer, pass STREAM_BLOCK in
VirtualSerialRead()
.)
ModemReceive()
takes three arguments:
ModemReceive()
writes the number of bytes actually read in to this parameter.
ModemReceive()
returns a
StreamError
value:


| Interface | Description |
|---|---|
| AgentRegistrar |
Implementations of this decide which entities are controlled by agents and what each agent can see on startup.
|
| CommandCollector |
The CommandCollector gathers commands from agents.
|
| CommandFilter |
An interface for allowing the kernel to filter out agent commands.
|
| CommunicationModel |
A model of communication.
|
| EntityIDGenerator |
Interface for objects that can generate new EntityIDs.
|
| KernelComponent |
This class is the kernel interface to components (agents, viewers, simulators).
|
| KernelListener |
Interface for objects that are interested in kernel events.
|
| Perception |
Implementations of this interface are responsible for determining what entities/properties each agent can see.
|
| TerminationCondition |
Termination conditions tell the kernel when to stop running a simulation.
|
| WorldModelCreator |
The interface for world model creators, e.g.
|
| Class | Description |
|---|---|
| AbstractCommandFilter |
An abstract base class for command filters.
|
| AbstractCommunicationModel |
Abstract base class for communication models.
|
| AbstractKernelComponent |
Abstract base class for KernelComponent implementations.
|
| AgentProxy |
This class is the kernel interface to an agent.
|
| ChainedCommandFilter |
A CommandFilter that chains together a set of filters.
|
| ComponentManager |
Class that manages connecting components (agents, simulators, viewers) to the kernel.
|
| CompositeCommandCollector |
A CommandCollector that waits for any of a set of child CommandCollectors to return a result.
|
| FrozenAgentsCommandFilter |
A CommandFilter that ignores agent commands for some number of timesteps.
|
| InlineComponentLauncher |
A class that knows how to connect components to the kernel using inline streams.
|
| Kernel |
The Robocup Rescue kernel.
|
| KernelConstants |
Some useful constants for the kernel.
|
| KernelListenerAdapter |
Abstract class for objects that want to implement a subset of the KernelListener interface.
|
| KernelStartupOptions |
Container class for all kernel startup options.
|
| KernelState |
A class for obtaining information about the state of the kernel.
|
| OrTerminationCondition |
A TerminationCondition that returns true if any of its children return true.
|
| RemoteGISWorldModelCreator |
A WorldModelCreator that talks to a remote GIS.
|
| SimulatorProxy |
This class is the kernel interface to a simulator.
|
| StartKernel |
A class for launching the kernel.
|
| TimedCommandCollector |
A CommandCollector that waits for a certain amount of time before returning agent commands.
|
| TimestepTerminationCondition |
A TerminationCondition that terminates the simulation after a specified timestep.
|
| ViewerProxy |
This class is the kernel interface to a viewer.
|
| WrongTimeCommandFilter |
A CommandFilter that ignores agent commands that have the wrong timestamp.
|
| Exception | Description |
|---|---|
| KernelException |
Root of the kernel exception heirarchy.
|


A purported ancient lake on Mars may have been far smaller than researchers thought. NASA’s Curiosity rover has been exploring Gale crater for more than eight years, and while early observations suggested the entire crater may once have been filled with water, a new analysis implies that it just had a series of ponds instead.
Previous analyses of data from Curiosity have relied heavily on a measure called the chemical index of alteration to determine how rocks were weathered over time. Joseph Michalski at the University of Hong Kong and his colleagues have suggested that because this measure was developed for use on Earth, it may not be valid in the extreme Martian climate.
Instead, they analysed the concentrations of various compounds that are expected to change based on different types of weathering over time. They found that some of the layers of rock Curiosity examined did interact with water at some point in their past, but more are likely to have formed outside of the water.


10. Inline assembler¶
Here you will learn how to write inline assembler in MicroPython.
Note: this is an advanced tutorial, intended for those who already know a bit about microcontrollers and assembly language.
MicroPython includes an inline assembler. It allows you to write assembly routines as a Python function, and you can call them as you would a normal Python function.
10.1. Returning a value¶
Inline assembler functions are denoted by a special function decorator. Let’s start with the simplest example:
@micropython.asm_thumb
def fun():
movw(r0, 42)
You can enter this in a script or at the REPL. This function takes no
arguments and returns the number 42. r0
is a register, and the value
in this register when the function returns is the value that is returned.
MicroPython always interprets the r0
as an integer, and converts it to an
integer object for the caller.
 Accessing peripherals¶
For something a bit more complicated, let’s turn on an LED:
@micropython.asm_thumb
def led_on():
movwt(r0, stm.GPIOA)
movw(r1, 1 << 13)
strh(r1, [r0, stm.GPIO_BSRRL])
This code uses a few new concepts:
stm
is a module which provides a set of constants for easy access to the registers of the pyboard’s microcontroller. Try runningimport stm
and thenhelp(stm)
at the REPL. It will give you a list of all the available constants.
stm.GPIOA
is the address in memory of the GPIOA peripheral. On the pyboard, the red LED is on port A, pin PA13.
movwt
moves a 32-bit number into a register. It is a convenience function that turns into 2 thumb instructions:movw
followed bymovt
. Themovt
also shifts the immediate value right by 16 bits.
strh
stores a half-word (16 bits). The instruction above stores the lower 16-bits ofr1
into the memory locationr0 + stm.GPIO_BSRRL
. This has the effect of setting high all those pins on port A for which the corresponding bit inr0
is set. In our example above, the 13th bit inr0
is set, so PA13 is pulled high. This turns on the red LED.
10.3. Accepting arguments¶
Inline assembler functions can accept up to 4 arguments. If they are
used, they must be named r0
, r1
, r2
and r3
to reflect the registers
and the calling conventions.
Here is a function that adds its arguments:
@micropython.asm_thumb
def asm_add(r0, r1):
add(r0, r0, r1)
This performs the computation r0 = r0 + r1
. Since the result is put
in r0
, that is what is returned. Try asm_add(1, 2)
, it should return
3.
10.4. Loops¶
We can assign labels with label(my_label)
, and branch to them using
b(my_label)
, or a conditional branch like bgt(my_label)
.
The following example flashes the green LED. It flashes it r0
times.
@micropython.asm_thumb
def flash_led(r0):
# get the GPIOA address in r1
movwt(r1, stm.GPIOA)
# get the bit mask for PA14 (the pin LED #2 is on)
movw(r2, 1 << 14)
b(loop_entry)
label(loop1)
# turn LED on
strh(r2, [r1, stm.GPIO_BSRRL])
# delay for a bit
movwt(r4, 5599900)
label(delay_on)
sub(r4, r4, 1)
cmp(r4, 0)
bgt(delay_on)
# turn LED off
strh(r2, [r1, stm.GPIO_BSRRH])
# delay for a bit
movwt(r4, 5599900)
label(delay_off)
sub(r4, r4, 1)
cmp(r4, 0)
bgt(delay_off)
# loop r0 times
sub(r0, r0, 1)
label(loop_entry)
cmp(r0, 0)
bgt(loop1)
10.5. Further reading¶
For further information about supported instructions of the inline assembler, see the reference documentation.