Supervised Learning

Supervised Learning consists of finding the link between observed data X, and an eternal variable Y (target) that we are trying to predict. If the prediction task is to classify the observation in a set of finite labels then the task is said to be Classification. If the task is to predict a continous target variable then the task is called Regression

 

* All Supervised estimators in scikit implement a fit(X,y) method to fit the model. and a predict(X) method that given an unlabeled observations X, returns the predicted labels y

Quote

Smart…

It is an elusive concept. There’s a certain sharpness, an ability to absorb new facts.  To walk into a situation, have something explained to you and immediately say “well, what about this?”. To ask insightful question. To absorb it in real time. A capacity to remember. To relate to domains that may not seem connected at first. A certain creativity that allows people to be effective.

                                                                                                                                                                                                                       – Bill Gates

GWT Exception Serialization

To serialize an exception to the client during an RPC call:

  1. The exception needs to be declared in the throws clause of the RPC method.
  2. The exception itself needs to be serializable.

When the rpc method throws the exception gwt converts it into JavaScript Exception object and when the  onFailure(Throwable) is invoked the exception is passed as a param to the method.

GWT Serialization

GWT RPC uses Serialization to facilitate async communication between server and client.

All GWT RPC Services extend RemoteServiceSrvlet (RSS) instead of HttpServlet.  RSS automatically takes care of serialization (in addition to calling appropriate service method).

RPC method params and return values needs to be serializable.

GWT Serialization is different from java.io.serialization and the following are rules to user classes in RPC:

  • primitives
  • String, Date, or a primitive wrapper
  • Enumeration
  • array of serializable types (including other serializable arrays).
  • user-defined serializable class.
  • The type has at least one serializable subclass.

User-Defined GWT Serializable Class

  • assignable to IsSerializable or Serializable.
  • All non-final, non-transient instance fields are themselves serializable, and
  • Prior to GWT 1.5, it must have a public default (zero argument) constructor or no constructor at all.
  • As of GWT 1.5, it must have a default (zero argument) constructor (with any access modifier) or no constructor at all.

The transient keyword is honored, so values in transient fields are not exchanged during RPCs.So are fields that are declared as final and hence advisable to be marked transient as well.

GWT RPC serialization supports polymorphism with params and return types.

Making collections serializable in GWT

Prior to GWT 1.4 @gwt.typeArgs annotation is used

in GWT 1.5 parameterized types are used.

Adding an object that doesn’t satisfy type constraint (of course in 1.4) leads to undefined behavior.

  • For RPC interfaces you need to annotate the method param’s powith field names and return types

           Ex:
           @gwt.typeArgs idList <java.lang.Integer>
           @gwt.typeArgs <java.lang.String>
           List populateList(List idList)

  • For DataTypes (DTO) you need to annotate the fields

GWT Serialization File Name:

*.gwt.rpc

Custom Field Serializer for GWT RPC

To custom serialize com.my.DTO creeate a class named com.my.DTO_CustomFieldSerializer and implement the following methods in the class:

    public static void serialize(SerializationStreamWriter streamWriter, MyObject myObject)
        throws SerializationException {}

    public static void deserialize(SerializationStreamReader streamReader, MyObject myObject)
        throws SerializationException {}

    //This method is optional
    public static DTO instantiate(SerializationStreamReader streamReader)
        throws SerializationException {}

More about custom serialization: http://code.google.com/p/wogwt/wiki/CustomFieldSerializer