This tutorial explains how to use text tags (pieces of text in a certain format) to dynamically specify where the fields should appear in your documents and how to send out these documents for signing using our eSignature API (Application Programming Interface).
Text tags are just pieces of text in a certain format that you dynamically include in your documents when you generate them to specify the positions for signature fields, text fields, date fields etc.
When you send out a document with text tags for signing, DigiSigner parses the document's content, finds all the text tags and replaces them through fields.
What are the benefits of using text tags compared to templates or to dynamic specifying of field coordinates directly in your signature request?
Templates are great when the positions of your fields are fixed and don't change from one signature request to another. But if they do change you need to be able to indicate the field positions dynamically. You can do this by specifying the exact field coordinates in your signature request, but sometimes it is not practical or even not possible.
Imagine that you need to put a signature field right under a dynamically generated paragraph of text. Depending on the paragraph size the field position could vary.
This is where text tags could help you. Just put your text tag in the form of [s:role] under your paragraph while you are generating your document and our service will automatically recognize it and convert it to a signature field.
A text tag is a piece of text starting and ending with a square bracket, between the brackets there are two parameters separated with a colon.
The first parameter in a text tag is the letter that indicates the type of the field. This letter can have five different values for the corresponding field types: s, t, d, c, i.
The second parameter is the signer's role, which allows you to specify which signer will fill in this particular field. The role can be any string of your choice (but should not contain a colon).
Imagine that your document needs to be filled out by two signers, one is an employee and the other is a manager. In this case you can use the role employee for all the fields that should be filled in by an employee, and the role manager for all the fields that should be filled in by a manager.
For example [s:employee] will be a signature field for an employee, and [t:manager] will be a text field for a manager.
You will use these roles later in your signature request to specify which signer will have which role while signing the document (and therefore what fields they will have to fill in).
Signer roles are case sensitive ('Employee' and 'employee' are two different roles).
Here is a sample document, that shows the usage of text tags.
We have two signer roles here: employee and manager. For each signer we added three fields: a signature field, a text field and a date field.
This is how the same document will be displayed when opened by an employee via our service.
As you probably already noticed you can add spaces inside your text tags to adjust field sizes, use fonts of different sizes or even place your text tags over multiple lines.
After you have generated your document with text tags you will need to send it out for signing. You can use the following sample code to do it.
Please note the following two parameters: use_text_tags and hide_text_tags.
The first parameter use_text_tags indicates that DigiSigner should parse your document and convert all text tags into the corresponding fields. If you don't set it to true, your text tags will be ignored.
The second parameter hide_text_tags indicates that your text tags should be hidden behind white rectangles. If you don't set this parameter to true, your tags will still be visible behind the added fields.
An alternative to using this parameter is to add text tags to your document in the color of the document's background. Then you can ignore the hide_text_tags parameter and your requests will be processed a little bit faster.
Please also note how the roles we specified in the request match with the roles we used in the corresponding text tags (employee and manager).


Under the Tourist Traffic Acts 1939 - 2016 any tourism business calling themselves a holiday camp must be registered with Fáilte Ireland.
In order to register as a holiday camp, your business should provide sporting and recreational facilities, and the accommodation must consist of either a block of separate serviced bedrooms, self catering houses or self catering apartments.
The following competent authorities websites also provide general information relevant to operating holiday camps in Ireland.


Unlike ODI's, the format and basic rules of Twenty20 matches have stayed the same since the very first official match back in 2003. The first 6 overs in each innings are Powerplay overs and the bowlers are limited to 4 overs each. This, coupled with the condensed nature of the format, means that certain situations are repeated many times. Naturally, this allows us to compute probabilities of events by looking back at how many times this situation arose and the resulting outcome. For example, how often do teams defend 10 runs off the last over? Or what do teams need to score in the Powerplay to stand a chance of chasing 200?
In this article, I develop some simple prediction models using a few machine learning algorithms. I use only a few factors to begin with – specifically the current score, number or runs required and wickets to predict the final score in the 1st innings and the winner in the 2nd innings. The dataset consists of 877,319 balls from 3,700 T20 matches where there was an outright winner and no reduction in overs in either innings.
Predicting the eventual score in the 1st innings is a regression problem, as the outcome is a continuous variable. I consider the 455,301 1st innings balls in the dataset to be independent of one another.
The table above shows a random sample of the data. The first three columns are the predictor variables and the last column is the target variable i.e. what we're trying to predict.
The first model we can look at is Linear Regression. Here we are trying to draw a line through our multi-dimensional data such that the total distance between all the points and the line is as small as possible. In two dimensions this is simply the line of best fit that we are all familiar with.
Using scikit-learn's machine learning package in Python, we can build our model very easily as below.
The R2 value is 0.547, which means about 55% of the variability in the data is explained by this model. The model tells us that the average score from the very beginning of the innings is about 156 (1.16*120 + 17.1). As the innings progresses, we can feed in more information regarding the current score and wickets to get a more refined prediction. The model also tells us that a wicket will save about 4 runs for the bowling team. Being a linear model it doesn't tell us at what stage of the innings losing wickets is most costly. It's also not particularly self-consistent – it can give predictions that are lower than the current score in extreme cases.
KNeighborsRegressor is an algorithm that I used when developing the Expected Runs and Wickets models. For any given ball, the algorithm searches for a specified number of the most similar balls and from those returns the average final score. The Python implementation is as below.
I found that 26 neighbours was the optimal number that would give the lowest error. Fewer than 26 and you'll suffer from small sample sizes whilst any greater and the neighbours start to become a bit too dissimilar. This method had an R2 value of 0.580, which is slightly better than what we had for linear regression. The disadvantage however is that we don't get a interpretable equation or rule – we merely input the details of the ball and it outputs a prediction.
A similar algorithm is RadiusNeighborsRegressor. Instead of searching for a fixed number of nearest neighbours, this algorithm finds all neighbours which are within a certain distance.
To give some perspective, the most popular unique score after the 6th over is 49 for 2 from 7.1 overs, which has occurred 62 times in total. If we take the average final score from those 62 innings we can be reasonably confident that this is a good prediction. If we loosen our requirements to allow any of current score, wickets and overs to be off by a maximum value of 1 (the radius I chose), e.g. 50 for 1 after 7.2 overs, we get 402 similar instances. In fact, of the 55,781 unique combinations of current score, wickets and balls remaining, 44,536 have at least 10 close neighbours.
This method is ever so slightly better with an R2 value of 0.607. We do however fail to predict with much accuracy the somewhat extreme cases. A score like 187 for 2 with 22 balls to go has only 4 close neighbours. RadiusNeighborsRegressor will take the average final score of those 4, while KNeighboursRegressor will find 26 quite dissimilar neighbours. Both methods will likely have high margins of error in this case.
The graph above shows how confident our predictions become as we progress through the innings using the RadiusNeighborsRegressor method. Early on, we have very little information to base our predictions on – the best we can do is give the historical average final score. We become 80% confident at around the 13th over and 95% confident with about 2 overs to go. It's true that a lot can happen in the last couple of overs, but over a large number of games any differences tend to average out.
The final algorithm we'll take a look at is RandomForestRegressor. This is an example of a ensemble method which takes a number of slightly different prediction models and combines them in such a way that the overall performance is better than any one model on its own.
The algorithm combines 1,000 models or estimators, specifically decision trees, and considers all three features when looking for the best split. It had an R2 value of 0.607 – very similar to the RadiusNeighborsRegressor algorithm. However, this algorithm has the advantage that it can tell us about feature importance – which of the attributes is most significant in predicting the final score.
The table above shows that the current score is the best predictor of the final score. It is about as informative as both the wickets and ball remaining values combined. This of course makes sense – good luck predicting the final score from just the number of wickets and balls remaining. It also perhaps confirms the long suspected notion that wickets in hand are overvalued. You'll often hear that a team that scores 180-3 from 20 overs has left a fair few runs on the table.
We can take a look at how the predictions from the random forests model perform on a real game – an IPL match earlier this season between Gujarat Lions and Kolkata Knight Riders.
The graph above shows the model's predictions for the Lions' first innings. A rolling mean of 6 balls has been applied to smooth out the plot. The model's predictions never varies from the final score by more than 8 runs. In contrast, the run rate projected score is a lot more erratic and only briefly predicts anything close to the final score. The model barely dropped below 180 even after the Lions' slowdown in between the 10th and 16th overs. It had faith in their ability to accelerate in the latter stage of the innings, something which the run rate projections does not take into account.
To sum up, we've seen how we can take some simple facts about the current state of the game and look back in the vast array of ball-by-ball data to generate fairly accurate predictions of the final score of the 1st innings. In the next article I will be using a similar suite of machine learning algorithms to predict the winner of the match during the 2nd innings.
In an excellent article in The Independent recently, it stated how in last year's World T20 final against the West Indies, England decided to open the bowling with Joe Root because Chris Gayle had 'a poor record against off-spin'. Although the idea worked it made me think that surely these plans are more rigorously justified beyond seeing which type of bowlers dismiss him most often. Root is a right-arm off-spin bowler just like say India's Ravichandran Ashwin, but over a long period of time would probably come off worse against Gayle. I'm sure England and other teams develop more detailed bowling plans that include what kinds of lines and lengths to bowl to particular batsmen, when to vary their pace and where exactly to position fielders among other things. All of this can be derived from data: what kind of deliveries do batsmen generally get out to, what areas of the ground do they target etc.
In this post, I want to use the metrics I've been developing and some visualisations to build up a statistical profile of a particular batsman in T20's, in this case Chris Gayle himself. It goes without saying that Gayle has a phenomenal record in this format; closing in on 10,000 runs from over 270 innings, with an average of over 40 and a strike rate of 150. The plot below shows how Gayle's average has fluctuated over the course of his T20 career. Early on in his career, his average somewhat dipped to about 30 before there was a resurgence in his batting from his 50th match until his 100th. He's since been averaging in the mid 40's.
The histogram below shows how his career scores are distributed, split up into 5 run bins.
It's obvious that we're not going to see a devastating Gayle innings in every match, having made 78 50+ scores in 273 innings. In fact it's more likely that we'll see a failure from Gayle having been dismissed for single figures 84 times in his career. This is not entirely surprising for an opener in T20's but it does show it's not impossible to dismiss him cheaply.
We can break this down further and see how he performs at different stages of the innings. The plot below shows the total number of runs he's scored in each over of a T20 innings. It's evident that the bulk of his runs come in the Powerplay overs before dropping off through the rest of the overs. This is due to the fact that it becomes more and more unlikely that he is actually still out in the middle in the later overs. To account for this we can plot his average per over.
Apart from the 11th over and the last 2 overs, Gayle's lowest average comes in the 3rd over. In fact, this is the over where he is most frequently dismissed – a total of 28 times. It's peculiar to see that he averages nearly 100 in the 10th over which then suddenly drops to about 30 in the next over. I'm not really sure why.
His strike rate generally increases through the course of the innings after the initial blitz in the Powerplay. The 1st over is the only time when his strike rate is below 100 suggesting he tends to be quite circumspect at the start of his innings.
The graph above shows the average number of balls it takes Gayle to reach a particular score. It illustrates his incredible ability to accelerate during an innings. It takes him on average 10 balls to score his first 10 runs. After that his 50 comes up in about 32 balls and if he gets to a century, it usually take just over 50 balls. Of course, sample sizes get quite small at that point so the graph becomes a little more erratic.
Now, we can look at what type of bowlers Gayle performs best against or otherwise. This article describes quite well exactly this. From a sample of 3 IPL seasons it shows that Gayle thrives against left-arm slow bowling striking at nearly 3 runs a ball. However, his run-scoring is somewhat restricted by right-arm fast and off-spin bowling, going for just over a run a ball.
We can go further and see if there is any variation in Gayle's expected runs and wickets against both spinners and seamers. I use a dataset made up of the last 5 IPL seasons consisting of 70,217 balls that produce 89,329 runs and 3,612 wickets. Gayle's IPL average and strike rate is not significantly off his career figures, so just using this data is sufficient for our analysis. As before, I train the data using a machine learning algorithm to return a xR and xW figure for every ball. The table below summarises the results.
So Gayle over-performs against both seam and spin bowlers compared to the average batsman. Although he performs better against spinner than seamers, he is dismissed more often than expected. This suggests that he takes a more hit and miss approach against spinners but balances risk and reward well against the seamers.
The beehive plot above shows Gayle's dismissals in the IPL since 2012, split by seam and spin bowlers. Spinners tend to dismiss him by bowling fairly straight while seamers tend to go wide of off stump or very short. Of course this doesn't tell you the full story. We can also take a look at where to bowl to keep Gayle quiet.
The heat maps above show the distributions of 460 and 186 dot balls to Gayle from seamers and spinners respectively. Seam bowlers give themselves the best chance by bowling back-of-a-length outside off, although the distribution is quite broad in terms of both line and length. For spinners, keeping it very tight to the top of off stump is the way to go ensuring you're not too full or too short. Of course, these plans are fraught with risk as the next images show.
The heat map above shows the distribution of 227 balls that have been hit to the boundary by Gayle. It's clear that if you bowl fuller and outside off, you're very likely to be hit to the boundary. If you're wondering what happens if you bowl straight to Gayle as a seamer, then this is where he is mostly restricted to 1's, 2's and 3's.
For spinners the margin of error between dot balls and boundaries is even smaller, comparing this to the spinner's dot ball heat map above. The figure above illustrates the 92 boundaries Gayle has hit off spin bowling. If you bowl fractionally too full and outside off stump then you are in trouble. This confirms the hit and miss nature of bowling spinners to Gayle implied by his xR and xW figures. If you want to bowl spin to him then you have to be prepared to go for runs before his is dismissed.
We can now look at how specific bowlers who have been successful (or otherwise) have bowled to Gayle. The table below shows the 10 bowlers he has performed worst against in terms of runs/xR and who have bowled at least 18 legal deliveries to him.
We get a mixture of both seam bowlers and spinners. Gayle scores nearly 26 runs fewer than what we would expect the average batsman to score when facing Lasith Malinga. We have to be careful with the interpretation here however. The average bowler would expect to concede 44 runs if they bowled the exact same deliveries as Malinga has. But if Malinga (and other bowlers on the list) concede less than expected against most other batsman then there is something about these bowlers our model doesn't quite capture.
The number of dismissals per bowler isn't really large enough to form concrete conclusions from the dismissals/xR ratios, but it should be noted that he is dismissed by the spinners Sunil Narine and Harbhajan Singh more often than expected.
Let's look at the heat maps from some of these bowlers with their wickets shown in red.
Firstly, Malinga has two distinct areas that he bowls to Gayle mixed in with the occasional short ball. He favours a good length quite wide of off stump and also some yorker length deliveries aiming for the base of middle stump.
Steyn bowls more or less evenly between back of a length on off stump and a bouncer length towards Gayle's helmet which has gotten his wicket once.
Narine's heat map shows he bowls wide of off stump rather than most spinners who target top of off. His length is also incredibly consistent shown by the very narrow contours, relying on variation in spin.
Ashwin, on the other hand, varies his line and length a lot more to Gayle. He predominantly bowls quite full on off stump which, if you remember, is where Gayle hits a lot of boundaries against spinners. Perhaps this suggests Gayle is relatively more cautious when facing Ashwin.
Finally, we can take a look at a bowler who hasn't fared quite as well.
Bhuvneshwar Kumar has gone for 78 runs from 51 balls with a runs/xR figure of 1.22 against Gayle. He mostly bowls in that area where seamers typically keep Gayle quiet. However, when he misses his length he goes for a lot of boundaries shown by the blue balls. This again stresses how little margin for error you have when bowling to Gayle.
Another component to restricting and ultimately dismissing Gayle is field placement. The wagon wheel below shows 6,037 of his runs from 2,260 scoring shots.
It's obvious from watching him that a lot of his boundaries come in the deep midwicket to long-off region. He also doesn't run many 2's or 3's.
His dot balls mainly come from deliveries played back to the bowler. Having a fielder close in on the off-side is also a source of quite a few dot balls, as well as conventional point and cover fielders. I assume all those dot balls on the boundary are when he's turned down singles although I'm not entirely sure he's done it that many times.
Gayle is caught 64% of the time he is dismissed. The wagon wheel below shows 85 instances of him being caught in the outfield separated by seam and spin bowling.
He is caught behind and in the slips quite often to both seamers and spinners, suggesting it is worth having a slip in, especially early on in his innings, even in T20's. Given where he scores most of his runs, it's only a matter of time before he mishits one and gets caught at long-on or deep midwicket.
Overall, we've seen how we can use data to identify the strengths and weaknesses of a batsman and thus formulate bowling plans. However, it's important to note that we haven't found the silver bullet to dismissing Gayle cheaply every time we bowl to him. Just because he gets out to a particular type of delivery really often, doesn't mean teams should focus their entire pre-match training on hitting that one spot. We know that variation is important in T20's. Looking deeper, we might find it's a particular string of deliveries that set him up before dismissing him, or that he is dismissed this way after getting a big score. As ever, more investigation is required.
Any comments/questions? Tweet me here.
In this blog I wanted to take a brief break from refining our Expected Runs and Expected Wickets models and instead use these metrics, in their current form, to analyse the recent India v England T20I series. India came back from 1 nil down to win the series 2-1. The table below shows a summary of the series in terms of the total xR and xW for each team in each match. To give some context, batsman outperformed in this series overall, scoring 875 runs compared to a total xR of 828.8. In contrast, there were 35 wickets lost (excluding run outs) compared to a total xW of 34.81.
In the first match, England bowled reasonably well to restrict India to 147-7 in their innings. This was 6 runs below their total xR suggesting their relatively low score was due to poor batting more than good bowling. In reply, England outscored their total xR by nearly 26 runs. This, along with losing nearly 2 wickets fewer than expected suggests a pretty good batting performance overall. In the next match, both teams performed near enough as expected in terms of both runs and wickets.
In the final match, India significantly outperformed their xR to post a total of 202-6. While England did too, it was nowhere near enough to challenge India's score. Slightly outperforming an already low xR total won't win you many games. The most damning aspect however, is England losing more than double the expected number of wickets. In fact, their xW for that match was the lowest of the series highlighting just how inept that batting collapse was.
We can look at how individual batsmen performed throughout the series. The table below shows some statistics for the top 10 series run scorers.
Although Joe Root top scored in the series, he did under-perform according to his xR. However, he did have the lowest wickets/xW of any batsman suggesting he had to dig in at times. He was dismissed only twice even though India bowled well enough to him to dismiss an average batsman more than 5 times.
The beehive plot above shows how India bowled to Root in the series. I think there was a definite plan to bowl very straight and wide of leg stump, with fielders out on the leg side boundary. This seemed to work as he was mainly restricted to singles in this area and ended up with an overall strike rate of just over 100.
The heat map above shows the extent of India's bowling plan along with Root's 2 dismissals. The darker the green the greater the number of balls bowled in that region.
MS Dhoni had a similar story to Root – scoring below xR, but batting well enough to survive periods of good bowling from England.
This heat map shows an even more pronounced plan from England to bowl at the top of leg stump and occasionally full and outside off stump to Dhoni. The purple balls shows all of Dhoni's boundaries which accounted for 44 of his 97 runs in the series. His overall strike rate of 139 suggests this plan didn't quite work for England, in contrast to India's plan to Root.
Also from the table above, it seem Sam Billings had a pretty poor series after giving his wicket away nearly 3.5 times more than expected. The beehive plot below shows his dismissals and every other ball he faced in the series.
It shows how we was undone by the surprise bouncer from Ashish Nehra in the 2nd T20I, which had an xW of 0.136 – the highest he faced. His other 2 dismissals had xW's of 0.045 and 0.034. He faced 8 balls which had higher xW's from which he scored 17 runs. Although he is an opener, this perhaps shows his need to work on picking the right ball to hit.
Another theme to come out of this series was, predictably, England's poor batting performance against spinners. We can see if this is borne out with our xR and xW metrics. The table below compares England's xR and xW for both seamers and spinners.
England produced an average performance against seamers, scoring and losing wickets more or less in line with expectation. Against spinners, they over-performed in terms of scoring runs but lost nearly 3 more wickets than expected. If we exclude Suresh Raina from India's list of spinners, England's runs/xR drops to 1.064 and wicket/xW increases to 1.63 i.e. nearly 4.3 wickets more than expected. This can only confirm how dreadfully poor some of England's shot selection was in this series against spinners.
The heat maps above show how India's spinners bowled to right and left-handed batsman with their wickets in red. The dark green patches tend to be wide but quite flat. This suggests that their spinners get quite consistent bounce and rely on movement off the pitch for variation. We can compare this to England's spinners, again bowling to right and left-handed batsmen.
Interestingly, the heat map is more narrow and less flat. This suggests the England spinners relied more on variation in length rather than line.
Overall, we've shown how the xR and xW metrics, together with some visualisations, can be useful in a post-match analysis. We can make use of this data to confirm or challenge any conclusions that commentators or we as viewers may make about team or player performances. As I refine these models further, I'll be sure to do some more match analyses in between to make sure the metrics remain valid.
If there's anything you think I could add, let me know here.
In previous blogs I have described how I used the speed of the ball, and its line and length to calculate the Expected Runs and Expected Wickets of that ball. In this blog, I incorporate game state into these metrics, i.e. the over of the innings the ball was bowled. The run rate, and indeed the probability of getting a wicket, is not constant throughout the course of a T20 innings. Using data from nearly 4,000 T20 matches, we can calculate the average number of runs from each over of a innings, shown in the graph below. Teams generally have a bit of a go in the powerplay overs then completely start over in the 7th over – something I've always found a bit peculiar. Usually, a spinner comes on and they knock him about in that over. If teams target this over when the fielders have just recovered from the powerplay, perhaps they can increase their average scores by 2 or 3 runs – enough to win maybe 5% more games? Anyway, the average number of runs then increases in a pretty linear fashion.
The point is that the run rate fluctuates and xR can be adjusted to reflect that. The historical run rate in T20 matches is about 6.98. This is the benchmark that will be used to set the 'value' of overs. For example, on average there are 9.07 runs scored in the 20th over, so the xR of balls in this over will be multiplied by 9.07/6.98 = 1.30. In other words you would expect 30% more runs to be scored from the exact same balls than in the 13th over where the multiple is about 1. Similarly, the multiple of the 1st over is 0.71 i.e. 4.95/6.98.
The average number of wickets in an over follows a similar shape. Again we see that dip in the 7th over where both sides just drop in intensity a bit. Toward the end of the innings the wickets tend to fall at an exponential rather than linear rate. As before, we can adjust xW to account for this variation. The historical average wickets per over is 0.318. So the xW of balls in the last over for example, are multiplied by 0.80/0.318 = 2.52. However, this does not ever result in the xW of a particular ball exceeding 1. In fact the highest xW of a single ball is 0.704.
We can now see how this affects our batsmen and bowler ratings. The correlation between the old xR and updated xR is very significant with an R2 of 0.996, so we would expect few changes. The table below shows the best and worst performing batsmen by runs/xR with over 300 runs.
The best batsmen according to the updated metric is once again Glenn Maxwell followed by Aaron Finch. However, Darren Sammy, who was previously in 3rd position, has dropped all the way to 33rd. This is a reflection of his under-performance in scoring runs near the end of the innings. This may also be true of MS Dhoni whose xR/runs figure drops from 1.00 to 0.889 – the equivalent of about 76 runs. Dhoni is a great finisher of an innings but perhaps picks the right ball to hit a little too conservatively.
An example of a batsman who sees an increase in their runs/xR multiple is David Warner, from 1.14 to 1.21 – the equivalent of 56 extra runs. This perhaps illustrates the fact that he performs better in the first few overs of the innings than other openers and top-order batsmen. If you look at the first graph above, you'll see that of the first 12 overs of an innings, only 3 (overs 4, 5 and 6) are above the average run rate of about 7. This means batting in this period will result in your xR to be discounted as it were. Other examples include Aaron Finch and Chris Gayle who this updated model rates more favourably. On the other hand, Luke Wright's runs/xR drops ever so slightly from 1.13 to 1.12.
For bowlers with at least 200 balls, the top and bottom 10, measured by xR/ball, are shown below. It should be noted again that spinners historically have had a lower economy rate than pace bowlers in T20 cricket. This coupled with the fact that spinners tend to bowl in the middle overs means that this updated model favours spinners a slightly more than pace bowlers.
As expected, spinners make up the bulk of the top performers list. The best performing fast bowler is South Africa's Lonwabo Tsotsobe with an xR/ball of 1.16. One important difference to the previous model is the fact that the xR/ball figures have all dropped for bowlers in the top 10 and increased for bowlers in the bottom 10. Mohammad Hafeez's xR/ball has gone from 1.08 to 1.00 while Dwayne Bravo's has gone from 1.40 to 1.50. This shows how the new model can be useful in identifying the best bowlers at certain stages of the innings.
Furthermore, we can see how the updated xW model affects both batsmen and bowlers. You can see from the second graph above that the wicket rate for every over up to the 14th is below the average wicket rate, so the xW of any balls in that period will be discounted and vice versa. The best and worst performing batsmen, with at least 15 dismissals, measured by dismissals/xW are shown below.
This time JP Duminy is top after adjusting xW for game state. At the other end, surprisingly Shahid Afridi drops down to 4th worst with Michael Lumb taking his place. Interestingly there are quite a few openers in the bottom 10 compared to the previous model even though this model favours batsmen who bat in the opening overs. This possibly highlights the hit-and-miss nature for openers in T20's. Perhaps an extension to this model would include adjustment factors for different positions in the batting order.
Expected Strike Rate (xSR) is calculated from the number of balls divided by xW. In general, pace bowlers have had a lower strike rate than spinners in T20 cricket so it is not surprising to see only fast bowlers in the top 10 and mostly spinners in the bottom 10. Tsotsobe however, who we saw previously to be the best performing pace bowler in terms of runs/xR, has the highest xSR of any bowler. This is consistent with his career stats which suggests he is a bowler who keeps it tight in the latter overs without getting a load of wickets.
Overall, the intuition between adding game state to the model is simple – if a player scores more runs or takes more wickets than on average at a particular stage of the innings then they deserve some credit and tells us something about their game. I realise this article consisted of a lot of tables of data, but I'll be sure to include some more informative graphics in the future. In the next post I hope to look into game state further, specifically which batsmen and bowlers perform the best in the powerplay and death overs and why they're able to do so.
After refining my Expected Runs model in my last blog, I will now apply the same methods to investigate wicket taking deliveries. I use the same factors, namely where the ball pitched, the line and length when it gets to the batsman and the speed of the ball. For a particular delivery, the nearest neighbour algorithm finds the 50 most similar deliveries in terms of those attributes. The number of wickets resulting from those deliveries divided by 50 is the Expected Wickets, or xW, of that ball.
We use the same dataset as before – 41,104 balls from 208 T20I matches. The algorithm predicts a total of 2,279 wickets compared to the actual 2,298 wickets. Firstly, we can visualise which kind of balls are most likely to take a wicket. The image below shows the pitch map and beehive plot of the 100 balls with the highest xW figures ranging from 0.20 to 0.28. Red points indicate actual wickets and deliveries to left-handers have been flipped so they can be compared.
We can observe that these 100 balls cluster into 5 distinct bowling areas: yorker length deliveries, balls on middle and leg stump, good length top of off, back of a length outside off and bouncers outside off stump. Interestingly, the few deliveries which pitched beyond the stumps are full tosses highlighting their canny knack in getting wickets.
The performance of a batsman can be measured by comparing how many times they were dismissed to their total xW, or how many times we would expect the average batsman to be dismissed if they faced the exact same deliveries. The graph below shows the xW of every batsman in the dataset against how many times they were actually dismissed. The grey line separates over and under-performing batsmen. The over-performing batsmen are below the line and those tend to be the ones who have batted (and been dismissed) most often. It seems the more established batsmen get out less often than what the metric predicts compared to the many tail-enders who hardly bat in T20 matches.
The table below shows the best performing batsmen calculated by the ratio of wickets to xW, for batsmen dismissed at least 15 times.
Perhaps unsurprisingly, notorious wicket giver-away Shahid Afridi comes out way on top with a dismissal to xW ratio of 1.70. In other words, he has given away 70% more wickets than the average batsman would have done facing the same balls. Further down the list are some more notable hitters like Darren Sammy and Kieron Pollard. Interestingly, AB de Villiers is under-performing with respect to this metric, which may suggest to need to incorporate game state into the model. It is likely this ratio increases toward the end of the innings as batsmen become more willing to sacrifice their wickets.
It would be pertinent to view the relationship between wickets/xW and runs/xR as these are both metrics which independently rate how good a batsman is. The graph above shows a slight negative trend as you would expect. The more runs you score above expectation, the less likely you are to give your wicket away compared to the average batsman. However an R2 of 0.185 suggests the relationship is not completely significant. This does mean the two metrics can be treated more or less independently and therefore be combined in some way to rate a batsman more reliably.
Out of interest, the leader of the runs/xR metric, Glenn Maxwell, has a wicket/xW ratio of 0.979 meaning he is over-performing ever so slightly.
We can also investigate how bowlers fare with this metric. The table below shows the best performing bowlers (with at least 300 balls) ordered by Expected Strike Rate, or xSR. This is the number of balls bowled divided by xW.
Mitchell Starc is first with 15.8 balls per Expected Wicket. Next come 8 more pace bowlers before the first spinner, Ravindra Jadeja. For reference, the strike rates in all T20I matches for pace bowlers and spinners are 19.0 and 19.9 respectively, so we would expect this split. The bottom 10 bowlers are as below.
Here we see mostly spin bowlers with the only two seam bowlers in 9th and 10th place. Interestingly we see Mohammad Hafeez and Sunil Narine in the list, both of whom the xR/ball metric rated highly. In both lists there are bowlers who take more or fewer wickets than what xW predicts. This is not something xSR takes into account as the xW of a delivery is only a function of the attributes of that delivery and not the eventual outcome. Bowlers who happen to take fewer wickets than expected have most likely bowled to more capable batsman more often and vice-versa.
I hope this article has demonstrated the usefulness and validity of the Expected Wickets metric in rating the performances of batsmen and bowlers. In future blogs I will see how this complements the Expected Runs metric and hope to include more variables to refine the model further.
As ever, if you have any questions/suggestions please feel free to tweet me here.
In my first blog I described my first attempt at a metric called Expected Runs or xR. This calculated the average number of runs a batsman would score off a delivery based on the ball's line and length as it reaches the batsman. In this blog, I extend this model by including other factors such as the speed of the ball and where it pitched.
I recently used a machine learning algorithm called k-nearest neighbours to develop a Expected Goals model. This worked out pretty well so I thought I'd apply this to my cricket data. Put simply, this algorithm finds the k (I used 50) most similar deliveries to a particular delivery and calculates the average number of runs accrued from those. This means that it is not necessary to split bowlers into spinners and fast bowlers, as balls bowled at a typically spinner's or seamer's pace are likely to be grouped together.
From the ball-by-ball T20I data I removed any wides and erroneous deliveries. In contrast to my first xR model I decided to mirror flip any deliveries to left-handers so that they can be equivalently compared to right-handers. This left 41,104 balls from 208 matches. After applying the algorithm as above, the total xR was 50,978 runs compared to 50,923 actual runs – a 0.1% error. This is not surprising at all given that the algorithm learns on itself. Almost by definition, the total actual runs and xR must more or less match.
As before, we can calculate the xR of individual batsmen. The plot below shows each batsman's careers runs against their xR. The straight line is y=x and acts as the dividing line between over and under-performing their expectation. Most of the highest scoring batsmen are over-performing which perhaps means that there is an aspect of their game we are not capturing with this metric. One possible factor is boundary hitting. The runs/xR ratio for a particular ball can take values up to and above six. As such, batsmen who hit a lot of boundaries can inflate their performance with this metric, not that boundary hitting is a bad thing. The usefulness of xR comes from identifying batsmen who can score more runs from deliveries than on average and this includes rotating the strike and hitting into gaps for two's and three's. The graph below shows the total number of boundaries for each player against their performance figure, measured by runs/xR.
Although there is a slight positive correlation, the R² value is just 0.119. This means that total boundaries only explains 11.9% of the variance in the performance measure. The R² drops to 0.093 if we only include batsmen who have scored at least 20 boundaries, indicating that it is even less significant for the better batsmen. The table below shows the top 20 performing batsmen with at least 300 runs (of which there are 52).
As before, Glenn Maxwell comes way out on top over-performing his xR by 42%, followed by his Australian teammate Aaron Finch. Finch and Sammy have swapped places from the list in the my first xR model. Some other notable changes include Shahid Afridi dropping from 5th to 12th in the list, and Mahela Jayawardene breaking into the top 10.
This time Martin Guptill comes bottom of the pile instead of Mohammad Hafeez who is in second place. It is reassuring that the runs/xR figures themselves have not changed drastically. In this and the previous model, they are mostly between 0.9 and 1.2.
The tables below show the 10 best and worst performing bowlers who have bowled at least 200 balls (there are 60 such bowlers in the dataset).
In my previous blog about xR, I questioned Hafeez's place in the Pakistan T20 side based on his batting stats. But it appears his bowling justifies his inclusion as he has the lowest xR/ball in the list. As explained in that post, bowlers who concede more runs than expected are most likely unlucky enough to bowl to quality batsmen quite often. Sunil Narine slips down to 8th, although he still concedes over 100 runs fewer than expected.
Spinners dominate the top of the list with the best performing pace bowler, Bhuvneshwar Kumar, coming in at 18th place with an xR/ball of 1.205. This is not entirely unexpected, as spinners have an overall economy rate of 6.89 in T20I's compared to 7.70 for pace bowlers. The full lists for both batsmen and bowlers can be obtained here.
In future blogs I will be extending this analysis to ODI's and Test matches and investigate xR at a match level. I'll also be experimenting with other machine learning algorithms to predict both runs and wickets.
If you have any suggestions or ideas of your own, please feel free to tweet me.
In my last blog I built two simple xG models using the distance of a shot from the goal line and the angle a shot makes with the crossbar. The second model attempted to account for the fact that, for the same distance, shots from wide areas are less likely to be scored than shots from right in front of goal. However, this was not perfect as it still undervalued shots from directly in front of goal closer to the penalty spot. Ideally, our xG visualisation should look like this (courtesy of David Sumpter) with high xG shots directly in front of goal and low xG shots in the wide areas but still close to the goal. This can achieved by combining both distance and angle to goal into one function. But this is not a trivial problem as described in detail by Michael Caley. Through trial-and-error, he manages to capture the above distribution pretty well using a combination of distances and angle and inverse distances and angles.
Another approach is to consider clusters of shots. A set of shots that are geometrically close together will have similar distances and angles so should therefore have a similar xG. This is the concept of binning as described in this model. The number of goals divided by the number of shots from inside a particular bin gives us the xG for those shots.
My approach uses a k-nearest neighbour algorithm which is a simple machine learning technique. For a particular shot, the KNeighborsRegressor Python package will search for the 500 closest shots and then count up the number of goals. This number divided by 500 is the xG for that shot. The image below is a visualisation of this model showing all 226,917 shots in the dataset. This seems much more like the xG distribution from above. However, the xG of shots in the 6 yard box right in front of goal is about 0.8 whereas my previous models predicted values closer to 1. This is a result of the high value for k. The 500 nearest neighbours to shots near the goal line will draw upon shots in the edges of the 6 yard box due to the relatively low density of shots.
There are 21,578 goals in the whole dataset. This model predicts 21,409 goals which is an error of just 0.8%. We can investigate how teams and players perform under this metric. The graph below shows the total xG for each team in the dataset against the total goals they scored. The line is y=x and shows over-performing teams above the line and under-performing teams below the line. The really good teams over-perform meaning there are aspects of their play that isn't captured by a shots-based xG model. These teams ordered by their performance, measured by total goals divided by total xG, are shown below.
Similarly, we can assess players using xG. The graph below shows xG against total goals per player. Again it seems the best players over-perform their xG numbers. A breakdown of players with at least 60 goals is shown in the table below.
Luis Suárez is over-performing his xG by a huge 72%, closely followed by Messi and Griezmann at 70%. It is interesting to note that Benzema has an xG per shot of 0.154, the highest of the players in the list. This, coupled with his high over-performance figure, suggests he is finishing really well and getting into high value positions to shoot. Meanwhile, his Real Madrid teammates, Ronaldo and Bale have the lowest xG/shot. It seems they have their share of speculative efforts before Benzema comes in to clean up if they fail.
It is reassuring that this xG model identifies the best teams and players, validated by other models. The machine learnining algorithms can of course be extended to include many other factors. In future blogs, I'll look to build these into my cricket models.


Smart supermarket is a well established supermarket which started operations in retail in 1981. In reality intelligent carts do already exist, one example being the Wind cart from French organization Caddie, which permits you to scan your obtain products oneself and visualise your journey by means of the shop by way of a touchscreen and integrated GPS functionality.
Yes, dealing with the supermarket verify-out line — such as the horror of getting kids screaming for the candy conveniently" placed there by profit-hungry conglomerates — is among the least well known chores, according to many surveys. Beamed from the supermarket ceiling, this device transforms surface into an interactive computer system.
The small business case for connecting supermarkets with electricity and heating networks is primarily based on the energy and CO2 savings it will produce and the incredibly quick payback occasions of about 1 and a half years for the supermarket owner. Possessing tapped in a purchasing list on to his/her smartphone, the customer will then be able to synchronise the mobile device with the screen on the trolley. Metro Group is making use of RFID technology to determine items, safeguard against theft, and track inventory and expiration dates in real-time, as nicely as to monitor activity on the store's consumer loyalty cards.
If the thought of navigating your neighborhood supermarket tends to make you want for a map and compass, let these strategies guide you on your subsequent trip. Intelligent already offers much more than 20 varieties of breads, flavored with sunflower, white and black sesame seeds, oat flakes, wheat or buckwheat oats. Visit our Smart Supermarket bread counter to get your freshly baked bread from our personal Wise Bakery!
Energy Star estimates that an typical supermarket (50,000 square feet) spends $250,000 annually on power expenses, equating to additional than $4 per square foot – one particular of the highest rates of power consumption per square foot. A significant quantity of high-finish solutions can be found in the Wellness and Beauty Solutions section of Smart Supermarket. Join the Clever Baby Club and benefit from more discounts and special offers.


PDC Engineers is pleased to announce that Cody Kreitel, PE, has joined the firm as a Geotechnical Engineer in our Anchorage office. Kreitel received a bachelor's degree in Civil Engineering from BYU and a master's degree in Arctic Engineering from UAA. He has worked on a wide variety of projects across Alaska and has extensive field experience in remote locations.


Blood diseases affect millions of people each year. These inherited and acquired diseases, including the anemias, venous thromboembolism, hemophilia, and other bleeding disorders, can affect red and white blood cells, platelets, bone marrow, vascular endothelium, or plasma proteins. These conditions can cause blood cells to function abnormally, which may lead to disease or affect overall health. Blood safety involves keeping the Nation's blood supply free of contaminants or infectious agents.
I never like to say 'cured,' but it feels like it's gone; it feels like a cure."
Jennifer Nsenkyire (pronounced 'century') has suffered from sickle cell disease for as long as she can remember. As a teenager growing up in her native Ghana, she endured the excruciating pain caused by the condition sometimes for days at a time.
Read more about Jennifer's struggle with sickle cell disease.
NHLBI has major research responsibilities in blood diseases. One is to ensure the adequacy and safety of the Nation's blood supply. A second is to support efforts to treat and cure blood disorders, such as scientific advances in stem cell biology and new gene and cell-based therapies to repair and regenerate human tissues and organs. By funding and supporting research on the causes, prevention, and treatment of blood disorders, we help researchers make new discoveries, which lead to better medical care for the millions of people affected by blood disorders around the world.
The NHLBI-led Cure Sickle Cell Initiative is a patient-focused research effort to develop genetic therapies for use in clinical research within 5 to 10 years.
NHLBI-sponsored research has helped and continues to help Americans with sickle cell disease live longer and well in into adulthood.
NHLBI-supported scientists developed life-saving treatments for patients with hemophilia and are now working on gene therapy approaches to cure the disease.
NHLBI-funded research helped develop therapies that increased the survival rates for patients who have aplastic anemia.
In 2016, NHLBI released its Strategic Vision, which will guide the Institute's research activities for the coming decade. Many of the objectives, compelling questions, and critical challenges identified in the plan focus on blood biology, blood disorders, and blood safety. Training the next generation of blood scientists is also a high priority for NHLBI.
Researchers are working across scientific disciplines to advance blood disorders research. NHLBI is assisting in this effort by enabling early translational research to accelerate the development of new clinical interventions. Currently, we are supporting research resource programs that provide regulatory, pharmacology, toxicology, and manufacturing services to NHLBI investigators who are doing blood science research. The hope is for patients with blood disorders to live long and full lives, and to improve blood safety measures both in the United States and around the world.
NHLBI is advancing blood disorders and blood safety research in many ways. Learn more about some of our key efforts related to sickle cell disease, anemia, blood transfusions, and more.
The NHLBI Division of Intramural Research and its Hematology Branch, Sickle Cell Branch and Sickle Cell Program include some of the investigators at NHLBI who are actively engaged in research on blood disorders and blood safety.
The research we fund today will help improve our future health. Our Division of Blood Diseases and Resources is a leader in research on the causes, prevention, and treatment of blood diseases other than cancers of blood cells. NHLBI's Division of Cardiovascular Sciences also supports some blood science research.
Through NHLBI's Trans-Omics for Precision Medicine (TOPMed) program, researchers will use data from studies focused on heart, lung, blood, and sleep disorders to better predict, prevent, diagnose, and treat blood disorders based on a patient's unique genes, environment, and molecular signatures. Learn more about NHLBI precision medicine activities.
The Cure Sickle Cell Initiative is a NHLBI-led collaborative research effort to develop genetic therapies for patients who have sickle cell disease. The goal is to have these genetic therapies ready to safely use in clinical research within five to 10 years. The Initiative is patient-focused, and it will bring together researchers, industry, patients, providers, advocacy groups, and others as it supports research, education, and community engagement activities.
While most U.S. children with sickle cell disease survive to adulthood, the transition from pediatric to adult care is often challenging. By funding the Sickle Cell Disease Implementation Consortium, we are working to understand current barriers to care, test interventions to overcome those barriers, and develop a new sickle cell disease registry.
More than 75 percent of infants with sickle cell disease are born in sub-Saharan Africa. By funding the Sickle Cell Disease in Sub-Saharan Africa Collaborative Consortium and associated Data Coordinating Center, we are building the regional capabilities to research sickle cell disease and monitor patients in Africa. These efforts may ultimately improve treatment and care for Americans who have sickle cell disease.
The NHLBI started the Recipient Epidemiology and Donor Evaluation Study (REDS) program in 1989 to protect the Nation's blood supply from threats, improve the benefits of transfusions, and reduce the risks of transfusions. Now in its third phase, called REDS-III, this program supports research in the United States and around the world. REDS-III includes research to prevent the transmission of Dengue and Zika viruses through blood transfusions.
The Blood and Marrow Transplant Clinical Trials Network (BMT CTN) was established to conduct large multi-institutional clinical trials to understand the best possible treatment approaches in blood and marrow transplantation. In the United States, nearly 21,000 patients receive blood or marrow transplants annually, mainly for rare blood disorders.
The NHLBI's Production Assistance for Cellular Therapies (PACT) supports translational research on cellular and genetic therapies by increasing the capacity to manufacture cell products that follow current Good Manufacturing Practices (cGMP) regulations. PACT offers education and resources through its five Cell Processing Facilities and a Coordinating Center that support activities such as safety testing, product shipment, and design of clinical testing protocols.
The Trans-Agency Research Consortium for Trauma-Induced Coagulopathy (TACTIC) research program was established in collaboration with the Department of Defense to study the disruptions in the normal process of blood clotting that occurs in individuals who experience severe trauma. Trauma, particularly severe trauma, can disturb the body's mechanisms for stopping hemorrhage or lead to the overproduction of blood clots, both of which can cause major or even fatal complications.
Myelodysplastic syndromes (MDS), a collection of rare disorders that for unknown reasons leads to defects in blood stem cells, affects at least 10,000 adults each year in the United States. The National MDS Natural History Study is a joint NHLBI and National Cancer Institute study that aims to create a resource of high quality biospecimens linked to clinical data that scientists can use to conduct research to improve diagnosis and treatment of MDS.
The Biologic Specimen and Data Repository Information Coordinating Center (BioLINCC) centralizes and integrates biospecimens and clinical data that were once stored in separate repositories. Researchers can find and request available resources on BioLINCC's secure website, which maximizes the value of these resources and advances heart, lung, blood, and sleep research.


text:
package kiwi.dashboard.action;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.persistence.EntityManager;
import javax.persistence.NoResultException;

import kiwi.api.content.ContentItemService;
import kiwi.api.entity.KiWiEntityManager;
import kiwi.api.tagging.TaggingService;
import kiwi.api.triplestore.TripleStore;
import kiwi.model.Constants;
import kiwi.model.content.ContentItem;
import kiwi.model.kbase.KiWiLiteral;
import kiwi.model.kbase.KiWiTriple;
import kiwi.model.kbase.KiWiUriResource;
import kiwi.model.recommendation.RuleBasedRecommendation;
import kiwi.model.tagging.Tag;
import kiwi.model.user.User;
import kiwi.service.reasoning.ReasoningConstants;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.faces.FacesMessages;

/**
 * A component supporting the management of personal rules. Used by the
 * Dashboard rules.xhtml view.
 *
 * @author freddurao
 *
 */
@Name("kiwi.dashboard.ruleAction")
@Scope(ScopeType.PAGE)
public class RuleBasedAction implements Serializable {

	/**
	 *
	 */
	private static final long serialVersionUID = 1L;

	@In
	@Out
	private User currentUser;

	@In(create=true)
	private EntityManager entityManager;

	@In(create=true)
	private KiWiEntityManager kiwiEntityManager;

	@In(create=true)
	private ContentItemService contentItemService;

	@In(create=true)
	private TaggingService taggingService;

	private String tagRec;

	private String myTag;

	private String firstQuery;

	private String secondQuery;

	private String ruleType;

	@In
    FacesMessages facesMessages;

	@In
	private TripleStore tripleStore;

	private List<RuleBasedRecommendation> ruleBasedRecommendations;

	private String RECOMMEND_ME_PAGES_WITH_TAGS="recTag";

	private String TAG_PAGES_WITH_TAGS="ruleTag";

	private String TAG_MY_PAGES_WITH_TAGS="myTag";

	/**
	 * @return
	 */
	public List<RuleBasedRecommendation> getRuleBasedRecommendations() {
		if(ruleBasedRecommendations == null) {
			ruleBasedRecommendations = new LinkedList<RuleBasedRecommendation>();
		}
		ruleBasedRecommendations = loadRuleBasedRecommendations();
		return ruleBasedRecommendations;
	}

	/**
	 * Created a personal rule
	 */
	public void createRule(String ruleType) {
		    this.setRuleType(ruleType);
		    boolean validated = false;
			RuleBasedRecommendation ruleBasedRecommendation = new RuleBasedRecommendation();
			ruleBasedRecommendation.setUser(currentUser);
			ruleBasedRecommendation.setRuleType(ruleType);
		    if (ruleType.equals(RECOMMEND_ME_PAGES_WITH_TAGS) && tagRec!=null && !tagRec.isEmpty()) {
				ruleBasedRecommendation.setTagRec(tagRec);
				validated = true;
			}else  if (ruleType.equals(TAG_MY_PAGES_WITH_TAGS)&& myTag!=null && !myTag.isEmpty()) {
				ruleBasedRecommendation.setMyTag(myTag);
				validated = true;
			}else  if (ruleType.equals(TAG_PAGES_WITH_TAGS)&& firstQuery!=null && secondQuery!=null && !firstQuery.isEmpty() && !secondQuery.isEmpty()) {
				ruleBasedRecommendation.setFirstQuery(firstQuery);
				ruleBasedRecommendation.setSecondQuery(secondQuery);
				validated = true;
			}
		    if (validated) {
				entityManager.persist(ruleBasedRecommendation);
				entityManager.flush();
				FacesMessages.instance().add("Rule created successfully.");
			}else{
				FacesMessages.instance().add("A field must be filled out");
			}

		    this.setFirstQuery(null);
		    this.setSecondQuery(null);
		    this.setTagRec(null);
		    this.setMyTag(null);
	}

	/**
	 * Save the rule in the triple store
	 * @param ruleBasedRecommendation
	 *
	 *
	 * 			String rule2 = "tag-1: ($tagging holygoat:taggedResource $ci), " +
					              "($tagging holygoat:associatedTag $tag), (" +
					              "$tagging holygoat:taggedBy $user), " +
					              "($tagging holygoat:taggedOn $date), " +
					              "($tag kiwi:title \"ahoj\") ->" +
					              " ($newtagging holygoat:taggedResource $ci)," +
					              " ($newtagging holygoat:associatedTag $newtag)," +
					              " ($newtagging holygoat:taggedBy $user), " +
					              "($newtagging holygoat:taggedOn $date), " +
					              "($newtag kiwi:title \"inferred\")";

			 // @prefix holygoat: <http://www.holygoat.co.uk/owl/redwood/0.1/tags/>
	 *
	 */

	public void generateRule(RuleBasedRecommendation ruleBasedRecommendation) {
			KiWiUriResource programUri = tripleStore.createUriResource(ReasoningConstants.KIWI_RDFS_SKWRL_PROGRAM);//the default program, see TriplestoreProgramLoader.getContent()
			KiWiUriResource property = tripleStore.createUriResource(ReasoningConstants.KIWI_PROGRAM_HAS_RULE);
			String rule = this.getRuleByType(ruleBasedRecommendation);
			System.out.println(rule);
			KiWiLiteral literal = tripleStore.createLiteral(rule);
			KiWiTriple kiwiTriple = tripleStore.createTriple(programUri, property, literal);
			kiwiEntityManager.persist(kiwiTriple);
			ruleBasedRecommendation.setKiwiTriple(kiwiTriple);
			entityManager.persist(ruleBasedRecommendation);
			entityManager.flush();

			//kiwiEntityManager.persist(ruleBasedRecommendation);

			gotTagging(ruleBasedRecommendation);
			FacesMessages.instance().add("Rules fired !");
	}

	/**
	 * @param ruleBasedRecommendation
	 */
	public void gotTagging(RuleBasedRecommendation ruleBasedRecommendation) {

		Set<Long> ciIds = new HashSet<Long>();

		Set<Long> ciTagsIds = new HashSet<Long>();

		List<Tag> tags = new ArrayList<Tag>();

		List<ContentItem> taggedItemsSet = new ArrayList<ContentItem>();

		List<ContentItem> taggedContentItems = new ArrayList<ContentItem>();

		if (ruleBasedRecommendation.getRuleType().equals(TAG_PAGES_WITH_TAGS)) {
			tags.addAll(taggingService.getTagsByLabel(ruleBasedRecommendation.getFirstQuery()));
		}else if (ruleBasedRecommendation.getRuleType().equals(TAG_MY_PAGES_WITH_TAGS)) {
			tags.addAll(taggingService.getTagsByUser(currentUser));
		}

		for (Tag tag : tags) {
			if (!ciIds.contains(tag.getTaggingResource().getId())) {
				taggedContentItems.addAll(taggingService.listTaggedItems(tag.getTaggingResource()));
				ciIds.add(tag.getTaggingResource().getId());
			}
		}

		for (ContentItem contentItem : taggedContentItems) {
			if (!ciTagsIds.contains(contentItem.getId())) {
				taggedItemsSet.add(contentItem);
				ciTagsIds.add(contentItem.getId());
			}
		}

		for (ContentItem contentItemToBeTagged : taggedItemsSet) {
		    	ContentItem newTag = contentItemService.createContentItem();
				if (ruleBasedRecommendation.getRuleType().equals(TAG_PAGES_WITH_TAGS)) {
					contentItemService.updateTitle(newTag, ruleBasedRecommendation.getSecondQuery());
				}else if (ruleBasedRecommendation.getRuleType().equals(TAG_MY_PAGES_WITH_TAGS)) {
					contentItemService.updateTitle(newTag, ruleBasedRecommendation.getMyTag());
				}
		    	contentItemService.saveContentItem(newTag);

				if (ruleBasedRecommendation.getRuleType().equals(TAG_PAGES_WITH_TAGS)) {
					taggingService.createTagging(ruleBasedRecommendation.getSecondQuery(), contentItemToBeTagged, newTag, currentUser);
				}else if (ruleBasedRecommendation.getRuleType().equals(TAG_MY_PAGES_WITH_TAGS)) {
					taggingService.createTagging(ruleBasedRecommendation.getMyTag(), contentItemToBeTagged, newTag, currentUser);
				}
		}
	}

	/**
	 * @param ruleType
	 * @param ruleBasedRecommendation
	 */
	public String getRuleByType(RuleBasedRecommendation ruleBasedRecommendation){
		Map<String, String> ruleMap = new HashMap<String, String>();

		String ruleRecommendation = "tag-"+currentUser.getLogin().concat("-").concat(""+ruleBasedRecommendation.getId())+":" +
		  "(($x rdf:type "+Constants.NS_KIWI_CORE+"ContentItem)," +
		  "($x "+Constants.NS_HGTAGS+"taggedWithTag \""+ruleBasedRecommendation.getTagRec()+"\")) -> " +
		  "(($x "+Constants.NS_KIWI_CORE+"recommendTo "+Constants.NS_KIWI_CORE+currentUser.getLogin()+"))";
		ruleMap.put(RECOMMEND_ME_PAGES_WITH_TAGS, ruleRecommendation);

		String ruleMyTags = "tag-"+currentUser.getLogin().concat("-").concat(""+ruleBasedRecommendation.getId())+": " +
		  "(($tagging holygoat:taggedResource $ci),($tagging holygoat:associatedTag $tag)," +
		  "($tagging "+Constants.NS_HGTAGS+"associatedTag \""+ruleBasedRecommendation.getFirstQuery()+"\")) -> " +
		  "(($newtagging holygoat:taggedResource $ci),($newtagging "+Constants.NS_HGTAGS+"associatedTag \""+ruleBasedRecommendation.getSecondQuery()+"\"))";
		ruleMap.put(TAG_PAGES_WITH_TAGS, ruleMyTags);

		String ruleTags = "tag-"+currentUser.getLogin().concat("-").concat(""+ruleBasedRecommendation.getId())+":" +
		  "(($tagging holygoat:taggedResource $ci),($tagging holygoat:associatedTag $tag)," +
		  "($tagging "+Constants.NS_HGTAGS+"taggedBy \""+Constants.NS_KIWI_CORE+currentUser.getLogin()+"\")) -> " +
		  "(($newtagging holygoat:taggedResource $ci),($newtagging "+Constants.NS_HGTAGS+"associatedTag \""+ruleBasedRecommendation.getMyTag()+"\"))";
		ruleMap.put(TAG_MY_PAGES_WITH_TAGS, ruleTags);
		return ruleMap.get(ruleBasedRecommendation.getRuleType());

	}

	/**
	 * @return
	 */
	@SuppressWarnings("unchecked")
	private List<RuleBasedRecommendation> loadRuleBasedRecommendations() {
		List<RuleBasedRecommendation> ruleBasedRecommendations  = null;
		String s = "select u from RuleBasedRecommendation u where u.user =:user ";
		javax.persistence.Query q = entityManager.createQuery(s);
        q.setParameter("user", currentUser);
        try {
        	ruleBasedRecommendations = (List<RuleBasedRecommendation>)q.getResultList();
 		} catch (NoResultException ex) {
 			//
		}
		return ruleBasedRecommendations;
	}

	/**
	 * @param rule
	 */
	public void removeRule(RuleBasedRecommendation rule) {
		if (rule.getKiwiTriple()!=null) {
		    tripleStore.removeTriple(rule.getKiwiTriple());
		}
		    entityManager.remove(rule);
			entityManager.flush();
			FacesMessages.instance().add("Rule deleted successfully.");

	}

	public String getFirstQuery() {
		return firstQuery;
	}

	public void setFirstQuery(String firstQuery) {
		this.firstQuery = firstQuery;
	}

	public String getSecondQuery() {
		return secondQuery;
	}

	public void setSecondQuery(String secondQuery) {
		this.secondQuery = secondQuery;
	}

	public String getRuleType() {
		return ruleType;
	}

	public void setRuleType(String ruleType) {
		this.ruleType = ruleType;
	}

	public String getTagRec() {
		return tagRec;
	}

	public void setTagRec(String tagRec) {
		this.tagRec = tagRec;
	}

	public String getMyTag() {
		return myTag;
	}

	public void setMyTag(String myTag) {
		this.myTag = myTag;
	}

}

redpajama_set_name: RedPajamaGithub


Spokane HOPE (Hearing Oral Program of Excellence) is a nonprofit developmental communication program for infants and children with hearing loss. "When a new parent finds out their child has hearing loss they're scared, they wonder what their baby's future is going to look like, and how they're going to communicate with them," Danette Driscoll the executive director of HOPE said.
Most of the children at HOPE use cochlear implants to hear. "We have children who might be two years old before their parents realise they have hearing loss," said Driscoll. "Sometimes if it's their first child they say 'oh kids learn to talk at different times', but If you think about your brain for two years not getting any language in it, that's a lot to catch up on." HOPE helped 81 Spokane children in 2017, operating in the smallest community to support such a program nationwide. Their teachers for the deaf help the children learn communication skills starting as early as two to three months and offer programs though preschool.
HOPE plans on building their access to rural areas to accommodate the need that exists outside of cities. Teachers can also connect with families via Skype to help them make sense of the sounds that are going on around them.


text:
#ifndef TENSORFLOW_COMPILER_MLIR_QUANTIZATION_TENSORFLOW_PYTHON_QUANTIZE_MODEL_WRAPPER_H_
#define TENSORFLOW_COMPILER_MLIR_QUANTIZATION_TENSORFLOW_PYTHON_QUANTIZE_MODEL_WRAPPER_H_

#include <pybind11/stl.h>

#include "absl/strings/string_view.h"
#include "pybind11/pybind11.h"
#include "pybind11/stl.h"
#include "tensorflow/python/lib/core/pybind11_lib.h"

namespace tensorflow {
namespace quantization {

PyObject* QuantizeQATModel(absl::string_view saved_model_path,
                           absl::string_view exported_names_str,
                           absl::string_view tags);

PyObject* QuantizePTQModelPreCalibration(absl::string_view saved_model_path,
                                         absl::string_view exported_names_str,
                                         absl::string_view tags);

PyObject* QuantizePTQModelPostCalibration(absl::string_view saved_model_path,
                                          absl::string_view exported_names_str,
                                          absl::string_view tags);

void ClearCollectedInformationFromCalibrator();

void ClearDataFromCalibrator(absl::string_view id);

float GetMinFromCalibrator(absl::string_view id);

float GetMaxFromCalibrator(absl::string_view id);

}  // namespace quantization
}  // namespace tensorflow

#endif  // TENSORFLOW_COMPILER_MLIR_QUANTIZATION_TENSORFLOW_PYTHON_QUANTIZE_MODEL_WRAPPER_H_


text:
Kingswood House is proud to support many worthwhile causes in keeping with our charitable status. It is our policy to help charities who directly work with children, as much as possible. Our main source of fundraising comes from "House Days" which are organised by Senior pupils and House staff throughout the year. However, there are many other days where we work in tandem with external organisations to raise the profile of important initiatives - such as Mental Health Awareness Day.
The House System
At Kingswood House, pupils are placed into one of four Houses when they join the school: Drake, Marlborough, Nelson or Wellington. House points are awarded for academic effort and attainment or at a teacher's discretion for successfully representing the school's values in association with The Kingswood House Way. Regular competitions are also held across sport, art, music and drama which generate a lot of excitement from the participants! The House points are accrued on a weekly basis and the House with the biggest total wins the House Cup each term – there is also an overall winner of the House Cup at the end of the academic year which is presented at Prize Giving.
House Families
Boys and girls are assigned to vertically-streamed House Families within their Houses. The idea is adapted from a concept from St Andrew's University, where each new student is assigned a second year "parent" and a final year "grandparent" with whom the fresher can spend time and become accustomed to their new surroundings. As such, our students have been carefully divided into "families", each of which boasts a cross-section of pupils from Lower Prep, Upper Prep and Seniors. They work as a team in House Meetings on a fortnightly basis as well as a dedicated afternoon at the start of each term and it is hugely rewarding to see the great mentorship in evidence between older pupils and their younger counterparts.
You are: Home » School Life » Charities & Houses

redpajama_set_name: RedPajamaCommonCrawl


text:
Showing results for tags 'vertical'.
Gaming News:Rival Megagun Pits Players Against One Another in Classic Shoot 'Em Up Style
Jack Gardner posted a topic in Announcements
You know the massive boss ships that float down from the top of the screen in classic bullet hell games? Have you ever wondered what it would be like to play as one of those for a change? Now you can thanks to Spacewave Software's Rival Megagun! Rival Megagun has two players competing against one another as they battle through SHMUP (Shoot 'Em Up) levels while trying to take one another out. When hitting certain power levels, players can cross the vertical divide to attack their opponent as a colossal boss ship - a Mega Gunship, if you will. Players can tackle the game solo against the AI, play against friends in local couch co-op, or take on all comers online. The game features a number of different playable characters each with their own strengths and weaknesses and unique Mega Gunship forms. There's also a solo play arcade mode for those who want to immerse themselves in the classic roots of the genre. As players progress through the Rival Megagun, they'll unlock new components and weapons for their various ships, enabling customizations and opening up devious tactics to spring on unsuspecting rivals. Rival Megagun is available today for PC and PlayStation 4, November 30 for Xbox One, and December 12 for the Nintendo Switch. Don't forget to sign up for Extra Life to help sick and injured kids in hospitals around the US and Canada by playing games! View full article
rival megagun
degica games
spacewave software
Rival Megagun Pits Players Against One Another in Classic Shoot 'Em Up Style
Jack Gardner posted an article in Gaming News
You know the massive boss ships that float down from the top of the screen in classic bullet hell games? Have you ever wondered what it would be like to play as one of those for a change? Now you can thanks to Spacewave Software's Rival Megagun! Rival Megagun has two players competing against one another as they battle through SHMUP (Shoot 'Em Up) levels while trying to take one another out. When hitting certain power levels, players can cross the vertical divide to attack their opponent as a colossal boss ship - a Mega Gunship, if you will. Players can tackle the game solo against the AI, play against friends in local couch co-op, or take on all comers online. The game features a number of different playable characters each with their own strengths and weaknesses and unique Mega Gunship forms. There's also a solo play arcade mode for those who want to immerse themselves in the classic roots of the genre. As players progress through the Rival Megagun, they'll unlock new components and weapons for their various ships, enabling customizations and opening up devious tactics to spring on unsuspecting rivals. Rival Megagun is available today for PC and PlayStation 4, November 30 for Xbox One, and December 12 for the Nintendo Switch. Don't forget to sign up for Extra Life to help sick and injured kids in hospitals around the US and Canada by playing games!


text:
Brian O´Doherty: Uvnitř bílé krychle. Ideologie galerijního prostoru
Authors: Brian O´Doherty
Editors: Vít Havránek
Publisher: tranzit.cz, Prague
Few essays have garnered as much immediate response as Brian O'Doherty's Inside the White Cube, originally published as a series of three articles in Artforum in 1976, and subsequently collected in a book of the same name. The story goes that the issues of Artforum containing O'Doherty's texts sold out very quickly, and as he himself has remarked, many artists he spoke to at the time told him that they themselves had been thinking about writing something similar. This is to say that the main concern of the essay – how to deal with the white cube convention for gallery design – was shared by many of his contemporaries.
O'Doherty was the first to explicitly confront a particular crisis in post-war art as he sought to examine the assumptions on which the modern commercial and museum gallery was based. Concerned with the complex and sophisticated relationship between economics, social context and aesthetics as represented in the contested space of the art gallery, he raises the question of how artists must construe their work in relation to the gallery space and system.
Naturally, O'Doherty was writing not only within the specific context of post-minimalism and conceptual art of the 1970s, but also from the point of view of artistic practice. Aside from being a prominent critic, O'Doherty was also an installation artist, having worked since 1972 under the name of Patrick Ireland (in protest against the British Army's involvement in Ulster). As both theorist and practitioner, insider and outsider, he was not in a bad position to examine the ideology of something as peculiar as the modern gallery space, the much loved and maligned "white cube".
These essays are essential reading for anyone interested in the history and issues of post-war art in Europe and the United States. Teeming with ideas, relentless in their pursuit of contradiction and paradox, they exhibit both the understanding of the artist (Patrick Ireland) and the precision of the scholar.
Having Brian O'Doherty's provocative essays available in Czech is a signal event for the Czech art scene. This edition also includes The Gallery as Gesture, a critically important piece published ten years after the others.
This publication is available at ERSTE Foundation Library.
Ion Grigorescu. Diaries and Dreams, 1976-1979
Eastern Sugar
Všichni jsme emotivní! / We are all emotional!
The ERSTE Foundation Tipping Point Talks 2019 – Identity | Normativity


Cambridge, Mass.—May 18, 2006—InterSystems Corporation today announced the winners of its 2006 Ensemble Innovator Awards competition. The $5000 awards, which were launched this year, recognize original and creative use of InterSystems' Ensemble universal integration platform in building outstanding new systems.
The world's leading database provider in healthcare, InterSystems develops and markets the CACHÉ post-relational database and the Ensemble universal integration platform. The 2006 Ensemble awards were introduced at InterSystems' DEVCON 2006 conference.
Jess Thompson, Research Vice President of Stamford, Conn.-based Gartner, Inc. developed the evaluation criteria for the awards and independently judged the entries. He brought to bear more than 25 years of IT industry experience in specifying criteria that included integration complexity, system size, diversity of integration styles, business value, time-to-market and innovation.
FORUM Solutions, headquartered in Indianapolis, received the first place Innovator Award for its TAPS Enterprise Lending application. TAPS is an automated loan origination, decision and application processing system targeted for credit unions and banks. It uses a wide range of Ensemble features to enable rapid tailoring and integration of the application with existing financial systems and third-party applications, and to speed the processing of direct and indirect loan applications. TAPS makes heavy use of Ensemble business rules and business intelligence capability to automate the decision-making process on consumer loan applications that enter TAPS via a Web portal used by auto dealers nationwide, as well as for internal loans. Typical turnaround time for an auto loan decision using Ensemble-based TAPS is seven seconds, providing FORUM Solutions' clients with major competitive advantages. The award was accepted by Cameron Minges, FORUM Solutions Chief Operating Officer.
Malvern, Penn.-based Maestro Projects Group was named as the second place winner for its Maestro credit union banking services system. Maestro consists of standardized components that can be easily customized, using Ensemble business rules, to meet the requirements of individual credit unions. Ensemble-based Maestro connects a wide range of applications and automates business processes throughout the credit union enterprise, dramatically increasing employee productivity and delivering substantial cost savings. Anne Ballard, Maestro General Manager, and Joe Rizzo, Director, Operations submitted the application and Ballard accepted the award.
In third place was Vimercate Hospital Trust of Milan, Italy, for its Vimercate electronic health record (EHR) application. The Vimercate EHR integrates departmental applications for seven hospitals by pulling and consolidating patient data from existing systems. Additional information streams into the system from smart cards issued to each citizen and from a central data repository for the Lombardy region where member hospitals and clinics are located. Leveraging Ensemble functionality to achieve true enterprise information integration, the Vimercate EHR has enabled measurable error reduction, improved data control and increased productivity throughout the hospital network. Giovanni DelGrossi, Technical Director, accepted the award.
"InterSystems congratulates the winners of the Ensemble Innovator Awards and all of the developers who submitted applications that demonstrated a truly remarkable level of application innovation," said Trevor Matz, InterSystems Managing Director, Application Integration.


text:
Q: UDF - How to turn a string that contains a path, workbook name, worksheet name and cell reference into a formula? I'm trying to write a UDF that will turn a string that contains path, workbook name, worksheet name and a cell reference into a formula so I can easily return values from other workbooks. For example, my string looks like:
='C:\FolderAlfa\SubfolderBeta\[Book1.xlsx]Sheet2'!$D$4

I tried Application.Evaluate(string) and ExecuteExcel4Macro(string) methods but none of them are working.
I would appreciate some help!

A: Based on what I found here it is possible to change cells with an UDF and insert a formula.
It is a little bit cumbersome (maybe there is someone out there who can improve it) but it works. You also need to do a recalculation what you can't trigger from the function getValue and the sub addFormula. You must put it somewhere else. The parameter rg is the cell where you want to put the formula. Make sure is is not the cell where you put getValue.
Function getValue(rg As Range, path As String, file As String, sheet As String, ref As String)
    Evaluate "addFormula( " & Chr(34) & rg.Address & Chr(34) & "," & Chr(34) & "'" & path & "[" & file & "]" & sheet & "'!" & ref & Chr(34) & ")"
    getValue = ""
End Function

Sub addFormula(trgAddress As String, myFormula As String)
    Dim trgRg As Range

    Set trgRg = Range(trgAddress)
    trgRg.Formula = "=" & myFormula

End Sub

In the worksheet selection change I added the calculate method. This is for sure not the best way to do it but it shows it is possible.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Me.Calculate
End Sub

And that how you can use it: The function is in D5, the result in E5

redpajama_set_name: RedPajamaStackExchange


Replacing the Front Caster Wheels of your wheelchair can work wonders for making your ride smoother than ever. Casters by Frog Legs have been known to improve the steering capability of your wheelchair which ultimately makes for the smoothest ride possible. Sportaid's prices on premium Casters from Frog Legs are among the best online.
Frog Legs caster wheels at Sportaid are among the most highly adjustable and affordable you will find, and they provide all the vibration absorbtion you expect from the brand while moving around in your wheelchair. Our selection of Frog Legs Casters includes 3" x 1" Frog Leg Epic Aluminum Firm Roll Court Wheelchair Casters, 4" x 1.4" Frog Leg Epic Soft Roll Wheelchair Casters with Aluminum or Composite Hub, Frog Legs Uni-Tine Wheelchair Forks, and many more.
A smooth ride is a safe ride when you count on the quality of Sportaid's collection of Frog Legs Casters. Check them out below or feel free to call 1-800-743-7203 for help. You'll be glad you did! Select from the top manufacturers and save big with Sportaid.com's everyday low prices.
Sportaid customers report savings up to 25% on Frog Legs Wheelchair Front Casters compared to the competition!
We guarantee satisfaction for new customers just like we do for the customers who have been with us for a while. We are prepared to beat any competitor's advertised price, and after more than 25 years in the business helping people find Wheelchair Frog Legs Casters at the lowest prices, we are still considered the industry leader! We carry a large selection of wheelchair cushions, wheelchair parts, and accessories. Our customer service staff has over 50 years of experience, plus over 90 years of combined wheelchair use experience. We look forward to working with you!


text:
The 1958 NBA All Star Game was the eighth NBA All-Star Game.

Roster

Eastern Conference
Head Coach: Red Auerbach, Boston Celtics

Western Conference
Head Coach: Alex Hannum, St. Louis Hawks

References

National Basketball Association All-Star Game
All-Star Game
Sports competitions in St. Louis
January 1958 sports events in the United States
1950s in St. Louis
1958 in sports in Missouri

redpajama_set_name: RedPajamaWikipedia