%classpath add mvn org.datavec datavec-api 0.9.1 %classpath add mvn org.datavec datavec-local 0.9.1 %classpath add mvn org.datavec datavec-dataframe 0.9.1 %classpath add mvn org.deeplearning4j deeplearning4j-core 0.9.1 %classpath add mvn org.nd4j nd4j-native-platform 0.9.1 %import org.nd4j.linalg.api.ndarray.INDArray %import org.datavec.api.split.FileSplit %import org.deeplearning4j.datasets.datavec.RecordReaderDataSetIterator %import java.nio.file.Paths %import org.nd4j.linalg.factory.Nd4j %import org.datavec.api.transform.TransformProcess %import org.datavec.api.records.reader.impl.csv.CSVRecordReader import org.datavec.api.transform.schema.Schema inputDataSchema = new Schema.Builder() //We can for convenience define multiple columns of the same type .addColumnsString("DateString", "TimeString") //We can define different column types for different types of data: .addColumnCategorical("State", Arrays.asList("GA","VA","IL","MO","IN","KY","MS","LA","AL","TN","OH","NC","MD","CA","AZ","FL","IA","MN","KS","TX","OK","AR","NE","WA","WY","CO","ID","SD","PA","MT","NV","NY","DE","NM","ME","ND","SC","WV","MI","WI","NH","CT","MA")) .addColumnsInteger("State No", "Scale", "Injuries", "Fatalities") //Some columns have restrictions on the allowable values, that we consider valid: .addColumnsDouble("Start Lat", "Start Lon", "Length", "Width") .build(); import org.datavec.api.transform.condition.ConditionOp import org.datavec.api.transform.condition.column.CategoricalColumnCondition import org.datavec.api.transform.filter.ConditionFilter transformProcess = new TransformProcess.Builder(inputDataSchema) //Let's remove some column we don't need .removeColumns("DateString", "TimeString", "State No") //Now, suppose we only want to analyze tornadoes involving NY, MI, IL, MA. Let's filter out // everything except for those states. //Here, we are applying a conditional filter. We remove all of the examples that match the condition // The condition is "State" isn't one of {"NY", "MI", "IL", "MA"} .filter(new ConditionFilter( new CategoricalColumnCondition("State", ConditionOp.NotInSet, new HashSet<>(Arrays.asList("NY", "WA"))))) .build(); import org.datavec.local.transforms.TableRecords import jupyter.Displayer; import jupyter.Displayers; //JVM Repr to display table using our widget instead raw string table Displayers.register(org.datavec.dataframe.api.Table.class, new Displayer() { @Override public Map display(org.datavec.dataframe.api.Table table) { return new HashMap() {{ put(MIMEContainer.MIME.HIDDEN, ""); List> values = new ArrayList<>(); for (int row=0; row rowValues = new ArrayList<>(); for (int column=0; column if (v==0) { plot << new Points(x: [k[0]], y: [k[1]], color: Color.orange) } else { plot << new Points(x: [k[0]], y: [k[1]], color: Color.red) } } plot def plot = new Plot(title: "Predicted data Plot") plot.setXBound([0.0, 1.0]) plot.setYBound([-0.2, 0.8]) rawPredictedData.each{k, v -> if (v==0) { plot << new Points(x: [k[0]], y: [k[1]], color: Color.orange) } else { plot << new Points(x: [k[0]], y: [k[1]], color: Color.red) } } plot