Get only the top 10 results of Google Prediction instead of all results - google-prediction

I have implemented a model that maps the incoming data into one of 1000 categories (label) available. For each entry, the Google Prediction returns all categories in 1000. Is there any way to make the Google Prediction return, for example, only the 10 most important outcomes?
Thanks

You simply can't get the top 10 on 1000.
If you really need to limited the number of result on the server side you can have your own server in the middle who "cleanup" the result for you.
Depending the size of your project, I recommend you Google App Engine. It will use Google Network who is very quick and have low latency.
From Google Prediction API webservice you can only limited to the most relevant category.
Using Google API explorer generate this kind of POST request:
POST
https://www.googleapis.com/prediction/v1.6/projects/{YOUR_PROJECT_NUMBER}/hostedmodels/job_training/predict?fields=id%2Ckind%2CoutputLabel%2CoutputValue%2CselfLink&key={YOUR_API_KEY}
Content-Type: application/json Authorization: Bearer
ya29.AHES6ZQykLLg0ctjS1YYnxMEUn2kCi7OL4UZj4_-e92cuPfywxJatw
X-JavaScript-User-Agent: Google APIs Explorer
{"input":
{"csvInstance": [ "YOUR PREDICTION" ]}
}
The URL request parameter "field" don't include "outputMulti" (all the other result)

Related

Speed limit for multiple locations using HERE API

I need to know the speed limit for some coordinates from the vehicle's trip.
If I do POST request like:
https://fleet.cit.api.here.com/2/calculateroute.json?routeMatch=1&mode=car&attributes=SPEED_LIMITS_FCn(*)&&app_id=APP_ID&app_code=APP_CODE
with body:
LATITUDE,LONGITUDE
37.401996,-122.041338
37.416438,-122.086022
I'm receiving back built route with very many coordinates.
But I'm interested in only two coordinates...
Is there a better way to get speed-limit for a few (~10-100) coordinates?
This will get an array of link and if speed limit is available in map data, it would be returned for the link. linkAttributes and routeAttributes will limit the response of parameters. the default response however can't be limited.
https://route.ls.hereapi.com/routing/7.2/calculateroute.json?apiKey=xxx&waypoint0=42.4065,-113.3798&waypoint1=42.2821,-83.74847&mode=fastest;car&inkAttributes=speedLimit,dynamicSpeedInfo&legAttributes=links
speedinfo can come via geocoder API in the form of speed category like below that will be based on the address location.
https://geocoder.ls.hereapi.com/6.2/geocode.json?searchtext=Castro%20St%20Mountain%20View%20Santa%20Clara%20US&gen=9&apiKey=xxxxx&locationattributes=li

JSON RouteLinks response to identify traffic light

I am sending an RME request to obtain speed limit and traffic light information and get back a JSON response. As Here-API provides a lot of different traffic sign types I dont care for (e.g. overtaking etc.) I cannot figure out how those types I am interested in are numerically encoded.
Browsing through the online docs provided by Here I could did not find the information I'm looking for, i.e. enumeration codes assigned to traffic lights
The request I send out looks something like
https://rme.api.here.com/2/matchroute.json?
app_id=<my-app_id>
&app_code=<my-app-code>
&routemode=car
&file=<zip and base64 encoded route info>
&attributes=BASIC_HEIGHT_FCn(*),ROAD_GEOM_FCn(*),ADAS_ATTRIB_FCn(*)
&attributes=ADAS_ATTRIB_FCn(*),SPEED_LIMITS_FCn(*),TRAFFIC_SIGN_FCn(*)
Please see below documents page and go to layers section and check the currently supported layers with the resource Layers.
https://developer.here.com/documentation/fleet-telematics/dev_guide/topics/here-map-content.html
For examples, this link will show about the layer of TRAFFIC_SIGN_FC1 in detail.
https://fleet.api.here.com/1/doc/layer.html?region=WEU&layer=TRAFFIC_SIGN_FC1&app_id={{app_id}}&app_code={{app_code}}

GA Reporting API session and product correlation

I ran into this issue a few months ago and nobody responded. It has come up again and I'm wondering if anyone knows why it doesn't work. Here's the original question:
Correlating certain metrics with Sessions and Products in Google Analytics API v4
The issue is correlating products to session/page information. If you setup an api query with a session variable (e.g. ga:sessions) or a page variable (e.g. ga:pageviews) and try to correlate it to a product dimension (e.g. ga:productSku), it will always give an empty data set.
I'm wondering A) why this data can't be correlated, B) why both google's dimension/metric explorer as well as their query explorer allow these combinations, but never return data, and C) is there a way around it?
I've tried this on about 10 clients that all have lots of product data and the result is always the same.
Edit: Adding example report json for ease of replication:
{
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '7daysAgo', 'endDate': 'today'}],
'metrics': [{'expression': 'ga:sessions'}],
'dimensions': [{'name':'ga:productSku'}],
'pageSize': 10000
}]
}
After exhausting every possibility and attempting to contact google support about this, there is apparently no work-around. It appears that any session level information (e.g. sessions) cannot be correlated directly to any product information. Unfortunately, you are limited to the other product level variables or page level (e.g. page views).
In the case of this project, we had to re-define some of our metric standards for GA for things that google didn't support (even though adobe does).

Why is this Google Analytics query unsampled via the web UI but sampled via the GA API?

I recently attempted to query the Google Analytics API for a report using device category, source, and medium as dimensions. The report covered about four weeks of time. Despite the fact that I was able to build the equivalent ad-hoc report in the UI and get results based on 100% of sessions, I couldn't get the API to give me results based on any more than 1.3% or so of sessions. The client I'm using is based on the v3 API, but I got the same results when using Google's v4 testing tool, so it's not a function of the API version.
According to Google's documentation, ad-hoc reports are supposed to use pre-aggregated unsampled data where possible:
Ad-hoc reports are based on any non-standard query of Analytics data. For example, if you apply a segment or secondary dimension to a standard report, then Analytics has to issue a new, non-standard query of the data to return that information.
The new query goes first to the tables of aggregated data to see if all of the requested information is available there. If the information is not available there, then Analytics queries the complete, unfiltered set of data and computes new aggregates to satisfy the application of the segment or secondary dimension.
This is apparently true of the web UI, but not necessarily of the API. I was under the impression that the web UI was making calls equivalent to those exposed in the API under the hood, but it seems that this isn't the case. Does anybody know whether it's possible to force the API query to use the pre-aggregated data sets that I know are available?
The difference in sampling threshold between the web UI and the API does indeed explain this. This happens to be a 360 account, for which the sampling threshold is much higher than the API permits (the documentation is cagey about exact numbers but apparently it can be "up to 100M sessions"). The same test on a standard account showed equivalent behavior between the API and the web UI. Google's issue tracker for the GA API indicates that they do not plan to increase the sampling threshold beyond 1M sessions even for 360 accounts.

is there an API out there to access google page rank for a predefined set of keywords?

I am building an internal reporting tool that I want to update with Googles pagerank once per week.
The list of keywords would be predefined at this point.
any ideas?
They do have an Adwords API that may get you closer to what you are looking to do.
API - http://code.google.com/apis/adwords/docs/
Specifically the TrafficEstimatorService allows you to specify keyword parameters and estimate what traffic you could receive.

Resources