From 713d9729534d0ee31e98bda6c2ad1ec8e51cb160 Mon Sep 17 00:00:00 2001 From: Julian Hinxlage Date: Thu, 25 Apr 2019 13:28:07 +0200 Subject: [PATCH] added WeekOverview --- .../spm/baudas/analysis/WeekOverview.java | 73 ++++++++++++++++++ .../de/hsel/spm/baudas/WeekOverviewTest.java | 30 +++++++ .../bauDas-kundenkarten.kotlin_module | Bin 0 -> 16 bytes .../de/hsel/spm/baudas/WekaBeispiel.class | Bin 3091 -> 3103 bytes .../hsel/spm/baudas/analysis/Analysis.class | Bin 0 -> 1068 bytes .../spm/baudas/analysis/WeekOverview.class | Bin 0 -> 2807 bytes .../bauDas-kundenkarten.kotlin_module | Bin 0 -> 16 bytes .../de/hsel/spm/baudas/WeekOverviewTest.class | Bin 0 -> 2032 bytes 8 files changed, 103 insertions(+) create mode 100644 src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java create mode 100644 src/test/java/de/hsel/spm/baudas/WeekOverviewTest.java create mode 100644 target/classes/META-INF/bauDas-kundenkarten.kotlin_module create mode 100644 target/classes/de/hsel/spm/baudas/analysis/Analysis.class create mode 100644 target/classes/de/hsel/spm/baudas/analysis/WeekOverview.class create mode 100644 target/test-classes/META-INF/bauDas-kundenkarten.kotlin_module create mode 100644 target/test-classes/de/hsel/spm/baudas/WeekOverviewTest.class diff --git a/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java b/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java new file mode 100644 index 0000000..081f4f9 --- /dev/null +++ b/src/main/java/de/hsel/spm/baudas/analysis/WeekOverview.java @@ -0,0 +1,73 @@ +package de.hsel.spm.baudas.analysis; + +import org.jetbrains.annotations.Nullable; +import weka.core.Instance; +import weka.core.Instances; +import weka.filters.Filter; +import weka.filters.unsupervised.attribute.Remove; + +import java.io.File; +import java.util.HashMap; +import java.util.Map; + +/** + * Week Overview Analysis + * + * @author Julian Hinxlage + * @version 0.1 + * @since 0.1 + **/ +public class WeekOverview implements Analysis> { + + private Instances instances; + private Map result; + + public WeekOverview(File file) { + result = new HashMap(); + instances = load(file); + } + + @Override + public Map getResult() { + + int[] keepIndexes = new int[]{5, 10}; + int dayIndex = 0; + int amountIndex = 1; + + + try { + //Remove all other attributes + Remove remove = new Remove(); + remove.setAttributeIndicesArray(keepIndexes); + remove.setInvertSelection(true); + remove.setInputFormat(instances); + instances = Filter.useFilter(instances, remove); + } catch (Exception ex) { + ex.printStackTrace(); + } + + + for (int i = 0; i < instances.attribute(dayIndex).numValues(); i++) { + String day = instances.attribute(dayIndex).value(i); + + System.out.println(day); + + + for (int j = 0; j < instances.attribute(amountIndex).numValues(); j++) { + String amount = instances.attribute(amountIndex).value(j); + + System.out.println(amount); + + int x = Integer.parseInt(amount); + + if(!result.containsKey(day)){ + result.put(day,0); + } + result.put(day,result.get(day) + x); + + } + } + + return result; + } +} diff --git a/src/test/java/de/hsel/spm/baudas/WeekOverviewTest.java b/src/test/java/de/hsel/spm/baudas/WeekOverviewTest.java new file mode 100644 index 0000000..9e285f5 --- /dev/null +++ b/src/test/java/de/hsel/spm/baudas/WeekOverviewTest.java @@ -0,0 +1,30 @@ +package de.hsel.spm.baudas; + +import de.hsel.spm.baudas.analysis.WeekOverview; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.util.Map; + + +/** + * Week Overview Analysis Test + * + * @author Julian Hinxlage + * @version 0.1 + * @since 0.1 + **/ +public class WeekOverviewTest { + + @Test + public void test(){ + WeekOverview overview = new WeekOverview(new File(getClass().getClassLoader().getResource("kd100.csv").getFile())); + + Map result = overview.getResult(); + + for(Map.Entry i : result.entrySet()){ + System.out.println(i.getKey() + " = " + i.getValue()); + } + + } +} diff --git a/target/classes/META-INF/bauDas-kundenkarten.kotlin_module b/target/classes/META-INF/bauDas-kundenkarten.kotlin_module new file mode 100644 index 0000000000000000000000000000000000000000..8fb60192d378759239a3ecbf60eac8c8de446e9c GIT binary patch literal 16 RcmZQzU|?ooU|@t|UH|}6022TJ literal 0 HcmV?d00001 diff --git a/target/classes/de/hsel/spm/baudas/WekaBeispiel.class b/target/classes/de/hsel/spm/baudas/WekaBeispiel.class index 9b513662d7bbf10ccd18a54e7b3dd6eaee81ccb9..f5ed3d560410ae79cd14221cf29a06956c96abdb 100644 GIT binary patch delta 485 zcmYk2Nl#Qk5P-kty|Er`YlvgQI~d|k5)zhV5^fk16K;Ajh@vCIA_C80lTqBpUEI*2 z6~ql({{S}Ckr6`=S)KOIQD@yeY zFlZTKSU77*G?p-;IHwr3j4>``mfaK+&Z{mfMuiDWUJLR}CQJ#_mPWN3nMt@1^f6|I zie;a+zG!JueaW()IW;aTu4tR9!nGaMUt!d6)Nx&ls)`%JO-l>66t{&tweLU8-Sthg zXm;HTvCts=9j5nvQFnTudB+0|2@f5Qcq}||Eb!ECM4jm~YK}#P=eh90vBa{W;J-#K zz7VI;OIG~RxXHZonm2~}@u80P_SV6fisLQs{ExV&dBw5Hn&Ukm93QC}8pcYM zQd?FkkF*`0m>tN59iOQAEO#LK%>4RNZY^h~edo@FBfUZ|!U^G|&}ZN`d;W$ETA@cc ZzAc)wE&pfb=?c4vF&qr{RCw2M`X3r^Ug!V- delta 452 zcmXYtOHY(B6o#M9d}BXKgCr=BNG7l{aS{S#b|x6Zg19FH21ITHA|tmEL~bKjMQ%bt z?sEAH>|C%WZutTH2^NHfvB%i7&)f61C+D;$rLHvh`_HdSAj!F*l9Z;!5FsUK6}--) zjW>pNIy9YzP|iZS1l@wPp@&}0TSEb%e3UZdnokdMcfM6W#F&tzNx_t6+K^yIkkfqLyuMYl7guUa zsX5mht$#Alf@P7HnkCB@zG{{&-&j%9xaW~XMO`M{F_0dytg>cV7i{odvuWAFDU$wH z(!B~EMz`5@@Xy3M`OcU3H?k2zZnOOhke^bG||HE4U^Z>;Rznc6$ GLi1k=4^)K! diff --git a/target/classes/de/hsel/spm/baudas/analysis/Analysis.class b/target/classes/de/hsel/spm/baudas/analysis/Analysis.class new file mode 100644 index 0000000000000000000000000000000000000000..af682a238745bdbd10b0ad28454f4598a424eb88 GIT binary patch literal 1068 zcma)5TTc@~7(LULF4W~(E&^Ua0b2?TD*7OVgrFuQ3na85@o~Bx%fNQF*_}oCOFr?0 zi6;I4f0X)7FHpq?n(SP@IX&NZ&NuV(*S8-4Ht^cPQVtBy>`<^n(ZO;KeJD9taj?pe z2|`h0SS)y_;#_bQ^7kr`n?>)FJQLgxBgyx4Y=rh@yh-rguqGLXJ*DMA(x}R)BB}vJ z#=OuM!Lf*x-FJeF4koUN_YU8E_GQzkP+KN*qGE<6uO|6PECU`l8@wu#nuxj3BDjcE z%y&8qi~mSjErKwTR!$$2;!LhyU2@Xx6sm^s@SSj zHn)jpuxx~XwlA73nJp*R$Z4{cVfHA|Mm6M~K3B0KD|WOFjj*Cg?SdCZb$%*MH4;i& zq1T7}APEBN9VHm3OLHXSBrpu)g<@NBAatD{R!^mGETpXJT9_mvPx=Z)s*F0kRe5t8 zyL~&vkSm8tFL_MX72#QqnqCU&qx;>>n@(-g^QQiV90l`PEUtjyuvyOzDsu* zMp_I#3K`rkX}iYkmeR^>Go%Z}W0D_B)0V(6`tRMP^Bg(&Rv1y1WZ@K9cq6IzIuAD^ zrA@1yl}Pw9%iy4&-VTtW*D`<{&G%^ch2{*+)8D~9d_`)1rF4b#$`vw~2dh`evP**Z zV-#cbxH51FI)f~Y4=MT>gP5a}dF1f~Q&^xquuQl-eM1;V+EQbL{%?QNgw1#O#xX&u zCn@Suq>Y-Q`96IUV802Pb};Q=#=$I@g9nrnl$zQIWEdr%qxC$+Qj|Q^Sv{p9Y-I5d Dl(Gm1 literal 0 HcmV?d00001 diff --git a/target/classes/de/hsel/spm/baudas/analysis/WeekOverview.class b/target/classes/de/hsel/spm/baudas/analysis/WeekOverview.class new file mode 100644 index 0000000000000000000000000000000000000000..161304aba26b8223d0781ecc5c3d5ff3f7eb0b3d GIT binary patch literal 2807 zcma)8TXR!Y6#h~#$#nu)@PLoZ0XmS$IrLs|4}i=%JMIJ}}G0mN~5_HQ_j-Oje9y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ff --git a/target/test-classes/META-INF/bauDas-kundenkarten.kotlin_module b/target/test-classes/META-INF/bauDas-kundenkarten.kotlin_module new file mode 100644 index 0000000000000000000000000000000000000000..8fb60192d378759239a3ecbf60eac8c8de446e9c GIT binary patch literal 16 RcmZQzU|?ooU|@t|UH|}6022TJ literal 0 HcmV?d00001 diff --git a/target/test-classes/de/hsel/spm/baudas/WeekOverviewTest.class b/target/test-classes/de/hsel/spm/baudas/WeekOverviewTest.class new file mode 100644 index 0000000000000000000000000000000000000000..c8b72a6daf257e77b09e50a5c22582cf4d1b37c1 GIT binary patch literal 2032 zcma)7TUQ%Z7~Lm?Oh|@uX#r_#rKKv+!ceW%mW#I7DmGl?R;gAUl4BT{%*2^VTD34`Cr|x%%u+@}auV%w#n~^I#s%neVc{^Ii5i`TN)4Ik&wkDGb) zVok%k5;n5fRPvS*9;oG$9JcXL!>1ZP6UfY3jup%cbc~H}38WX?k`(AESdLt-Rd%Ge zVeZ(}^cUQsX>XaHrQ}$d4t6bH;MGD&8oR!<4Zm73cFbDI^o<8n?yuCPSGVNj4e19n z3?6V75SBpaT_^Ak1oTD6k=}xB`o3hOfx@0yH;r0g*~XGty&QTGnRVkx0u${HGab`D z@U7&j#AQ6`*KD5IlMGDLV6vctYO|=>q-&Hzth7z1Y^(>K<&nR&*& zk%a$$VE1}p7WY|o*xZm4k2HKPFuYcC0;?joEZ<`9Z##|~n1SUwY}omN>y?eY8fVD0 zY6a3W%&KL?9nY=1HLob|S!#p>Cr2`+nyupkUJ)2;Gs3oA<;=nvS+1eN>i7a*YG9Zh z6a~8WOV_5Sr;2`ELrI6kR~pJXc44V=_SCYk!$w8JBOMN04OJaq!(*j7d;~gbs0*BK z!vhVEbvyxCGZb1|hHdGhFkw^X#lt&%(N7Ta#w0Xl`kB=#y1^j~YCfh}LX8 zG1{)_FUu#4$QSM*A0a0clEp-`q<1TI4*Wn?2y<%$$1f9$S>^2ySiLkW1Y}szeMwGc z%xYCSC4tFy{dl48F=H7)QDe)r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