Tutorial by Examples: class

here countInstance is a static class variable class StaticTest{ static countInstance : number= 0; constructor(){ StaticTest.countInstance++; } } new StaticTest(); new StaticTest(); console.log(StaticTest.countInstance);
class Functor f where fmap :: (a -> b) -> f a -> f b One way of looking at it is that fmap lifts a function of values into a function of values in a context f. A correct instance of Functor should satisfy the functor laws, though these are not enforced by the compiler: fmap id = i...
Create training instances from .arff file private static Instances getDataFromFile(String path) throws Exception{ DataSource source = new DataSource(path); Instances data = source.getDataSet(); if (data.classIndex() == -1){ data.setClassIndex(data.numAttributes()...
The ClassLoader needs to provide a ProtectionDomain identifying the source of the code: public class PluginClassLoader extends ClassLoader { private final ClassProvider provider; private final ProtectionDomain pd; public PluginClassLoader(ClassProvider provider) { this...
from sklearn import svm X = [[1, 2], [3, 4]] #Training Samples y = [1, 2] #Class labels model = svm.SVC() #Making a support vector classifier model model.fit(X, y) #Fitting the data clf.predict([[2, 3]]) #After fitting, new data can be classified by using predict()
Implement ICloneable in a class with a twist. Expose a public type safe Clone() and implement object Clone() privately. public class Person : ICloneable { // Contents of class public string Name { get; set; } public int Age { get; set; } // Constructor public Person(string...
Controller is an entry point to our application. However, it’s not the only possible entry point. I would like to have my logic accessible from: Rake tasks background jobs console tests If I throw my logic into a controller it won’t be accessible from all these places. So let’s try “skinny ...
InvocationExpression class allows invocation of other lambda expressions that are parts of the same Expression tree. You create them with static Expression.Invoke method. Problem We want to get on the items which have "car" in their description. We need to check it for null before searc...
# imports import weka.core.converters.ConverterUtils.DataSource as DS import weka.classifiers.trees.J48 as J48 import os # load data data = DS.read(os.environ.get("MOOC_DATA") + os.sep + "anneal.arff") data.setClassIndex(data.numAttributes() - 1) # configure classifier...
# imports import weka.core.converters.ConverterUtils.DataSource as DS import weka.classifiers.Evaluation as Evaluation import weka.classifiers.trees.J48 as J48 import java.util.Random as Random import os # load data data = DS.read(os.environ.get("MOOC_DATA") + os.sep + "annea...
# Note: install jfreechartOffscreenRenderer package as well for JFreeChart library # imports import weka.classifiers.Evaluation as Evaluation import weka.classifiers.functions.LinearRegression as LinearRegression import weka.core.converters.ConverterUtils.DataSource as DS import java.util.Ran...
using UnityEngine; public class Audio : MonoBehaviour { AudioSource audioSource; AudioClip audioClip; void Start() { audioClip = (AudioClip)Resources.Load("Audio/Soundtrack"); audioSource.clip = audioClip; if (!audioSource.isPlaying) audio...
Class under test: public class GreetingsService { // class to be tested in isolation private UserService userService; public GreetingsService(UserService userService) { this.userService = userService; } public String getGreetings(int userId, LocalTime time) { // the...
###### Used for both Classification and Regression examples library(randomForest) library(car) ## For the Soils data data(Soils) ###################################################### ## RF Classification Example set.seed(656) ## for ...
In order to achieve type safety sometimes we want to avoid the use of primitive types on our domain. For instance, imagine a Person with a name. Typically, we would encode the name as a String. However, it would not be hard to mix a String representing a Person's name with a String representing an e...
Resource loading in Java comprises the following steps: Finding the Class or ClassLoader that will find the resource. Finding the resource. Obtaining the byte stream for the resource. Reading and processing the byte stream. Closing the byte stream. The last three steps are typically accomp...
We can statically bootstrap an application by taking the plain ES5 Javascript output of the generated factory classes. Then we can use that output to bootstrap the application: import { platformBrowser } from '@angular/platform-browser'; import { AppModuleNgFactory } from './main.ngfactory'; //...
instance methods use an instance of a class. @interface MyTestClass : NSObject - (void)testInstanceMethod; @end They could then be used like so: MyTestClass *object = [[MyTestClass alloc] init]; [object testInstanceMethod]; Class method can be used with just the class name. @inte...
Swift does not support multiple inheritance. That is, you cannot inherit from more than one class. class Animal { ... } class Pet { ... } class Dog: Animal, Pet { ... } // This will result in a compiler error. Instead you are encouraged to use composition when creating your types. This can b...
Location is a service that applications can use to interact with a browser's URL. Depending on which LocationStrategy is used, Location will either persist to the URL's path or the URL's hash segment. Location is responsible for normalizing the URL against the application's base href. import {Comp...

Page 22 of 28