Commit 411b055b authored by anastasiaslobodyanik's avatar anastasiaslobodyanik
Browse files

Merge branch 'master' of git.scc.kit.edu:oliver.wirth/windturbineprediction

parents 6e62623a 62e4070c
......@@ -411,6 +411,10 @@
"metadata": {},
"outputs": [],
"source": [
"def output_to_onehot(x, dim = -1) :\n",
" maxidx = x.argmax(dim = dim, keepdims = True)\n",
" return torch.zeros_like(x).scatter(dim = dim, index = maxidx, value = 1)\n",
"\n",
"# Ensemble model consisting of pre-trained region models\n",
"class RegionEnsemble(nn.Module) :\n",
" \n",
......@@ -423,13 +427,18 @@
" model = torch.load(region_run_path / 'model_best.pt')\n",
" self.models[region_run_path.name] = model\n",
" \n",
" def confidence(self, x, dim = -1) :\n",
" x = x.softmax(dim = dim)\n",
" x = 1 + (x * torch.log(x)).sum(dim = dim, keepdims = True)\n",
" return x\n",
" \n",
" def forward(self, x) :\n",
" # Get region model outputs\n",
" x = torch.stack([model(x) for model in self.models.values()], dim = 1)\n",
" # Convert to probabilities\n",
" x = x.softmax(dim = 2)\n",
" # Average probabilities (confidence-weighted majority vote)\n",
" x = x.mean(dim = 1)\n",
" # Convert to confidence-weighted probabilities\n",
" x = x.softmax(dim = 2) * self.confidence(x, dim = 2)\n",
" # Sum weighted probabilities\n",
" x = x.sum(dim = 1)\n",
" return x"
]
},
......@@ -574,7 +583,7 @@
" cmap = 'mako_r',\n",
" fmt = 'g'\n",
")\n",
"plt.savefig('confusion_matrix.png')\n",
"plt.savefig(run_path / 'confusion_matrix.png')\n",
"\n",
"metrics"
]
......
This diff is collapsed.
# WindTurbinePrediction
## Others: Versuch_Paul.ipynb:
Data: use ten best features explored in data_exploration.ipynb file
### Approaches:
1. Lightgbm: leaf wise tree growth (best first) instead of level wise tree growth. low acc.
2. Easy NN: 2 hidden layers, batches 64, epochs 50, binary classification, Relu, ADAM. low acc.
3. TPOPT: looks for the best classification pipeline. Currently only on mean feature data.
This repository resembles our solution approach to the second PSDA task.
......@@ -30,7 +24,7 @@ The models' predictions are combined by using a weighted majority vote.
More specifically, the models' output probabilities are acquired via softmax and averaged to form the ensemble's output.
## `Others.ipynb`
Data: use ten best features explored in data_exploration.ipynb file
Data: best features explored in data_exploration.ipynb file
### Approaches:
1. Lightgbm: leaf wise tree growth (best first) instead of level wise tree growth. low acc.
......
......@@ -572,7 +572,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.4"
"version": "3.8.8"
}
},
"nbformat": 4,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment