Skip to content

Commit 211d4c7

Browse files
authored
Merge pull request #8 from dmi3coder/feature/java_implementation
Fixed storing on empty features
2 parents 67a9332 + 127b85a commit 211d4c7

File tree

3 files changed

+92
-56
lines changed

3 files changed

+92
-56
lines changed

.idea/workspace.xml

Lines changed: 78 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ publishing {
2222
maven(MavenPublication) {
2323
groupId = 'de.dmi3y.behaiv'
2424
artifactId = 'behaiv'
25-
version = '0.1.8-alpha'
25+
version = '0.1.10-alpha'
2626

2727

2828
from components.java

src/main/java/de/dmi3y/behaiv/kernel/LogisticRegressionKernel.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)