## ~vonfry/cpipc-2020

9bd8bd21d240e3768c1bc42b197c6a3f2f66f3f0 — Vonfry 2 years ago
```papare ga optimzation

but here are some problem with the library
```
```4 files changed, 24 insertions(+), 1 deletions(-)

M 1dimension_reduce_randomforest.r
A 3optimization.py
A requirements.txt
M shell.nix
```
`M 1dimension_reduce_randomforest.r => 1dimension_reduce_randomforest.r +3 -0`
```@@ 12,3 12,6 @@ imp <- importance(rf)
ordered_imp <- imp[order(imp, decreasing = T),]

write.csv(ordered_imp, "./data/features_importance.csv")
+
+# chi test
+library(MASS)

```
`A 3optimization.py => 3optimization.py +16 -0`
```@@ 0,0 1,16 @@
+import numpy as np
+
+def fitness(args):
+    # step1: calculate target value
+    # step2: compute RON LOSS RATE
+    # step3: get the max/min target values as our fitness value
+    return
+
+from sko.GA import GA
+# TODO set lb and ub to each variables
+ga = GA(func=schaffer, n_dim=11, size_pop=50, max_iter=800, lb=[-1, -1],
+        ub=[1, 1], precision=1e-7)
+best_x, best_y = ga.run()
+print('best_x:', best_x, '\n', 'best_y:', best_y)
+
+import matplotlib.pyplot as plt

```
`A requirements.txt => requirements.txt +1 -0`
```@@ 0,0 1,1 @@
+scikit-opt

```
`M shell.nix => shell.nix +4 -1`
```@@ 10,6 10,9 @@ let tex-combined = texlive.combine {
neuralnet MLmetrics
genalg
];
+    pythonWith = python3.withPackages (p: with p; [ pip numpy ipython pandas
+                                                    matplotlib # scikit-opt
+                                                  ]);
in mkShell {
-  buildInputs = [ R tex-combined ] ++ rDeps;
+  buildInputs = [ R tex-combined pythonWith ] ++ rDeps;
}

```