Let me preface this report with some background information on myself. As a child, I was diagnosed with ADD and some developmental disorder. I was prescribed Ritalin when I was 7 or 8 and used it tell I was around 10.
The other day I acquired some Ritalin. Two pills, ten MG each. I went home, and insuffalated them. Then I took a shower. During my shower I felt the effects come on slowly. I felt happy, almost silly. When it kicked in I started beat boxing for a second haha.  I felt happy and sociable. But one thing that I really didn't expect was, I didn't feel like it was a stimulant. I felt sleepy and lazy - relaxed and at peace. I even felt hungry. Really made me wonder. I felt a urge to socialize. I grabbed my phone and I called my friends and I said something along the lines of 'Man I feel so good!'. After that I popped on my iPod and listened to some music and relaxed for a while. Sounded great. I even layed down for a bit and listened to music.
The whole experience lasted around two hours in its entirety. During the come down, I felt a strong urge to do more (unfortunately I didn't have any more :( ) The night after I took it, and the day after, I experienced some eye twitching. It didn't happen often, like twice a hour. In general, I say I had a excellent time. I felt better than I have in months. I can't wait to do this again :)
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


+
-
Reset
The weather in
is currently
degrees.
Power saving mode is
on
PSM on
PSM off
Check your energy usage
Check


- Michela Taufer, University of Tennessee, Knoxville (chair)
- Kathryn Mohror, Lawrence Livermore National Laboratory (secretary)
- Abhinav Bhatele, University of Maryland
- Taisuke Boku, University of Tsukuba
- Sunita Chandrasekaran, University of Delaware
- Toni Cortes, Barcelona Supercomputing Center
- Satoshi Matsuoka, Tokyo Institute of Technology
- Scott Pakin, Los Alamos National Laboratory
- Antonio Pena, Barcelona Supercomputing Center
- James Lin, Shanghai Jiao Tong University
- Min Si, Facebook
- Bronis de Supinski, Lawrence Livermore National Laboratory
- Felix Wolf, TU Darmstadt
- Seetharami Seelam, IBM TJ Watson
- Ewa Deelman, University of Southern California
- Bogdan Nicolae, Argonne National Laboratory


Elizabeth and Hector both love to collect hats.
Drag each expression to the category that correctly describes whether the expression does or does not equal the total number of hats.


I'm a Software Craftsperson
Introduction
My name is Kelum Priyadarshana/e.Born and raised in a beauitiful city Matara, Sri Lanka. Here I'm mentioning you little bit about my background, interests, achievements and my goals.
Background
I was born in a small village near to Matara Town. After a year at primary school and then 3 years at my village's school, my parents entered me to a school at town.A turning point of my life, I was risen like bright star. In each term of each grade, upto grade 9, I finished my postion by sitting among first three seats with top scores.
With few ups and downs passed ordinary level exams then finished high school education with Advance Level in Maths stream(Physics, Chemistry and Mathematics) with flying colors. Because of that, I selected for Well Reputed State University for Bachelors Degree.
Interests
- Research and Development
- Software Engineering
- Analytical Thinking
- Highly Organize work
- Nature
- Photography
- Cricket
- Swimming/Diving
- Hiking/Traveling
- Buddhisum
- Choclatez
- Ceylon Tea
- Peanuts
Achievements
- Winners - Amazon aws Cloud Sprint Hackathon 2017
- Finalist : WSO2 Hackathon 2014
- IEEE Xtreme Competition World Rank 218
- Advanced Level in Mathematics
- Grade V Examination
- Among First three ranks in Grade 3 to Gade 9 in a row
Goals
I hope to keep good outcomes from everthing that I'm experiencing. Three years from now, I want to become a Technical Lead in IT project, and Most Valuble/Reputable Dev.
Hire Me Resume


Income Tax Sections
EmployeeId
:
(or) EmployeeName
:
Search
Employee Details
Form 16
Financial Year
Preview
Email
Save as PDF
Nothing found to display


| < Day Day Up > |
Matching Specific Character TypesThus far, you have seen how to match specific characters, any characters (using .), one of a set of characters (using [ and ]), and how to negate matches (using ^). Sets of characters (matching one of a set) is the most common form of matching, and special metacharacters can be used in lieu of commonly used sets. These metacharacters are said to match classes of characters. Class metacharacters are never actually needed (you can always enumerate the characters to match or use ranges), but you will undoubtedly find them to be incredibly useful. Note
Matching Digits (and Nondigits)As you learned in Lesson 3, [0-9] is a shortcut for [0123456789] and is used to match any digit. To match anything other than a digit, the set can be negated as [^0-9]. Table 4.2 lists the class shortcuts for digits and nondigits.
To demonstrate the use of these metacharacters, let's revisit a prior example: var myArray = new Array(); ... if (myArray[0] == 0) { ... } myArray\[\d\]
var myArray = new Array();
...
if (myArray[0] == 0) {
...
}
\[ matches [, \d matches any single digit, and \] matches ], so that myArray\[\d\] matches myArray[0]. myArray\[\d\] is shorthand for myArray\[0-9\], which is shorthand for myArray\[0123456789\]. This regular expression would also have matched myArray[1], myArray[2], and so on (but not myArray[10]). Tip
Caution Matching Alphanumeric Characters (and Nonalphanumeric Characters)Another frequently used set is all the alphanumeric characters, A through Z (in uppercase and lowercase), the digits, and the underscore (often used in file and directory names, application variable names, database object names, and more). Table 4.3 lists the class shortcuts for alphanumeric characters and nonalphanumeric characters.
The following example is an excerpt from a database containing records with U.S. ZIP codes and Canadian postal codes: 11213 A1C2E3 48075 48237 M1B4F2 90046 H1H2H2 \w\d\w\d\w\d 11213 A1C2E3 48075 48237 M1B4F2 90046 H1H2H2 The pattern used here combines \w and \d metacharacters to retrieve only the Canadian postal codes. Note Matching Whitespace (and Nonwhitespace)The final class you should look at is the whitespace class. Earlier in this lesson, you learned the metacharacters for specific whitespace characters. Table 4.4 lists the class shortcuts for all whitespace characters.
Note
Specifying Hexadecimal or Octal ValuesAlthough you'll not find yourself needing to refer to specific characters by their octal or hexadecimal value, it is worth noting that this is doable. Using Hexadecimal ValuesHexadecimal (base 16) values may be specified by preceding them with \x. Therefore, \x0A (ASCII character 10, the linefeed character) is functionally equivalent to \n. Using Octal ValuesOctal (base 8) values may be specified as two- or three-digit numbers proceeded by \0. Therefore, \011 (ASCII character 9, the tab character) is functionally equivalent to \t. Note
|
| < Day Day Up > |


Good morning, oh in case i don’t see you, good afternoon, good evening and goodnight. well, then, i confess, it is my intention to commandeer one of these ships, pick up a crew in tortuga, raid, pillage, plunder and otherwise pilfer my weasely black guts out. do you like my...


--- layout: post title: Keepin' It Real date: 2011-06-23 02:09:43.000000000 -04:00 categories: - Keepin' It Real tags: - Home renovations - Keepin' it real - Renovating with kids - Renovations status: publish type: post published: true meta: aktt_notify_twitter: 'no' _edit_last: '1' dsq_thread_id: '1188590872' author: login: cint email<EMAIL_ADDRESS>display_name: Jacinta first_name: Jacinta last_name: '' ---
- Keepin' It Real captures the true essence of family life that I know are fleeting, keeping this mama grounded -
As we are in the midst of renovating, different rooms get reassigned their use. The playroom is currently also Scarlett's bedroom.
It seems a bed in the middle of the room makes for fun play and jumping on and off of course. So while the playroom is in shambles, Scarlett's room is getting its finishing touches before Greg starts on the floating floors. The house is definitely a work in progress.
I hope if you have renovated with kids, it has been a mostly fun journey! Jacinta x


Syn is used to simulate user actions. It creates synthetic events and
performs their default behaviors.
Basic Use
The following clicks an input element with id='description'
and then types 'Hello World'.
Syn.click({},'description')
.type("Hello World")
User Actions and Events
Syn is typically used to simulate user actions as opposed to triggering events. Typing characters
is an example of a user action. The keypress that represents an 'a'
character being typed is an example of an event.
While triggering events is supported, it's much more useful to simulate actual user behavior. The
following actions are supported by Syn:
[Syn.prototype.click click] - a mousedown, focus, mouseup, and click.
[Syn.prototype.dblclick dblclick] - two click! events followed by a dblclick.
[Syn.prototype.key key] - types a single character (keydown, keypress, keyup).
[Syn.prototype.type type] - types multiple characters into an element.
[Syn.prototype.move move] - moves the mouse from one position to another (triggering mouseover / mouseouts).
[Syn.prototype.drag drag] - a mousedown, followed by mousemoves, and a mouseup.
All actions run asynchronously.
Click on the links above for more
information on how to use the specific action.
Asynchronous Callbacks
Actions don't complete immediately. This is almost
entirely because focus()
doesn't run immediately in IE.
If you provide a callback function to Syn, it will
be called after the action is completed.
The following checks that "Hello World" was entered correctly:
Every browser has very different rules for dispatching key events.
As there is no way to feature detect how a browser handles key events,
synthetic uses a description of how the browser behaves generated
by a recording application.
If you want to support a browser not currently supported, you can
record that browser's key event description and add it to
Syn.key.browsers by it's navigator agent.
Syn fully supports IE 6+, FF 3+, Chrome, Safari, Opera 10+.
With FF 1+, drag / move events are only partially supported. They will
not trigger mouseover / mouseout events.
Safari crashes when a mousedown is triggered on a select. Syn will not
create this event.
Contributing to Syn
Have we missed something? We happily accept patches. The following are
important objects and properties of Syn:
Syn.create - contains methods to setup, convert options, and create an event of a specific type.
Syn.defaults - default behavior by event type (except for keys).
Syn.key.defaults - default behavior by key.
Syn.keycodes - supported keys you can type.
Roll Your Own Functional Test Framework
Syn is really the foundation of JavaScriptMVC's functional testing framework - FuncUnit.
But, we've purposely made Syn work without any dependencies in the hopes that other frameworks or
testing solutions can use it as well.
Syn is used to simulate user actions. It creates synthetic events and performs their default behaviors.
Basic Use
The following clicks an input element with
id='description'
and then types'Hello World'
.User Actions and Events
Syn is typically used to simulate user actions as opposed to triggering events. Typing characters is an example of a user action. The keypress that represents an
'a'
character being typed is an example of an event.While triggering events is supported, it's much more useful to simulate actual user behavior. The following actions are supported by Syn:
All actions run asynchronously. Click on the links above for more information on how to use the specific action.[Syn.prototype.click click]
- a mousedown, focus, mouseup, and click.[Syn.prototype.dblclick dblclick]
- twoclick!
events followed by adblclick
.[Syn.prototype.key key]
- types a single character (keydown, keypress, keyup).[Syn.prototype.type type]
- types multiple characters into an element.[Syn.prototype.move move]
- moves the mouse from one position to another (triggering mouseover / mouseouts).[Syn.prototype.drag drag]
- a mousedown, followed by mousemoves, and a mouseup.Asynchronous Callbacks
Actions don't complete immediately. This is almost entirely becausefocus()
doesn't run immediately in IE. If you provide a callback function to Syn, it will be called after the action is completed.The following checks that "Hello World" was entered correctly:
Asynchronous Chaining
You might have noticed the [Syn.prototype.then then] method. It provides chaining so you can do a sequence of events with a single (final) callback.
If an element isn't provided to then, it uses the previous Syn's element.
The following does a lot of stuff before checking the result:Key Event Recording
Every browser has very different rules for dispatching key events. As there is no way to feature detect how a browser handles key events, synthetic uses a description of how the browser behaves generated by a recording application.
If you want to support a browser not currently supported, you can record that browser's key event description and add it to
Syn.key.browsers
by it's navigator agent.Limitations
Syn fully supports IE 6+, FF 3+, Chrome, Safari, Opera 10+. With FF 1+, drag / move events are only partially supported. They will not trigger mouseover / mouseout events.Safari crashes when a mousedown is triggered on a select. Syn will not create this event.
Contributing to Syn
Have we missed something? We happily accept patches. The following are important objects and properties of Syn:
Syn.create
- contains methods to setup, convert options, and create an event of a specific type.Syn.defaults
- default behavior by event type (except for keys).Syn.key.defaults
- default behavior by key.Syn.keycodes
- supported keys you can type.Roll Your Own Functional Test Framework
Syn is really the foundation of JavaScriptMVC's functional testing framework - FuncUnit. But, we've purposely made Syn work without any dependencies in the hopes that other frameworks or testing solutions can use it as well.
Creates a synthetic event on the element.


815_EonYang.py
from math import degrees, atan2
class Solution:
def visiblePoints(self, points: List[List[int]], angle: int, location: List[int]) -> int:
x0, y0 = location
same_location = sum([1 if point == location else 0 for point in points])
D = [degrees(atan2(y-y0, x-x0)) for x, y in points if [x, y] != location]
D += [d + 360 for d in D]
D.sort()
# print(D)
l = r = 0
max_in_view = 0
while r < len(D):
# might be <=. Is the angle inclusive?
while D[r] - D[l] > angle and l < r:
l += 1
max_in_view = max(max_in_view, r - l + 1)
r += 1
return same_location + max_in_view


| L(5) |
| userId |
1 |
| firstName |
Krish |
| lastName |
Lee |
| phoneNumber |
123456 |
| emailAddress |
<EMAIL_ADDRESS>|
| userId |
2 |
| firstName |
racks |
| lastName |
jacson |
| phoneNumber |
123456 |
| emailAddress |
<EMAIL_ADDRESS>|
| userId |
3 |
| firstName |
denial |
| lastName |
roast |
| phoneNumber |
33333333 |
| emailAddress |
<EMAIL_ADDRESS>|
| userId |
4 |
| firstName |
devid |
| lastName |
neo |
| phoneNumber |
222222222 |
| emailAddress |
<EMAIL_ADDRESS>|
| userId |
5 |
| firstName |
jone |
| lastName |
mac |
| phoneNumber |
111111111 |
| emailAddress |
<EMAIL_ADDRESS>|


Let me tell you a few things ...
I am Suraj Bokde, pursuing B.E (INFORMATION TECHNOLOGY) in Yeshwantrao Chavan College of Engineering (YCCE), Nagpur. I am Tech enthusiast Loves Web Development , Competitive Programmer , Open Source Contribution and Exploring new technologies.
My stack mainly includes Front-end web Development - HTML, CSS, BOOTSTRAP, JAVASCRIPT, PHP, REACTJS and I have also worked with JAVA, C, C++ ,PYTHON.
Tags
Nature_beauty ( Web App ) is for organisation to spread awareness about environment and Nature .
Tags
Web-development-Resource contains tips ,tricks ,hacks ,cheat-sheet ,roadmap ,resources for web development
Tags
Snake_game is Web Game built using canvas Html ,css ,JS ,Bootstrap .
Tags
This Project is my personal Portfolio Website ,made by using Bootstrap


---
layout: standard_page
title: ACI Semantic Model
---
A great deal of information is produced and consumed by many parties for every flight movement that occurs.
Information is exchanged between business partners (B2B), between businesses and individuals (B2C) and between businesses and government agencies (B2G).
The ACI ACRIS (Aviation Community Recommended Information Services) initiative was created to improve the quality of information being exchanged by
providing standards such as industry, information and technology standards.
Standardising Aviation services facilitates integration and semantic inter-operability between aviation systems, whether in airport,
airline, air traffic management, or third party vendors. Airport business performance depends on seamless and meaningful information exchange.
Effective communication requires a common business vocabulary, with well defined terminology.
This common vocabulary is the foundation of ACI’s Semantic Model.
Knowledge is held about airlines, passengers, assets and other core factors in the Airport.
These business concepts represent the smallest grain of business knowledge.
The terms used to describe these concepts form the business vocabulary.
The Semantic Model defines the concepts, their characteristics, the relationships between them, and how they behave.
This provides a framework for semantic inter-operability within which different applications can cooperate with each other.
The applications may be within, or between, businesses e.g. an Airport sharing gate information with an Airline. The model contains four layers: the business language context layer, the knowledge layer, the data
element library of re-usable components, and the physical (technology) layer.
Information artefacts can be derived directly from the model.
These include for example, XSDs and JSON schemas, REST APIs and database scripts. Rockport is an active member of the ACI ACRIS working group that is responsible for the definition of
standards for information exchange. We have been heavily involved in the development of the ACRIS Semantic Model and
have extensive experience using the Sparx Systems Enterprise Architect tool.
Please contact us to find out how to benefit from this initiative. It has never been more important for an airport to base its decisions on trusted and reliable information.
The ACRIS Semantic Model is a powerful tool to enable airports get easy access to timely and consistent information,
both from internal and external sources. As the world leading experts on the ACRIS Semantic Model, Rockport Software is uniquely placed to help
airports and their partners to obtain the substantial benefits that the Model provides. For example to reduce costs,
reduce carbon footprint, improve asset usage, and deliver solutions more quickly than ever. We offer formal and bespoke services to suit the needs of organisations of any size: A number of information projects based on the Semantic Model have either been completed or are underway. These include: Please contact Rockport to find out how to get involved with, and benefit from, these initiatives.
In 2019, the United States Senate mandated that all US airports must provide travellers with
consistent and comparable information on checkpoint wait times.
The ACRIS working group established the Passenger Queue Measurement project to develop an open API specification
that could be used by airports worldwide, based on the ACRIS Semantic Model.
The wait times API integrates passenger queue wait times system interfaces from each airport to provide a
single access point for information from all participating airports.
The use of the ACRIS Semantic Model ensures that the meaning and understanding of information sourced from
multiple airports and system providers is consistent and comparable. The current version of the Semantic Model is v2.7. The package of Semantic Model XSDs is currently published as v1.0.
These services include: Aircraft Movement, Bag Item, Equipment, Facility, IRVR, Passenger Transfer, Planning, Resource Usage, SMGCS, ULD. The ACRIS Semantic Model is hosted on Rockport's cloud platform on behalf of ACI.
Requests for access to the Semantic Model are invited from anyone wishing to participate in ACI information projects. Please contact us by email to submit your request to obtain access to the ACI Semantic Model.
Note that requests for access are subject to review and approval by ACI itself.ACRIS Semantic Model
Rockport Software provides modelling expertise, hosting and maintenance services for the ACI ACRIS Semantic Model.
ACRIS Semantic Model
Rockport Software - How Can We Help You?
Email Rockport
Visit ACI World ACRIS Website
Visit ACRIS.AERO website
The Semantic Model in Action
Example Usage - Passenger Wait Times
Current Version
How Can I Access the Semantic Model?


Running Jekyll on MacOS High Sierra
So it was time to show my blog a little affection – you know, a little housekeeping involving updating development dependencies and other stuff like checking that build commands still run as expected.
Which they didn't. Well, for the most part they did, but Jekyll refused to play nice with me. I got this system message telling me Ruby wasn't really playing the game:
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/
bin/ruby: bad interpreter: No such file or directory
A quick search resulted in posts like this, and after trying some ruby magic I stumbled on Nokigiri which refused to play at all, and so I ended up on this post.
I had no luck with all those tricks, and I can't say I understand everything that's going on under the hood of the Terminal. But what I did understand from my research was that when I updated MacOS to High Sierra, the Ruby version was also updated to version 2.3, but Jekyll still tried to reference Ruby version 2.0.
So eventually, I found this post on Stack Overflow, where a comment offered the simplest of solutions.
Uninstall Jekyll, and install it again. That easy, huh?
gem uninstall Jekyll
gem install Jekyll
Yeah, that easy. It worked, problem solved. Move on.


You can download Informix Dynamic Server Express Edition 11.5 Trial for Linux and Windows.
Database ClientThere’s a database client SDK available, but I couldn’t get the demo client working.
I used SQuirreL SQL Client Version 2.6.8 after installing the Informix JDBC drivers (“emerge dev-java/jdbc-informix” on Gentoo).Logging in from command line
If you get local admin rights on a Windows box and have a GUI logon:
Click: Start | All Programs | IBM Informix Dynamic Server 11.50 | someservername. This will give you a command prompt with various Environment variables set properly.
Run dbaccess.exe from your command prompt. This will bring up a text-based GUI that allows you to browse databases.
The following were set on my test system. This may help if you get command line access, but can’t get a GUI – you’ll need to change “testservername”:
set INFORMIXDIR=C:PROGRA~1IBMIBMINF~111.50
set INFORMIXSERVER=testservername
set ONCONFIG=ONCONFIG.testservername
set PATH=C:PROGRA~1IBMIBMINF~111.50bin;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:PROGRA~1ibmgsk7bin;C:PROGRA~1ibmgsk7lib;C:Program FilesIBMInformixClien-SDKbin;C:Program Filesibmgsk7bin;C:Program Filesibmgsk7lib
set CLASSPATH=C:PROGRA~1IBMIBMINF~111.50extendkrakatoakrakatoa.jar;C:PROGRA~1IBMIBMINF~111.50xtendkrakatoajdbc.jar;
set DBTEMP=C:PROGRA~1IBMIBMINF~111.50infxtmp
set CLIENT_LOCALE=EN_US.CP1252
set DB_LOCALE=EN_US.8859-1
set SERVER_LOCALE=EN_US.CP1252
set DBLANG=EN_US.CP1252
mode con codepage select=1252
Identifying on the network
My default installation listened on two TCP ports: 9088 and 9099. When I created a new “server name”, this listened on 1526/TCP by default.


Home
(current)
Login
Register
Name
Email
Password
IDNumber
Date of Birth
PhoneNumber
Address
Register


Contextual Bandits¶
This is the documentation page for the python package contextualbandits. For more details, see the project’s home page:
Getting started¶
You can find user guides with detailed examples in the following links:
Online Contextual Bandits¶
-
class
contextualbandits.online.
ActiveExplorer
(nchoices, C=None, explore_prob=0.15, decay=0.9997, beta_prior='auto')¶ Bases:
object
Active Explorer
Logistic Regression which selects a proportion of actions according to an active learning heuristic based on gradient.
Note
Here, for the predictions that are made according to an active learning heuristic (these are selected at random, just like in Epsilon-Greedy), the guiding heuristic is the gradient that the observation, having either label (either weighted by the estimted probability, or taking the maximum or minimum), would produce on each model that predicts a class, given the current coefficients for that model.
Parameters: - nchoices (int) – Number of arms/labels to choose from.
- C (float) – Inverse of the regularization parameter for Logistic regression. For more details see sklearn.linear_model.LogisticRegression.
- explore_prob (float (0,1)) – Probability of selecting an action according to active learning criteria.
- decay (float (0,1)) – After each prediction, the probability of selecting an arm according to active learning criteria is set to p = p*decay
- beta_prior (str ‘auto’, None, or tuple ((a,b), n)) – If not None, when there are less than ‘n’ positive sampless from a class (actions from that arm that resulted in a reward), it will predict the score for that class as a random number drawn from a beta distribution with the prior specified by ‘a’ and ‘b’. If set to auto, will be calculated as: beta_prior = ((3/nchoices,4), 1)
-
fit
(X, a, r)¶ Fits the base algorithm (one per class) to partially labeled data with actions chosen by this same policy.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
Returns: self – Copy of this same object
Return type: obj
-
predict
(X, exploit=False, gradient_calc='weighted')¶ Selects actions according to this policy for new data.
Parameters: - X (array (n_samples, n_features)) – New observations for which to choose an action according to this policy.
- exploit (bool) – Whether to make a prediction according to the policy, or to just choose the arm with the highest expected reward according to current models.
- gradient_calc (str, one of ‘weighted’, ‘max’ or ‘min’) – How to calculate the gradient that an observation would have on the loss function for each classifier, given that it could be either class (positive or negative) for the classifier that predicts each arm. If weighted, they are weighted by the same probability estimates from the base algorithm.
Returns: pred – Actions chosen by the policy.
Return type: array (n_samples,)
-
class
contextualbandits.online.
AdaptiveGreedy
(base_algorithm, nchoices, window_size=500, percentile=30, decay=0.9998, decay_type='threshold', initial_thr='auto', fixed_thr=False, beta_prior='auto')¶ Bases:
object
Adaptive Greedy
Takes the action with highest estimated reward, unless that estimation falls below a certain moving threshold, in which case it takes a random action.
Note
The threshold for the reward probabilities can be set to a hard-coded number, or to be calculated dynamically by keeping track of the predictions it makes, and taking a fixed percentile of that distribution to be the threshold. In the second case, these are calculated in separate batches rather than in a sliding window.
The original idea was taken from the paper in the references and adapted to the contextual bandits setting like this.
Parameters: base_algorithm (obj) – Base binary classifier for which each sample for each class will be fit.
nchoices (int) – Number of arms/labels to choose from.
window_size (int) – Number of predictions after which the threshold will be updated to the desired percentile. Ignored when passing fixed_thr=False
percentile (int [0,100]) – Percentile of the predictions sample to set as threshold, below which actions are random. Ignored in fixed threshold mode.
decay (float (0,1)) –
- After each prediction, either the threshold or the percentile gets adjusted to:
val_t+1 = val_t*decay
Ignored when pasing fixed_thr=True.
decay_type (str, either ‘percentile’ or ‘threshold’) – Whether to decay the threshold itself or the percentile of the predictions to take after each prediction. If set to ‘threshold’ and fixed_thr=False, the threshold will be recalculated to the same percentile the next time it is updated, but with the latest predictions. Ignored when passing fixed_thr=True.
initial_thr (str ‘autho’ or float (0,1)) – Initial threshold for the prediction below which a random action is taken. If set to ‘auto’, will be calculated as initial_thr = 1.5/nchoices
fixed_thr (bool) – Whether the threshold is to be kept fixed, or updated to a percentile after N predictions.
beta_prior (str ‘auto’, None, or tuple ((a,b), n)) – If not None, when there are less than ‘n’ positive sampless from a class (actions from that arm that resulted in a reward), it will predict the score for that class as a random number drawn from a beta distribution with the prior specified by ‘a’ and ‘b’. If set to auto, will be calculated as: beta_prior = ((3/nchoices,4), 1)
References
[1] Mortal multi-armed bandits (2009)
-
decision_function
(X)¶ Get the estimated probability for each arm from the classifier that predicts it.
Note
This is quite different from the decision_function of the other policies, as it doesn’t follow the policy in assigning random choices with some probability. A sigmoid function is applyed to the decision_function of the classifier if it doesn’t have a predict_proba method.
Parameters: X (array (n_samples, n_features)) – Data for which to obtain decision function scores for each arm. Returns: scores – Scores following this policy for each arm. Return type: array (n_samples, n_choices)
-
fit
(X, a, r)¶ Fits the base algorithm (one per class) to partially labeled data.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
Returns: self – Copy of this same object
Return type: obj
-
predict
(X, exploit=False)¶ Selects actions according to this policy for new data.
Parameters: - X (array (n_samples, n_features)) – New observations for which to choose an action according to this policy.
- exploit (bool) – Whether to make a prediction according to the policy, or to just choose the arm with the highest expected reward according to current models.
Returns: pred – Actions chosen by the policy.
Return type: array (n_samples,)
-
class
contextualbandits.online.
BayesianTS
(nchoices, method='advi', beta_prior=((1, 1), 3))¶ Bases:
object
Bayesian Thompson Sampling
Performs Thompson Sampling by sampling a set of Logistic Regression coefficients from each class, then predicting the class with highest estimate. .. note:
The implementation here uses PyMC3's GLM formula with default parameters and ADVI. You might want to try building a different one yourself from PyMC3 or Edward. The method as implemented here is not scalable to high-dimensional or big datasets.
Parameters: - nchoices (int) – Number of arms/labels to choose from.
- method (str, either ‘advi’ or ‘nuts’) – Method used to sample coefficients (see PyMC3’s documentation for mode details).
- beta_prior (None, or tuple ((a,b), n)) – If not None, when there are less than ‘n’ positive sampless from a class (actions from that arm that resulted in a reward), it will predict the score for that class as a random number drawn from a beta distribution with the prior specified by ‘a’ and ‘b’.
References
[1] An empirical evaluation of thompson sampling (2011)
-
decision_function
(X)¶ Get the scores for each arm following this policy’s action-choosing criteria.
Parameters: X (array (n_samples, n_features)) – Data for which to obtain decision function scores for each arm. Returns: scores – Scores following this policy for each arm. Return type: array (n_samples, n_choices)
-
fit
(X, a, r)¶ Samples coefficients for Logistic Regression models from partially-labeled data, with actions chosen by this same policy.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
Returns: self – Copy of this same object
Return type: obj
-
predict
(X, exploit=False)¶ Selects actions according to this policy for new data.
Parameters: - X (array (n_samples, n_features)) – New observations for which to choose an action according to this policy.
- exploit (bool) – Whether to make a prediction according to the policy, or to just choose the arm with the highest expected reward according to current models.
Returns: pred – Actions chosen by the policy.
Return type: array (n_samples,)
-
class
contextualbandits.online.
BayesianUCB
(nchoices, percentile=80, method='advi', nsamples=None, beta_prior=((3, 1), 3))¶ Bases:
object
Bayesian Upper-Confidence Bound
Gets an upper-confidence bound by Bayesian Logistic Regression estimates.
Note
The implementation here uses PyMC3’s GLM formula with default parameters and ADVI. You might want to try building a different one yourself from PyMC3 or Edward. The method as implemented here is not scalable to high-dimensional or big datasets.
Parameters: - nchoices (int) – Number of arms/labels to choose from.
- percentile (int [0,100]) – Percentile of the predictions sample to take
- method (str, either ‘advi’ or ‘nuts’) – Method used to sample coefficients (see PyMC3’s documentation for mode details).
- beta_prior (None, or tuple ((a,b), n)) – If not None, when there are less than ‘n’ positive sampless from a class (actions from that arm that resulted in a reward), it will predict the score for that class as a random number drawn from a beta distribution with the prior specified by ‘a’ and ‘b’.
-
decision_function
(X)¶ Get the scores for each arm following this policy’s action-choosing criteria.
Parameters: X (array (n_samples, n_features)) – Data for which to obtain decision function scores for each arm. Returns: scores – Scores following this policy for each arm. Return type: array (n_samples, n_choices)
-
fit
(X, a, r)¶ Samples Logistic Regression coefficients for partially labeled data with actions chosen by this policy.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
Returns: self – Copy of this same object
Return type: obj
-
predict
(X, exploit=False)¶ Selects actions according to this policy for new data.
Parameters: - X (array (n_samples, n_features)) – New observations for which to choose an action according to this policy.
- exploit (bool) – Whether to make a prediction according to the policy, or to just choose the arm with the highest expected reward according to current models.
Returns: pred – Actions chosen by the policy.
Return type: array (n_samples,)
-
class
contextualbandits.online.
BootstrappedTS
(base_algorithm, nchoices, nsamples=10, beta_prior='auto')¶ Bases:
object
Bootstrapped Thompson Sampling
Performs Thompson Sampling by fitting several models per class on bootstrapped samples, then makes predictions by taking one of them at random for each class.
Parameters: - base_algorithm (obj) – Base binary classifier for which each sample for each class will be fit.
- nchoices (int) – Number of arms/labels to choose from.
- nsamples (int) – Number of bootstrapped samples per class to take.
- beta_prior (str ‘auto’, None, or tuple ((a,b), n)) – If not None, when there are less than ‘n’ positive sampless from a class (actions from that arm that resulted in a reward), it will predict the score for that class as a random number drawn from a beta distribution with the prior specified by ‘a’ and ‘b’. If set to auto, will be calculated as: beta_prior = ((3/nchoices,4), 1)
References
[1] An empirical evaluation of thompson sampling (2011)
-
decision_function
(X)¶ Get the scores for each arm following this policy’s action-choosing criteria.
Parameters: X (array (n_samples, n_features)) – Data for which to obtain decision function scores for each arm. Returns: scores – Scores following this policy for each arm. Return type: array (n_samples, n_choices)
-
fit
(X, a, r)¶ Fits the base algorithm (one per sample per class) to partially labeled data, with the actions having been determined by this same policy.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
Returns: self – Copy of this same object
Return type: obj
-
predict
(X, exploit=False, output_score=False, apply_sigmoid_scores=True)¶ Selects actions according to this policy for new data.
Parameters: - X (array (n_samples, n_features)) – New observations for which to choose an action according to this policy.
- exploit (bool) – Whether to make a prediction according to the policy, or to just choose the arm with the highest expected reward according to current models.
- output_score (bool) – Whether to output the score that this method predicted, in case it is desired to use it with this pakckage’s offpolicy and evaluation modules.
- apply_sigmoid_scores (bool) – If passing output_score=True, whether to apply a sigmoid function to the scores from the decision function of the classifier that predicts each class.
Returns: pred – Actions chosen by the policy. If passing output_score=True, it will be an array with the first column indicating the action and the second one indicating the score that the classifier gave to that class.
Return type: array (n_samples,) or (n_samples, 2)
-
class
contextualbandits.online.
BootstrappedUCB
(base_algorithm, nchoices, nsamples=10, percentile=80, beta_prior='auto')¶ Bases:
object
-
decision_function
(X)¶ Get the scores for each arm following this policy’s action-choosing criteria.
Parameters: X (array (n_samples, n_features)) – Data for which to obtain decision function scores for each arm. Returns: scores – Scores following this policy for each arm. Return type: array (n_samples, n_choices)
-
fit
(X, a, r)¶ Fits the base algorithm (one per sample per class) to partially labeled data, with the actions having been determined by this same policy.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
Returns: self – Copy of this same object
Return type: obj
-
predict
(X, exploit=False, output_score=False, apply_sigmoid_scores=True)¶ Selects actions according to this policy for new data.
Parameters: - X (array (n_samples, n_features)) – New observations for which to choose an action according to this policy.
- exploit (bool) – Whether to make a prediction according to the policy, or to just choose the arm with the highest expected reward according to current models.
- output_score (bool) – Whether to output the score that this method predicted, in case it is desired to use it with this pakckage’s offpolicy and evaluation modules.
- apply_sigmoid_scores (bool) – If passing output_score=True, whether to apply a sigmoid function to the scores from the decision function of the classifier that predicts each class.
Returns: pred – Actions chosen by the policy. If passing output_score=True, it will be an array with the first column indicating the action and the second one indicating the score that the classifier gave to that class.
Return type: array (n_samples,) or (n_samples, 2)
-
-
class
contextualbandits.online.
EpsilonGreedy
(base_algorithm, nchoices, explore_prob=0.2, decay=0.9999, beta_prior='auto')¶ Bases:
object
Epsilon Greedy
Takes a random action with probability p, or the action with highest estimated reward with probability 1-p.
Parameters: - base_algorithm (obj) – Base binary classifier for which each sample for each class will be fit.
- nchoices (int) – Number of arms/labels to choose from.
- explore_prob (float (0,1)) – Probability of taking a random action at each round.
- decay (float (0,1)) – After each prediction, the explore probability reduces to p = p*decay
- beta_prior (str ‘auto’, None, or tuple ((a,b), n)) – If not None, when there are less than ‘n’ positive sampless from a class (actions from that arm that resulted in a reward), it will predict the score for that class as a random number drawn from a beta distribution with the prior specified by ‘a’ and ‘b’. If set to auto, will be calculated as: beta_prior = ((3/nchoices,4), 1)
References
[1] The k-armed dueling bandits problem (2010)
-
decision_function
(X)¶ Get the decision function for each arm from the classifier that predicts it.
Note
This is quite different from the decision_function of the other policies, as it doesn’t follow the policy in assigning random choices with some probability.
Parameters: X (array (n_samples, n_features)) – Data for which to obtain decision function scores for each arm. Returns: scores – Scores following this policy for each arm. Return type: array (n_samples, n_choices)
-
fit
(X, a, r)¶ Fits the base algorithm (one per class) to partially labeled data.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
Returns: self – Copy of this same object
Return type: obj
-
predict
(X, exploit=False, output_score=False, apply_sigmoid_scores=True)¶ Selects actions according to this policy for new data.
Parameters: - X (array (n_samples, n_features)) – New observations for which to choose an action according to this policy.
- exploit (bool) – Whether to make a prediction according to the policy, or to just choose the arm with the highest expected reward according to current models.
- output_score (bool) – Whether to output the score that this method predicted, in case it is desired to use it with this pakckage’s offpolicy and evaluation modules.
- apply_sigmoid_scores (bool) – If passing output_score=True, whether to apply a sigmoid function to the scores from the decision function of the classifier that predicts each class.
Returns: pred – Actions chosen by the policy. If passing output_score=True, it will be an array with the first column indicating the action and the second one indicating the score that the classifier gave to that class.
Return type: array (n_samples,) or (n_samples, 2)
-
class
contextualbandits.online.
ExploreFirst
(base_algorithm, nchoices, explore_rounds=2500, beta_prior='auto')¶ Bases:
object
Explore First, a.k.a. Explore-Then-Exploit
Selects random actions for the first N predictions, after which it selects the best arm only according to its estimates.
Parameters: - base_algorithm (obj) – Base binary classifier for which each sample for each class will be fit.
- nchoices (int) – Number of arms/labels to choose from.
- explore_rounds (int) – Number of rounds to wait before exploitation mode. Will switch after making N predictions.
- beta_prior (str ‘auto’, None, or tuple ((a,b), n)) – If not None, when there are less than ‘n’ positive sampless from a class (actions from that arm that resulted in a reward), it will predict the score for that class as a random number drawn from a beta distribution with the prior specified by ‘a’ and ‘b’. If set to auto, will be calculated as: beta_prior = ((3/nchoices,4), 1)
References
[1] The k-armed dueling bandits problem (2012)
-
decision_function
(X)¶ Get the decision function for each arm from the classifier that predicts it.
Note
This is quite different from the decision_function of the other policies, as it doesn’t follow the policy in assigning random choices at the beginning with equal probability all.
Parameters: X (array (n_samples, n_features)) – Data for which to obtain decision function scores for each arm. Returns: scores – Scores following this policy for each arm. Return type: array (n_samples, n_choices)
-
fit
(X, a, r)¶ Fits the base algorithm (one per class) to partially labeled data with actions chosen by this same policy.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
Returns: self – Copy of this same object
Return type: obj
-
predict
(X, exploit=False)¶ Selects actions according to this policy for new data.
Parameters: - X (array (n_samples, n_features)) – New observations for which to choose an action according to this policy.
- exploit (bool) – Whether to make a prediction according to the policy, or to just choose the arm with the highest expected reward according to current models.
Returns: pred – Actions chosen by the policy.
Return type: array (n_samples,)
-
class
contextualbandits.online.
LinUCB
(nchoices, alpha=1.0)¶ Bases:
object
Note
The formula described in the paper where this algorithm first appeared had dimensions that didn’t match to an array of predictions. I assumed that the (n x n) matrix that results inside a square root was to be summed by rows.
Parameters: - nchoices (int) – Number of arms/labels to choose from.
- alpha (float) – Parameter to control the upper-confidence bound (more is higher).
References
[1] A contextual-bandit approach to personalized news article recommendation (2010)
-
fit
(X, a, r)¶ ” Fits one linear model for the first time to partially labeled data. Overwrites previously fitted coefficients if there were any. (See partial_fit for adding more data in batches)
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
Returns: self – Copy of this same object
Return type: obj
-
partial_fit
(X, a, r)¶ ” Updates each linear model with a new batch of data with actions chosen by this same policy.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
Returns: self – Copy of this same object
Return type: obj
-
predict
(X, exploit=False)¶ Selects actions according to this policy for new data.
Parameters: - X (array (n_samples, n_features)) – New observations for which to choose an action according to this policy.
- exploit (bool) – Whether to make a prediction according to the policy, or to just choose the arm with the highest expected reward according to current models.
Returns: pred – Actions chosen by the policy.
Return type: array (n_samples,)
-
class
contextualbandits.online.
SeparateClassifiers
(base_algorithm, nchoices, beta_prior=None)¶ Bases:
object
Separate Clasifiers per arm
Fits one classifier per arm using only the data on which that arm was chosen. Predicts as One-Vs-Rest.
- base_algorithm : obj
- Base binary classifier for which each sample for each class will be fit.
- nchoices : int
- Number of arms/labels to choose from.
- beta_prior : str ‘auto’, None, or tuple ((a,b), n)
- If not None, when there are less than ‘n’ positive sampless from a class (actions from that arm that resulted in a reward), it will predict the score for that class as a random number drawn from a beta distribution with the prior specified by ‘a’ and ‘b’. If set to auto, will be calculated as: beta_prior = ((3/nchoices,4), 1)
-
decision_function
(X)¶ Get the scores for each arm following this policy’s action-choosing criteria.
Parameters: X (array (n_samples, n_features)) – Data for which to obtain decision function scores for each arm. Returns: scores – Scores following this policy for each arm. Return type: array (n_samples, n_choices)
-
decision_function_std
(X)¶ Get the predicted probabilities from each arm from the classifier that predicts it, standardized to sum up to 1.
Note
Classifiers are all fit on different data, so the probabilities will not add up to 1.
Parameters: X (array (n_samples, n_features)) – Data for which to obtain decision function scores for each arm. Returns: scores – Scores following this policy for each arm. Return type: array (n_samples, n_choices)
-
fit
(X, a, r)¶ Fits the base algorithm (one per class) to partially labeled data.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
Returns: self – Copy of this same object
Return type: obj
-
predict
(X, exploit=False, output_score=False, apply_sigmoid_scores=True)¶ Selects actions according to this policy for new data.
Parameters: - X (array (n_samples, n_features)) – New observations for which to choose an action according to this policy.
- exploit (bool) – Whether to make a prediction according to the policy, or to just choose the arm with the highest expected reward according to current models.
- output_score (bool) – Whether to output the score that this method predicted, in case it is desired to use it with this pakckage’s offpolicy and evaluation modules.
- apply_sigmoid_scores (bool) – If passing output_score=True, whether to apply a sigmoid function to the scores from the decision function of the classifier that predicts each class.
Returns: pred – Actions chosen by the policy. If passing output_score=True, it will be an array with the first column indicating the action and the second one indicating the score that the classifier gave to that class.
Return type: array (n_samples,) or (n_samples, 2)
-
predict_proba_separate
(X)¶ Get the predicted probabilities from each arm from the classifier that predicts it.
Note
Classifiers are all fit on different data, so the probabilities will not add up to 1.
Parameters: X (array (n_samples, n_features)) – Data for which to obtain decision function scores for each arm. Returns: scores – Scores following this policy for each arm. Return type: array (n_samples, n_choices)
-
class
contextualbandits.online.
SoftmaxExplorer
(base_algorithm, nchoices, beta_prior='auto')¶ Bases:
object
Soft-Max Explorer
Selects an action according to probabilites determined by a softmax transformation on the scores from the decision function that predicts each class.
Note
If the base algorithm has ‘predict_proba’, but no ‘decision_function’, it will calculate the ‘probabilities’ with a simple scaling by sum rather than by a softmax.
Parameters: - base_algorithm (obj) – Base binary classifier for which each sample for each class will be fit.
- nchoices (int) – Number of arms/labels to choose from.
- beta_prior (str ‘auto’, None, or tuple ((a,b), n)) – If not None, when there are less than ‘n’ positive sampless from a class (actions from that arm that resulted in a reward), it will predict the score for that class as a random number drawn from a beta distribution with the prior specified by ‘a’ and ‘b’. If set to auto, will be calculated as: beta_prior = ((3/nchoices,4), 1)
-
decision_function
(X, output_score=False, apply_sigmoid_score=True)¶ Get the scores for each arm following this policy’s action-choosing criteria.
Parameters: X (array (n_samples, n_features)) – Data for which to obtain decision function scores for each arm. Returns: scores – Scores following this policy for each arm. Return type: array (n_samples, n_choices)
-
fit
(X, a, r)¶ Fits the base algorithm (one per class) to partially labeled data.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
Returns: self – Copy of this same object
Return type: obj
-
predict
(X, exploit=False, output_score=False)¶ Selects actions according to this policy for new data.
Parameters: - X (array (n_samples, n_features)) – New observations for which to choose an action according to this policy.
- exploit (bool) – Whether to make a prediction according to the policy, or to just choose the arm with the highest expected reward according to current models.
- output_score (bool) – Whether to output the score that this method predicted, in case it is desired to use it with this pakckage’s offpolicy and evaluation modules.
Returns: pred – Actions chosen by the policy. If passing output_score=True, it will be an array with the first column indicating the action and the second one indicating the score that the classifier gave to that class.
Return type: array (n_samples,) or (n_samples, 2)
Off-policy learning¶
-
class
contextualbandits.offpolicy.
DoublyRobustEstimator
(base_algorithm, reward_estimator, nchoices, method='rovr', handle_invalid=True, c=None, pmin=1e-05)¶ Bases:
object
Doubly-Robust Estimator
Estimates the expected reward for each arm, applies a correction for the actions that were chosen, and converts the problem to const-sensitive classification, on which the base algorithm is then fit.
This technique converts the problem into a cost-sensitive classification problem by calculating a matrix of expected rewards and turning it into costs. The base algorithm is then fit to this data, using either the Weighted All-Pairs approach, which requires a binary classifier with sample weights as base algorithm, or the Regression One-Vs-Rest approach, which requires a regressor as base algorithm.
In the Weighted All-Pairs approach, this technique will fail if there are actions that were never taken by the exploration policy, as it cannot construct a model for them.
The expected rewards are estimated with the imputer algorithm passed here, which should output a number in the range [0,1].
This technique is meant for the case of contiunous rewards in the [0,1] interval, but here it is used for the case of discrete rewards {0,1}, under which it performs poorly. It is not recommended to use, but provided for comparison purposes.
This method requires to form reward estimates of all arms for each observation. In order to do so, you can either provide estimates as an array (see Parameters), or pass a model.
One method to obtain reward estimates is to fit a model to the data and use its predictions as reward estimates. You can do so by passing an object of class contextualbandits.online.SeparateClassifiers which should be already fitted, or by passing a classifier with a ‘predict_proba’ method, which will be put into a ‘SeparateClassifiers’
object and fit to the same data passed to this function to obtain reward estimates.The estimates can make invalid predictions if there are some arms for which every time they were chosen they resulted in a reward, or never resulted in a reward. In such cases, this function includes the option to impute the “predictions” for them (which would otherwise always be exactly zero or one regardless of the context) by replacing them with random numbers ~Beta(3,1) or ~Beta(1,3) for the cases of always good and always bad.
This is just a wild idea though, and doesn’t guarantee reasonable results in such siutation.
Note that, if you are using the ‘SeparateClassifiers’ class from the online module in this same package, it comes with a method ‘predict_proba_separate’ that can be used to get reward estimates. It still can suffer from the same problem of always-one and always-zero predictions though.
Parameters: base_algorithm (obj) – Base algorithm to be used for cost-sensitive classification.
reward_estimator (obj or array (n_samples, n_choices)) –
- One of the following:
- An array with the first column corresponding to the reward estimates for the action chosen by the new policy, and the second column corresponding to the reward estimates for the action chosen in the data (see Note for details).
- An already-fit object of class ‘contextualbandits.online.SeparateClassifiers’, which will be used to make predictions on the actions chosen and the actions that the new policy would choose.
- A classifier with a ‘predict_proba’ method, which will be fit to the same test data passed here in order to obtain reward estimates (see Note 2 for details).
nchoices (int) – Number of arms/labels to choose from. Only used when passing a classifier object to ‘reward_estimator’.
method (str, either ‘rovr’ or ‘wap’) – Whether to use Regression One-Vs-Rest or Weighted All-Pairs (see Note 1)
handle_invalid (bool) – Whether to replace 0/1 estimated rewards with randomly-generated numbers (see Note 2)
c (None or float) – Constant by which to multiply all scores from the exploration policy.
pmin (None or float) – Scores (from the exploration policy) will be converted to the minimum between pmin and the original estimate.
References
[1] Doubly robust policy evaluation and learning (2011)
[2] Doubly robust policy evaluation and optimization (2014)
-
decision_function
(X)¶ Get score distribution for the arm’s rewards
Note
For details on how this is calculated, see the documentation of the RegressionOneVsRest and WeightedAllPairs classes in the costsensitive package.
Parameters: X (array (n_samples, n_features)) – New observations for which to evaluate actions. Returns: pred – Score assigned to each arm for each observation (see Note). Return type: array (n_samples, n_choices)
-
fit
(X, a, r, p)¶ Fits the Doubly-Robust estimator to partially-labeled data collected from a different policy.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
- p (array (n_samples)) – Reward estimates for the actions that were chosen by the policy.
-
predict
(X)¶ Predict best arm for new data.
Parameters: X (array (n_samples, n_features)) – New observations for which to choose an action. Returns: pred – Actions chosen by this technique. Return type: array (n_samples,)
-
class
contextualbandits.offpolicy.
OffsetTree
(base_algorithm, nchoices, c=None, pmin=1e-05)¶ Bases:
object
Offset Tree
Parameters: - base_algorithm (obj) – Binary classifier to be used for each classification sub-problem in the tree.
- nchoices (int) – Number of arms/labels to choose from.
References
[1] The offset tree for learning with partial labels (2009)
-
fit
(X, a, r, p)¶ Fits the Offset Tree estimator to partially-labeled data collected from a different policy.
Parameters: - X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observations.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
- p (array (n_samples)) – Reward estimates for the actions that were chosen by the policy.
-
predict
(X)¶ Predict best arm for new data.
Note
While in theory, making predictions from this algorithm should be faster than from others, the implementation here uses a Python loop for each observation, which is slow compared to NumPy array lookups, so the predictions will be slower to calculate than those from other algorithms.
Parameters: X (array (n_samples, n_features)) – New observations for which to choose an action. Returns: pred – Actions chosen by this technique. Return type: array (n_samples,)
Policy Evaluation¶
-
contextualbandits.evaluation.
evaluateDoublyRobust
(pred, X, a, r, p, reward_estimator, nchoices=None, handle_invalid=True, c=None, pmin=1e-05)¶ Doubly-Robust Policy Evaluation
Evaluates rewards of arm choices of a policy from data collected by another policy.
Note
This method requires to form reward estimates of the arms that were chosen and of the arms that the policy to be evaluated would choose. In order to do so, you can either provide estimates as an array (see Parameters), or pass a model.
One method to obtain reward estimates is to fit a model to both the training and test data and use its predictions as reward estimates. You can do so by passing an object of class contextualbandits.online.SeparateClassifiers which should be already fitted.
Another method is to fit a model to the test data, in which case you can pass a classifier with a ‘predict_proba’ method here, which will be fit to the same test data passed to this function to obtain reward estimates.
The last two options can suffer from invalid predictions if there are some arms for which every time they were chosen they resulted in a reward, or never resulted in a reward. In such cases, this function includes the option to impute the “predictions” for them (which would otherwise always be exactly zero or one regardless of the context) by replacing them with random numbers ~Beta(3,1) or ~Beta(1,3) for the cases of always good and always bad.
This is just a wild idea though, and doesn’t guarantee reasonable results in such siutation.
Note that, if you are using the ‘SeparateClassifiers’ class from the online module in this same package, it comes with a method ‘predict_proba_separate’ that can be used to get reward estimates. It still can suffer from the same problem of always-one and always-zero predictions though.
Parameters: pred (array (n_samples,)) – Arms that would be chosen by the policy to evaluate.
X (array (n_samples, n_features)) – Matrix of covariates for the available data.
a (array (n_samples), int type) – Arms or actions that were chosen for each observation.
r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
p (array (n_samples)) – Scores or reward estimates from the policy that generated the data for the actions that were chosen by it.
reward_estimator (obj or array (n_samples, 2)) –
- One of the following:
- An array with the first column corresponding to the reward estimates for the action chosen by the new policy, and the second column corresponding to the reward estimates for the action chosen in the data (see Note for details).
- An already-fit object of class ‘contextualbandits.online.SeparateClassifiers’, which will be used to make predictions on the actions chosen and the actions that the new policy would choose.
- A classifier with a ‘predict_proba’ method, which will be fit to the same test data passed here in order to obtain reward estimates (see Note for details).
nchoices (int) – Number of arms/labels to choose from. Only used when passing a classifier object to ‘reward_estimator’.
handle_invalid (bool) – Whether to replace 0/1 estimated rewards with randomly-generated numbers (see Note)
c (None or float) – Constant by which to multiply all scores from the exploration policy.
pmin (None or float) – Scores (from the exploration policy) will be converted to the minimum between pmin and the original estimate.
References
[1] Doubly robust policy evaluation and learning (2011)
-
contextualbandits.evaluation.
evaluateRejectionSampling
(policy, X, a, r, online=False, start_point_online='random', batch_size=10)¶ Evaluate a policy using rejection sampling on test data.
Note
In order for this method to be unbiased, the actions on the test sample must have been collected at random and not according to some other policy.
Parameters: - policy (obj) – Policy to be evaluated (already fitted to data). Must have a ‘predict’ method. If it is an online policy, it must also have a ‘fit’ method.
- X (array (n_samples, n_features)) – Matrix of covariates for the available data.
- a (array (n_samples), int type) – Arms or actions that were chosen for each observation.
- r (array (n_samples), {0,1}) – Rewards that were observed for the chosen actions. Must be binary rewards 0/1.
- online (bool) – Whether this is an online policy to be evaluated by refitting it to the data as it makes choices on it.
- start_point_online (either str ‘random’ or int in [0, n_samples-1]) – Point at which to start evaluating cases in the sample. Only used when passing online=True.
- batch_size (int) – After how many rounds to refit the policy being evaluated. Only used when passing online=True.
Returns: result – Estimated mean reward and number of observations taken.
Return type: tuple (float, int)
References
[1] A contextual-bandit approach to personalized news article recommendation (2010)


There is this subconscious understanding that unnecessary complexity is root of all evil in software development. We have been fiercely ranting about the dreadful experience caused by the dependency hell. We’ve been detracting legacy code as big ball of mud because nobody can honestly understand how it works. Fearlessly, we’ve been shushing our developer mates arguing that they’ve done the wrong coding choices.
It is funny how Machiavellian we can become in name of the simplicity. Surely, we can have better days with less cyclic dependencies, we probably can adopt better design patterns or even avoid syntaxes that ordinary people can’t easily read in our source code. But, to remove complexity from our daily routine, we need a systematic approach that help us to weigh up the benefits of every piece of code we introduce in our software.
The rule of three
Source: xkcd
Benefit-first 1 is a technique to guide the decisions you made when you develop a software. Basically, before introduce any piece of code on your software you have to list pros and cons of adopting it, and analyse the impact of maintaining it in short and long term. If the benefit of introducing it is bigger than the cost of maintaining it, then it is probably safe to proceed.
The first piece of advice I’ve ever read that advocated a similar approach came from Martin Fowler on his iconic book Refactoring. According to him, we should adopt the rule of three to drive our refactoring decisions, avoiding overcomplicated strategies that might need to be rethink again in the future. As the book got notorious and relevant, the Rule of Three has been constantly repeated on the internet with subjective definition and, in some cases, with no clear steps to reproduce this technique in the future.
Distinguishing Chance, Coincidence and Trend
My professor of Statistics once taught me about a similar concept: identifying trend behaviour. Letting all mathematic formulas aside, I would reproduce his reasoning and translate to the Software Development world as follows:
- Take a chance and design the most simplistic solution to your problem. As you have a simple piece of code testing it take less time, and it will be easier to adapt in case your needs change.
- Treat further changes as a coincidence. We have this instinct to introduce generic solutions to solve problems that might happen in the future. A premature generalization might require further refactoring, or might even be removed altogether being replaced by a different approach in the future. Sometimes, a simple if/else statement is our best choice.
- A good hint to identify trend behaviours is the introduction of duplicated pieces of code. That’s the perfect opportunity to introduce abstractions that not only removes these duplications but also allows developers to extend the current logic without modifying it 2.
By looking to these rules it is clear that they focus on the software design, diverging from its original proposal as a technique to help you to refactor your code wisely. By adopting it in the early stages of the development, we enforce simple and evolving code over reactive trial-error-refactor approach, where complex solutions will be introduced only when we need to solve a complex problem.
Final Thoughts
Sometimes the requirements are clear enough so you can jump into the complex solution straightaway, but that is not usually the case. The above mindset was an attempt to narrow down the Rule of Three scope and try to make it more reproducible on a daily-basis. As a bonus hint, I’d like to left here another definition that approaches the Rule of Three as something totally different way. I found it when I was reviewing the references for this article and it has been echoing on my mind for a bit of time already. Hopefully it will be just as enlightening for you as it was for me.
There are two "rules of three" in [software] reuse:
- It is three times as difficult to build reusable components as single use components, and
- a reusable component should be tried out in three different applications before it will be sufficiently general to accept into a reuse library.
-
Benefit-first isn’t a term carved by me. Although I’ve never saw any specific mention to this term on a book or a lecture before, I heard about it a few years ago from my first mentor and I’ve been using it since then. ↩
-
The Open-Closed Principle is the perfect technique for this job as, by definition, it closes out methods or classes for modification by introducing customization points that allow it to be extended from outside. ↩


RESERVOIR DOGS A film review by Andrew Hicks Copyright 1996 Andrew Hicks / Fatboy Productions
(1992) *** (out of four)
On the basis of this film alone, I never would have predicted that, in two years, Quentin Tarantino would become the country's biggest hotshot director. RESERVOIR DOGS has hints of the Tarantino brilliance that emerged in PULP FICTION, but is a much less substantive, more conventional crime story than the big PF. Here's what the two movies do have in common...
--Scenes of intelligent, amusing dialogue with no relevance to the plot --A story that jumps back and forth in time rather than going in a logical, chronological sequence --Graphic yet necessary violence --An engaging crime story --Dialogue liberally spiced with swear words and racial/gender slurs --Three of the same actors (Harvey Keitel, Tim Roth and Steve Buscemi) --A Mexican standoff ending, although this one is considerably less optimistic than PF
RESERVOIR DOGS is an entire hour shorter than PULP FICTION because it's only got one story to tell rather than three. Crime lord Joe Cabot (veteran actor Lawrence Tierney) has assembled five criminals who have never even met each other to pull a diamond store heist. The five are instructed not to reveal their real names or personal details or anything the cops could use if one of them was captured and interrogated. Instead, they are all given code names off the color chart -- Mr. White (Keitel), Mr. Pink (Buscemi), Mr. Orange (Roth), Mr. Blonde (Michael Madsen), Mr. Brown (Tarantino) and Mr. Peach (Tarantino's chin).
Most of the movie's running time is spent with Mr. White and Pink waiting at a warehouse for the others to arrive. Mr. Orange, meanwhile, is on the floor, dying from a gunshot wound. The police had arrived at the scene of the crime way too soon, leading White to believe one of the five was an informant. The story's background unfolds through a series of flashbacks, of the crime itself and the meetings between Joe and the criminals prior to the crime. Eventually, Blonde arrives with a police officer hostage, and what follows is a truly brutal, uncomfortable torture scene. Let's just say Picasso would be inspired by what Blonde does to the cop's ear.
A lot of the time, RESERVOIR DOGS seems like your typical gangster heist-gone-wrong movie, but there are a few sequences that are uniquely Tarantino. The opening scene in the coffee shop starts the movie off on a high note the rest of it doesn't live up to, as the criminals plus Joe have a conversation on, among other things, tipping philosophies and their interpretations of Madonna's "Like a Virgin." Another scene involves Roth's lengthy manufactured story about running into a group of cops and a police dog in a bus station bathroom while carrying a giant bag of marijuana. Neither of these have much plot relevance but are given ample time to develop, like the Captain Koons gold watch speech in PULP FICTION, only here these sequences are more enjoyable than the rest of the movie. RESERVOIR DOGS is good but it's no PULP FICTION.
--
Visit the Movie Critic at LARGE homepage at http://www.missouri.edu/~c667778/movies.html
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


Gallery
PHOTOS: Louth ladies presentation night at Lisdoo
Pictures
by David LynchFollowing what was a tremendously successful year for the Louth ladies GAA side, players and supporters came together for a presentation night at the Lisdoo in Dundalk recently.
Our photographer Arthur Kinahan was on hand to capture the scene.
Check out the gallery above


--- layout: default ---
I'm either working on this or it really does not exist. In any case, sorry about that.


"x" "1" "VERGNES,JS AND BALLANTYNE,B, INVESTIGATIONS ON THE IN VITRO AND INVIVO GENOTOXIC POTENTIAL OF 5-VINYL-2-NORBORNENE, J. APPL. TOXICOL.18(2):129-142, 1998"


Welcome to our voting website! please help donating for these goats by voting for your favorite ones .. you will have 25 rounds of voting by default ...
Welcome to our voting website! please help donating for these goats by voting for your favorite ones .. you will have 25 rounds of voting by default ...


This document is under construction as Cordova/PhoneGap have changed quite a bit.
PhoneGap is a tool that allows you to target various phones, including Android, IPhone, Windows Phone 7, Blackberry, Symbion and WebOS.
To effectively use PhoneGap, you will need Eclipse, the Android SDK and the ADT plugin for Eclipse. If you don't have these tools installed already, descriptions and links for these tools are described later in this paragraph. Your first, step, then, will be to go to the
Cordova is the name for the open source version of PhoneGap. Because PhoneGap is a widely known name, we will probably hear that name the most often. But from a developers point of view, there are few significant differences between PhoneGap and Cordova, and it is the Cordova source and documents that will often be the most important to us. PhoneGap was bought by Adobe in 2011. Since Cordova is open source, this is really a non-issue for most developers. Hopefully Adobe's deep pockets will help increase the popularity of Cordova, and help finance its development, but otherwise, there should be no significant impact. I'm not, of course, clairvoyant or able to predict the future, but that is my guess as to how things will pan out.
Navigate to the Get Started Guide and choose the platform you want to target. In our case, it will likely be Android. The description of how to get started is included on the page you selected. There is even a video to help step you through the process. I include my own take on the subject below, and show how a script that can make the process much simpler for you.
Don't forget to copy create a res/xml directory, and move the plugins.xmland phonegap.xml into it. Without this step, I got the following error:
android.content.res.Resources$NotFoundException: Resource ID #0x0
You may have a problem with the deviceReady event never being firing because the plugin(s) are not installed properly. In other words, these lines at the bottom of index.html may not working right:
document.addEventListener('deviceready', function onDeviceReady() {
angular.bootstrap(document, ['statesApp']);
}, false);
NOTE: The deviceReady code won't work in a browser. This means you can have difficulties if you want to preview your app before installing it on AndroidX86 or a phone. The problem, of course, is that the deviceReady event will never fire in a browser since we are not installed in a device. Given the code above, this means that angular will never load, and hence main.html and about.html, etc. will never load. One fix would be to comment out those lines and restore the ng-app statement on the body tag near the top of the HTML file.
I fixed the plugins problem by doing this:
#! /bin/bash
rm -r platforms
rm -r plugins
cordova platform add android
cordova plugin add org.apache.cordova.network-information
It follows that we don't want to check in the plugins folder at all. Probably the best solution is to add plugins to your repository wide .gitignore file. Don't worry about having checked in plugins on one or two projects, but we do want to fix this issue going forward.
More recent information is here:
To create PhoneGap applications automatically, you need to know how to set up environment variables, as explained here. Before we get into the details, let me give you an overview in the form of a cheat sheet that will help you understand where we are headed.
If you have not done so already, you will first need to download and install the following:
Many developers get the Android SDK as part of Android Studio. The bundle is just a zip file. In the other platforms section of the downloads page you can find a zip file for the Android SDK. Support for Mac and Linux are also under other platforms.
Details on what to download are discussed below and also in the page on setting up Eclipse. But first let's talk about setting up your environment.
NOTE: Eclipse used to be the preferred IDE for Android development. However, that has changed, and now Google prefers Android Studio. Whether you do Cordova development in Android Studio, Eclipse, WebStorm or some other tool is mostly a matter of taste. I find it easy to build the application from the command line, so I think the choice of IDE is simply a matter of taste and not of necessity. Just to be clear, the Android SDK is a necessity, you must install it. But Android Studio is optional. This means you can install the stand alone Android SDK rather than getting it as part of the Android Studio bundle.
To use the PhoneGap/Cordova create program to quickly and easily create a Cordova project you need to make sure you have the path on your system set up correctly so that several programs will run. In particular, you want the following programs to run from the command line:
In other words, you should be able to type any of those words, exactly as shown, and they should not produce an error that reads "XXX is not recognized as an internal or external command." Some of the programs may not do anything useful, but as long as they run, regardless of the ouput they produce, then you are good. For instance, here is the output you want to see from the ant program:
C:\Users\Charlie>ant
Buildfile: build.xml does not exist!
Build failed
Right now, we don't need to supply a build.xml file, we just need to see that ant is on the path. The output shown above confirms that ant is indeed on the path. If it were not, we would get an error about ant being an unrecognized command.
To ensure that all these programs run, you should set up the following environment variables, as shown on the left of the table presented below. On the right you see sample illustrations of what the paths could be:
The paths on the right are merely suggestions; you may wish to put these folders somewhere else.
Next, you need to set up the path on your system. Look at this group of paths, and see if they help:
%ANDROID_SDK_HOME%\platform-tools; adb %ANDROID_SDK_HOME%\tools; android %ANT_HOME%\bin; ant %JAVA_HOME%\bin; javac %PHONEGAP_HOME%\lib\android\bin create
The following SanityCheck batch file can help you confirm that you have at least set each of the environment variables on your system:
@ECHO OFF
IF NOT DEFINED JAVA_HOME GOTO MISSING_HOME
IF NOT DEFINED ANT_HOME GOTO MISSING_HOME
IF NOT DEFINED PHONEGAP_HOME GOTO MISSING_HOME
IF NOT DEFINED ANDROID_SDK_HOME GOTO MISSING_HOME
ECHO Looks good.
GOTO END
:MISSING_HOME
ECHO Missing one of the following:
ECHO JAVA_HOME - %JAVA_HOME%
ECHO ANT_HOME - %ANT_HOME%
ECHO PHONEGAP_HOME - %PHONEGAP_HOME%
ECHO ANDROID_SDK_HOME - %ANDROID_SDK_HOME%
ECHO -------------------
ECHO Try one of the following locations:
ECHO Apache ant: http://ant.apache.org
ECHO Android SDK: http://developer.android.com
ECHO Cordova: http://cordova.apache.org/
ECHO JDK: http://java.oracle.com
EXIT /B 1
:END
ECHO Your system currently has these settings:
ECHO -----------------------------------------
ECHO JAVA_HOME - %JAVA_HOME%
ECHO ANT_HOME - %ANT_HOME%
ECHO PHONEGAP_HOME - %PHONEGAP_HOME%
ECHO ANDROID_SDK_HOME - %ANDROID_SDK_HOME%
ECHO -----------------------------------------
Your setup is likely different from mine, but it might still be helpful to show the current setup on one of my systems as of January, 2014:
JAVA_HOME - C:\Program Files\Java\jdk1.7.0_51
ANT_HOME - C:\Development\apache-ant-1.9.3
PHONEGAP_HOME - C:\Development\cordova
ANDROID_SDK_HOME - C:\Users\Charlie\EclipseAdt\sdk
So long as you have the correct environment variables setup, then you can add those paths to your system exactly as shown. For instance, I appended the following to my path.
%ANDROID_SDK_HOME%\platform-tools;%ANDROID_SDK_HOME%\tools;%ANT_HOME%\bin;%JAVA_HOME%\bin;%PHONEGAP_HOME%\bin
At the command prompt, this portion of my path produces the following output when I type the wordpath:
C:\Users\Charlie\EclipseAndroid\sdk\platform-tools;C:\Users\Charlie\EclipseAndroid\sdk\tools;C:\Development\ApacheAnt-184\bin;C:\Development\jdk\bin;C:\Development\PhoneGap-2.3.0\lib\android\bin
Here is a little batch file that you can create to automate the process of setting your environment variables:
SetX JAVA_HOME "C:\Program Files\Java\jdk1.7.0_45"
SetX ANT_HOME C:\Src\Ant\apache-ant-1.9.3
SetX PHONEGAP_HOME C:\Src\cordova-android
SetX ANDROID_SDK_HOME C:\Src\Eclipse\sdk
The SetX is built into windows. You can learn about it by searching the internet or typing:
setx /h
In the code shown above, we are setting environment variables:
setx [ENVIRONMENT VARIABLE] [VALUE]
By default, the variable is set for the current user. If you want to change the entire environment for all users, look in the /M parameter. Here is how the help describes that variable:
/M Specifies that the variable should be set in the system wide (HKEY_LOCAL_MACHINE) environment. The default is to set the variable under the HKEY_CURRENT_USER environment.
Now that you have an overview of where you are headed, I will add a bit more detail for those who are not clear on exactly how to proceed. The first thing to understand is that it is possible to build a fully functional "hello world" Cordova project using the tools that come with the PhoneGap SDK. First make sure you have downloaded the SDK, unzipped it, and placed it in a well known location, such as C:\Dev\Phonegap-2.3.0 orC:\Users\YourUserName\Dev\Phonegap-2.3.0. Here is the download site:
http://phonegap.com/download/
Also download Ant, unzip it, and place it in the same Dev directory as PhoneGap, ie C:\Dev\ApacheAnt-184:
http://ant.apache.org/bindownload.cgi
You need to set up the JAVA_HOME environment variable.
For instance, set JAVA_HOME to this value:
C:\Program Files\Java\jdk1.6.0_27
Create an environment variable called ANT_HOME and point it at the home directory for ANT, the zip file you downloaded and probably put in c:\users\yourname\dev\ant....
C:\Users\charles.calvert\Dev\apache-ant-1.8.4
Set up the following path variables, altering the paths so they make sense on your system. For instance, change the user name:
%ANT_HOME%\bin;
C:\Users\charles.calvert\AndroidEclipse\sdk\platform-tools;
C:\Users\charles.calvert\AndroidEclipse\sdk\tools
%JAVA_HOME%\bin
The point is that you need to set up your path so that the Android SDK platform-tools and tools directories are on your path:
;C:\Users\Charlie\EclipseAndroid\sdk\platform-tools;C:\Users\Charlie\EclipseAndroid\sdk\tools
Make sure Java works from the command line. If not, set up Java-home. Make sure javac will run from the command line. If not, examine the part of your path that we set with %JAVA_HOME%\bin.
If you have everything set up right, then you should be able to go to the command prompt and run create.
As you know, in my system create is in:
C:\Development\phonegap-2.3.0\lib\android\bin
On computers where you don't have rights to the root of the C drive, you might try something like this:
C:\Users\UserName\Dev\phonegap-2.3.0\lib\android\bin
But regardless of where you put the program, you should be able to run it from any directory since it is now on your path.
Here is how to run the create program:
create C:\Temp\Cordova03 com.elvenware.cordova03 Cordova03
This command tells create to build a Cordova project and put in a folder called C:\Temp\Cordova03. The program will create the folder for you. It will set up your program to run in the com.elvenware.cordova03 namespace. The name of the project it creates will be Cordova03.
Notice that I am putting the project in a temp directory. Assuming that you are using Eclipse, the next step will be to copy it into our Eclipse workspace. If you are not using Eclipse, then you can the project from the temp directory or move it to someplace more useful.
To import the project in to Eclipse, choose File | Import | Android | Existing Android Code into Workspace
Browse to your project. Select the Copy Projects into workspaceoption. Click OK. Now you should see your project in the Eclipse Project Manager. You can run it by right clicking, and choosing Run As | Android Application.
Because you will be giving the command to create a project so often, it helps to automate the process. Here is a batch file for running create. To run it, you will need to be sure you have your [PHONEGAP]\lib\android\bin directory on your path, as described above. Here is the batch file:
set Project=Cordova03
set ProjectSmall=cordova03
create C:\Temp\%Project% com.elvenware.%ProjectSmall% %Project%
Please see this text on running batch files from NotePad++:
NOTE: It seems like Mac users should be able to create your project in your workspace, and then just import it without the Copy Projects into workspace option. This does not, however, seem to work on a PC, which is why we create the project in a temp directory, and then import it.
Once you have created the project, you need to import it by selecting File | Import. Now use the Android | Existing Android Code into Workspace option to browse for the root directory of your new PhoneGap project. After importing the project it should be visible in the Project Explorer. If the Project Explorer is not visible, choose Window | Show View | Project Explorer from the menu.
Plug in your Android device, start an Android X86 instance in VirtualBox, or start the Emulator. You have to have the developer options turned on for your device before you can use it for development. There are multiple ways to set up the developer options on an Android device, so I'll ask that you perform an Internet search to find the technique used for your device. There are other, lengthy, sections of this Elvenware site that describe how to set up Android x86 in VirtualBox.
The emulator tends to be monumentally slow, but it is probably the easiest option to setup. To start the emulator:
To Run the project:
Go to your [dev]/[PhoneGap]/lib/android/bin/templates/project directory.
For instance, here is the path on my system:
C:\Development\phonegap-2.3.0\lib\android\bin\templates\project
Back up the Assets directory. Make sure you have all your environment variables set up as described above, and then run either of the batch files found in the root of this zip file:
/Charlie/downloads/Android/ElfCordova-V2.3-Templates-V1.0.zip
(If you are on the Mac, or Linux, for now you can just delete the existing Assets folder, and copy one of the new ones into the place where you made the deletion.
If you open up the zip file you will find that I am simply replacing the index.html, index.js, and index.css files with custom files set up the way I prefer to see them. You will, I'm sure, want to implement changes of your own. Once you see how the system works, you will probably find it easy to modify these to create the effects you prefer. Notice that I delete a number of the files that come with the default package. That is why I suggest that you back up the original content before you delete it. You can, of course, download a new copy of the original PhoneGap templates at any time from the PhoneGap site.
This cloud based service will take your HTML, CSS and JavaScript wrapped up in a zip file and return verisons for Apple iOS, Android, Palm, Symbian, and Blackberry. It is all done in the cloud. Right now the service is free, but it will cost more when they get out of beta.
Ceate libs, xml and /assets/www folders and add
Edit manifest and
There are several solutions to this problem, but I have written some scripts that help me convert Android applications to PhoneGap. To get started, first be sure that you have installed Python. You might also want to install PyDev, which is a Python development environment in the form of an add on to Eclipse. An alternative would be to install Aptana, which is a version of Eclipse that comes with PyDev built-in.
After installing Python, you should download the two zip files shown below. The first contains the scripts that convert the project, the second contains the core parts of the PhoneGap tools that need to be included in your PhoneGap projects. The scripts should work on Windows, Linux and the Mac.
When you are done, the destDir and srcDir fields might look like this, assuming your workspace is in J:\src\PhoneGap/. Note that the # sign is a comment in Python, and that we use forward slashes rather than back slashes, and that we include a trailing slash at the end of each line:
# Here is an Android project to be converted
destDir = "J:/src/PhoneGap/PhoneGap03/"
# Here is where the files from PhoneGap live
srcDir="J:/Src/PhoneGap/PhoneGapBase/"
There are many platforms out there, and targeting HTML 5 gets you to all platforms at once. The idea is to have one platform to target all these devices. Most of the modern phones use WebKit, which fully supports HTML 5.
You can embed web apps inside native apps. People don't want to have to open a browser to open a web app.
HTML 5 is really HTML 5, CSS and JavaScript. It doesn't all work on all platforms, but it works in a wide variety of locations. Graceful degradation helps you work with this problem, in particular because things that are not supported are just ignored.
HTML5 is fluid. It stretches and morphs on different screens even if you don't write platform specific code.
HTML 5 is compelling because it supports:
Can be built with Dalvik and Java, or C++, or RenderScript for graphics code. You also have access to Python. These are all Android specific tools.
Native apps are good:
The point here is that there are great features in HTML 5, and great features in native applications. Perhaps you should build a web app for everyone, and then build a native app for successful platorms.
With WebViews you can get a bit of both worlds, have a native app that leverages your HTML5 code.
Some powerful tools, Sproutcore, Sencha touch, jquery mobile, jo, iUI, Modernizr, Polyfills
If you use jQuery ajax,or related calls in a PhoneGap application, if you try to use LocalHost in your URL, you are asking to reach the web server of the Android operating system that your application is hosted on. In most cases, there will be no web server on that Phone/OS, and so you will just get an error. If there were a WebServer on the device, it would still likely fail, because your database, data and scripts are probably not on the phone, but back on your web server.
The important thing to grasp here is that an Android emulator or VirtualBox running Android x86 is, for all intents and purposes the same thing as a phone. It is a separate operating system, a separate device from the copy of Windows, Mac, or Linux that is hosting it. That's what we mean by a virtual machine: it is a virtual computer/phone/device hosted by your main OS. It thinks its running on its own device, and so does your web server.
To make things work, you need to create a URL that can be reached from your virtual device, from a real phone. The first thing to test is whether the URL can be reached from the Browser on your computer. As a rule, if the URL does not work on your browser, then it won't work in the virtual device or in a real phone. Remember that you can simulate passing parameters in a URL when testing in the browser:
http://localhost:8000/cgi-bin/AddingDataXml.py?operanda=1&operandb=2&answer=3
You don't use the part after the question mark in your PhoneGap program, but you do in your test URL that you run in the browser.
Of course the URL above won't work in the phone, because it references localhost. You need to use the Windows command line utility ipconfig to get the actual IP address of your machine. In my case, it is <IP_ADDRESS>:
http://<IP_ADDRESS>:8000/cgi-bin/AddingDataXml.py?operanda=1&operandb=2&answer=3
An address like that should work in an emulator, in VirtualBox or on your phone. If it does not, that means you don't have your FireWall set up correctly as explained here:
http://www.elvenware.com/charlie/development/web/Server/SetupAWebSite.html
Download Apache Ant:
http://ant.apache.org/bindownload.cgi
Read how to install it:
http://wiki.apache.org/ant/AntOnWindows
Additional:
http://simonmacdonald.blogspot.ca/2012/11/getting-create-command-to-work-on.html
Check the following. Go to the command prompt and confirm that you can run:
You should be able to type java -version and get reasonable output. Make sure that javac.exe is on your path. This usually means putting \jdk\bin on your path.