org.neuroph.contrib.samples
Class SunSpots
- java.lang.Object
-
- org.neuroph.contrib.samples.SunSpots
-
- All Implemented Interfaces:
- java.util.EventListener, LearningEventListener
public class SunSpots extends java.lang.Object implements LearningEventListener
This example shows how to use Neuroph to predict sunspots. It demonstrates two very important machine learning techniques. First, time-window. Sunspots are organized into input windows used to predict the next level of sunspot activity. This example uses a 30 year window. Basically, 30 years of sunspot activity is used to predict the 31st year. This 30 year window slides forward, one year at a time. Second is normalization. The sunspots are normalized into a range between 0.1 and 0.9. This is very close to the actual 0 to 1 range of the sigmoid function. We stay away from the extream edges of this range, thus using 0.1 and 0.9. This is an example from the book "Introduction to Neural Networks for Java" by Jeff Heaton. This example has been contributed to the Neuroph project by Jeff Heaton. http://www.heatonresearch.com/book/programming-neural-networks-java-2.html
-
-
Field Summary
Fields Modifier and Type Field and Description static intEVALUATE_ENDEnd of evaluation data.static intEVALUATE_STARTBeginning of evaluation data.static doubleMAX_ERRORThis really should be lowered, I am setting it to a level here that will train in under a minute.static intSTARTING_YEARStarting year for sunspot data.static double[]SUNSPOTSstatic intTRAIN_ENDEnd of training data.static intTRAIN_STARTStart of training data.static intWINDOW_SIZESize of our prediction window.
-
Constructor Summary
Constructors Constructor and Description SunSpots()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description DataSetgenerateTrainingData()Generate the training data for the training sunspot years.voidhandleLearningEvent(LearningEvent event)This method gets executed when LearningRule fires LearningEvent which some class is listening to.static voidmain(java.lang.String[] args)voidnormalizeSunspots(double lo, double hi)Normalize the sunspots.voidpredict(NeuralNetwork network)Predict sunspots.voidrun()
-
-
-
Field Detail
-
SUNSPOTS
public static final double[] SUNSPOTS
-
STARTING_YEAR
public static final int STARTING_YEAR
Starting year for sunspot data.- See Also:
- Constant Field Values
-
WINDOW_SIZE
public static final int WINDOW_SIZE
Size of our prediction window.- See Also:
- Constant Field Values
-
TRAIN_START
public static final int TRAIN_START
Start of training data.- See Also:
- Constant Field Values
-
TRAIN_END
public static final int TRAIN_END
End of training data.- See Also:
- Constant Field Values
-
EVALUATE_START
public static final int EVALUATE_START
Beginning of evaluation data.- See Also:
- Constant Field Values
-
EVALUATE_END
public static final int EVALUATE_END
End of evaluation data.
-
MAX_ERROR
public static final double MAX_ERROR
This really should be lowered, I am setting it to a level here that will train in under a minute.- See Also:
- Constant Field Values
-
-
Method Detail
-
normalizeSunspots
public void normalizeSunspots(double lo, double hi)Normalize the sunspots.- Parameters:
lo- Low range for normalization.hi- High range for normalization.
-
generateTrainingData
public DataSet generateTrainingData()
Generate the training data for the training sunspot years.- Returns:
- The training data.
-
predict
public void predict(NeuralNetwork network)
Predict sunspots.- Parameters:
network- Neural network to use.
-
run
public void run()
-
main
public static void main(java.lang.String[] args)
-
handleLearningEvent
public void handleLearningEvent(LearningEvent event)
Description copied from interface:LearningEventListenerThis method gets executed when LearningRule fires LearningEvent which some class is listening to. For example, if you want to print current iteration, error etc.- Specified by:
handleLearningEventin interfaceLearningEventListener- Parameters:
event- holds the information about event tha occured
-
-
DMelt 3.0 © DataMelt by jWork.ORG