Tutorial by Examples: and

A random forest is a meta estimator that fits a number of decision tree classifiers on various sub-samples of the dataset and use averaging to improve the predictive accuracy and control over-fitting. A simple usage example: Import: from sklearn.ensemble import RandomForestClassifier Define tr...
Python has a variety of command-line switches which can be passed to py. These can be found by performing py --help, which gives this output on Python 3.4: Python Launcher usage: py [ launcher-arguments ] [ python-arguments ] script [ script-arguments ] Launcher arguments: -2 : Launch ...
Postfix increment X++ will add 1 to x var x = 42; x++; Console.WriteLine(x); // 43 Postfix decrement X-- will subtract one var x = 42 x--; Console.WriteLine(x); // 41 ++x is called prefix increment it increments the value of x and then returns x while x++ returns the value of x and the...
The bisect command helps you to track down the changeset that introduced a bug. Reset the bisect state and mark the current revision as bad (it contains the bug!) hg bisect --reset hg bisect --bad Go back to a point where you think the bug isn't present hg update -r -200 Now...
Python 2.x2.7 In Python 2 filter, map and zip built-in functions return a sequence. map and zip always return a list while with filter the return type depends on the type of given parameter: >>> s = filter(lambda x: x.isalpha(), 'a1b2c3') >>> s 'abc' >>> s = map(lambd...
Lubridate provides ymd() series of functions for parsing character strings into dates. The letters y, m, and d correspond to the year, month, and day elements of a date-time. mdy("07-21-2016") # Returns Date ## [1] "2016-07-21" mdy("07-21-2016", t...
date <- now() date ## "2016-07-22 03:42:35 IST" year(date) ## 2016 minute(date) ## 42 wday(date, label = T, abbr = T) # [1] Fri # Levels: Sun < Mon < Tues < Wed < Thurs < Fri < Sat day(date) <- 31 ## "2016-07-31 03:42:35 IST" # If an ...
Intervals are simplest way of recording timespans in lubridate. An interval is a span of time that occurs between two specific instants. # create interval by substracting two instants today_start <- ymd_hms("2016-07-22 12-00-00", tz="IST") today_start ## [1] "2016-07-...
Unlike durations, periods can be used to accurately model clock times without knowing when events such as leap seconds, leap days, and DST changes occur. start_2012 <- ymd_hms("2012-01-01 12:00:00") ## [1] "2012-01-01 12:00:00 UTC" # period() considers leap year calculati...
GROUP BY is used in combination with aggregation functions. Consider the following table: orderIduserIdstoreNameorderValueorderDate143Store A2520-03-2016257Store B5022-03-2016343Store A3025-03-2016482Store C1026-03-2016521Store A4529-03-2016 The query below uses GROUP BY to perform aggregated calc...
Creating a hub A quick configuration for a hub and node setup in selenium grid. For more information see: Grid 2 docs Requirements To set up a grid hub you need the flowing: Selenium-server-standalone-.jar Creating the hub To Create a Hub you need to run the selenium server. Download Se...
The Android specific implementation is a bit more complex because it forces you to inherit from a native Java.Lang.Object and forces you to implement the IOnInitListener interface. Android requires you to provide a valid Android context for a lot of the SDK methods it exposes. Xamarin.Forms exposes ...
' Sometimes we don't need to evaluate all the conditions in an if statement's boolean check. ' Let's suppose we have a list of strings: Dim MyCollection as List(Of String) = New List(of String)() ' We want to evaluate the first value inside our list: If MyCollection.Count > 0 And MyCo...
It is now a best-practice to use Vector instead of List because the implementations have better performance Performance characteristics can be found here. Vector can be used wherever List is used. List creation List[Int]() // Declares an empty list of type Int List.empty[Int] // U...
The Scala compiler prefixes every argument in the parameter list by default with val. This means that, by default, case classes are immutable. Each parameter is given an accessor method, but there are no mutator methods. For example: case class Foo(i: Int) val fooInstance = Foo(1) val j = fooIn...
Apply will be used when when table valued function in the right expression. create a Department table to hold information about departments. Then create an Employee table which hold information about the employees. Please note, each employee belongs to a department, hence the Employee table has ref...
In normal mode, we can increment the nearest number on the line at or after the cursor with <C-a> and decrement it with <C-x>. In the following examples, the cursor position is indicated by ^. Incrementing and decrementing numbers for i in range(11): ^ <C-x> decrements ...
The Math.random() function should give random numbers that have a standard deviation approaching 0. When picking from a deck of card, or simulating a dice roll this is what we want. But in most situations this is unrealistic. In the real world the randomness tends to gather around an common normal...
Creating and configuring Sprite and TextField objects at runtime can be costly if you are creating hundreds of thousands of these on a single frame. Therefore a common trick is "pooling" these objects for later reuse. Remember we are not just trying to optimize the creation time (new Sprit...
Flash dispatches Events for most of its objects. One of the most basic event is ENTER_FRAME, which is dispatched (at the framerate of the SWF) on every display list object. import flash.display.Sprite; import flash.events.Event; var s:Sprite = new Sprite(); s.addEventListener(Event.ENTER_FRAME...

Page 35 of 153