@@ -74,6 +74,11 @@ public void fit(ArrayList<Pair<ArrayList<Double>, String>> data) {
7474
7575 }
7676
77+ @ Override
78+ public boolean readyToPredict () {
79+ return theta != null || super .readyToPredict ();
80+ }
81+
7782 @ Override
7883 public void updateSingle (ArrayList <Double > features , String label ) {
7984 super .updateSingle (features , label );
@@ -100,21 +105,25 @@ public String predictOne(ArrayList<Double> features) {
100105
101106 @ Override
102107 public void save (BehaivStorage storage ) throws IOException {
103- theta .saveToFileBinary (storage .getNetworkFile (id ).toString ());
104- final Gson gson = new Gson ();
105108
106109 try (final BufferedWriter writer = new BufferedWriter (new FileWriter (storage .getNetworkMetadataFile (id )))) {
110+ theta .saveToFileBinary (storage .getNetworkFile (id ).toString ());
111+ final Gson gson = new Gson ();
107112 writer .write (gson .toJson (labels ));
113+ } catch (Exception e ) {
114+ e .printStackTrace ();
108115 }
109116 }
110117
111118 @ Override
112119 public void restore (BehaivStorage storage ) throws IOException {
113- theta = SimpleMatrix .loadBinary (storage .getNetworkFile (id ).toString ());
114- final Gson gson = new Gson ();
115120
116121 try (final BufferedReader reader = new BufferedReader (new FileReader (storage .getNetworkMetadataFile (id )))) {
122+ theta = SimpleMatrix .loadBinary (storage .getNetworkFile (id ).toString ());
123+ final Gson gson = new Gson ();
117124 labels = ((List <String >) gson .fromJson (reader .readLine (), labels .getClass ()));
125+ } catch (Exception e ) {
126+ e .printStackTrace ();
118127 }
119128 }
120129
0 commit comments