Federated learning for multi classes classification

mohammed_ibrahim: <p>I’m a new to python as well as machine learning. I’m trying to use logistic regression for federated learning program for multiclass labels (sitting, sittingdown, standing, standingup, walking) for UCI HAR Dataset. it’s working for binary classification but for multiclassification when I’m trying to find out precision and recall, it is throwing the following error:</p>
<p><code>ValueError: Target is multiclass but average='binary'. Please choose another average setting, one of [None, 'micro', 'macro', 'weighted'].</code></p>
<p>Can anyone please suggest me how to proceed with it? I have tried to classify 6 labels by LG classified (multi-classes) with FL instead of using binary classification.</p>
<p>code:<br>
</p><aside class="onebox githubblob">
  <header class="source">
      <a href="https://github.com/datafleets/horizontal-federated-learning-blog/blob/master/horizontal-fl.ipynb" target="_blank" rel="nofollow noopener">github.com</a>
  </header>
  <article class="onebox-body">
    <h4><a href="https://github.com/datafleets/horizontal-federated-learning-blog/blob/master/horizontal-fl.ipynb" target="_blank" rel="nofollow noopener">datafleets/horizontal-federated-learning-blog/blob/master/horizontal-fl.ipynb</a></h4>
<pre><code class="lang-ipynb">{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Federated averaging with non-IID data in multiple silos\n",
    "\n",
    "This notebook explores the robustness of model/gradient averaging with respect to varying degrees of non-iid'ness and different data partitioning schemes."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import warnings\n",
    "import math\n",
    "import random\n",
</code></pre>

  This file has been truncated. <a href="https://github.com/datafleets/horizontal-federated-learning-blog/blob/master/horizontal-fl.ipynb" target="_blank" rel="nofollow noopener">show original</a>

  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>


ptrblck: <p><code>sklearn.metrics.precision_score</code> uses the <code>binary</code> average by default, which is only defined for the binary use case.<br>
For multi-class/-label classification, you would have to define one of the suggested average settings.<br>
<a href="https://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_score.html">The docs</a> give you some information about each <code>average</code>.</p>

NickNack2020: <p>Hey mohammed_ibrahim<br>
I’m one of the cofounders of <a href="http://www.datafleets.com" rel="nofollow noopener">DataFleets</a>.<br>
Way to dive in on Federated Learning…was your question sufficiently addressed?<br>
-Nick</p>

mohammed_ibrahim: <p>Hey Nick</p>
<p>unfortunately no, I want to use the code but for 6 classes? Such that the prediction falls into one of the classes or activities (walking, walkingupstairs, walkingdownstairs, sitting, standing, lying).</p>
<aside class="onebox allowlistedgeneric">
  <header class="source">
      <img src="https://www.kaggle.com/static/images/favicon.ico" class="site-icon" width="32" height="32">
      <a href="https://www.kaggle.com/uciml/human-activity-recognition-with-smartphones" target="_blank" rel="nofollow noopener">kaggle.com</a>
  </header>
  <article class="onebox-body">
    <img src="https://storage.googleapis.com/kaggle-datasets-images/226/478/11ff0be5a773e73886c3da626349e8f0/dataset-card.jpeg" class="thumbnail onebox-avatar" width="500" height="500">

<h3><a href="https://www.kaggle.com/uciml/human-activity-recognition-with-smartphones" target="_blank" rel="nofollow noopener">Human Activity Recognition with Smartphones</a></h3>

<p>Recordings of 30 study participants performing activities of daily living</p>


  </article>
  <div class="onebox-metadata">
    
    
  </div>
  <div style="clear: both"></div>
</aside>

<p>Any advice or solution is highly appreciated.</p>