Skip to content

Commit

Permalink
Merge pull request #165 from kandrio/kandrio-prune-gossipml-and-peerchat
Browse files Browse the repository at this point in the history
Prune the `gossipML` and `Peerchat` modules
  • Loading branch information
InvictusRMC authored Aug 28, 2023
2 parents 04e21d2 + 3be76bf commit 1894dcf
Show file tree
Hide file tree
Showing 170 changed files with 91 additions and 6,272 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ build
*.iml
local.properties
.gradle
gossipML/.cxx
**.project
**.settings
**.classpath
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "kotlin-ipv8"]
path = kotlin-ipv8
url = https://github.com/Tribler/kotlin-ipv8.git
[submodule "gossipML/superapp-essentia"]
path = gossipML/superapp-essentia
url = https://github.com/Tribler/superapp-essentia.git
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,6 @@ Video 1: <a href="doc/musicdao/thesis2.mp4">Load example.</a> This uses a defaul

Video 2: <a href="doc/musicdao/thesis3.mp4">Share track.</a> Note: as a fresh magnet link is generated in this video, there is only 1 peer. For this reason it will be difficult to obtain the metadata of the magnet link (cold start issue, write about this in thesis) so the video stops there.

### Federated, privacy-preserving music recommendations via gossiping

This is a demonstration of machine learning which relies exclusively on edge computing. Music recommendation inside the MusicDAO is used to demonstrate gossip-based machine learning.

Every time a user opens MusicDAO, they are asked to reload the page in order to get recommendations. The recommendation engine yields two recommendations made by two different models: a musical feature-based model and a collaborative filtering model. The collaborative filtering model is based on federated matrix factorization as introduced in [this paper](https://dmle.iais.fraunhofer.de/papers/hegedus2019decentralized.pdf). The feature-based models are from this [paper](https://arxiv.org/pdf/1109.1396.pdf), called Adaline and Pegasos. These models are trained on audio features extracted from music files with the [Essentia library](https://essentia.upf.edu/).
<img src="gossipML/docs/imgs/overview.png" height="400px">

The feature-based models are gossiped along random walks through the network. At each peer they are merged and re-trained on peer's local data. The matrix factorization model seeks to learn a factorization of the user-song matrix. This means that one of the two factors contains only information on how users generally rate each song. This matrix can then be gossiped around the network while a user's personal vector as well as their listening history are kept private.
- [More about federated machine learning using gossiping for music recommendations](gossipML/README.md)

### Do you want to add your own app?

- [Adding your own app to the TrustChain Super App](doc/AppTutorial.md)
Expand Down
4 changes: 0 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ allprojects {
dependencies {
implementation project(':debug')
implementation project(':freedomOfComputing')
implementation project(':peerchat')
implementation project(':eurotoken')
implementation project(':valuetransfer')
api(project(':common')) {
Expand All @@ -125,9 +124,6 @@ dependencies {
api(project(':musicdao')) {
exclude group: 'net.java.dev.jna'
}
api(project(':gossipML')) {
exclude group: 'net.java.dev.jna'
}

implementation 'org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0-M1-1.4.0-rc'

Expand Down
5 changes: 0 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@
android:name="nl.tudelft.trustchain.debug.DebugActivity"
android:parentActivityName=".ui.dashboard.DashboardActivity" />

<activity
android:name="nl.tudelft.trustchain.peerchat.PeerChatActivity"
android:parentActivityName=".ui.dashboard.DashboardActivity"
android:theme="@style/Theme.PeerChat" />

<activity
android:name="nl.tudelft.trustchain.eurotoken.EuroTokenMainActivity"
android:parentActivityName=".ui.dashboard.DashboardActivity"
Expand Down
7 changes: 0 additions & 7 deletions app/src/main/java/nl/tudelft/trustchain/app/AppDefinition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import nl.tudelft.trustchain.FOC.MainActivityFOC
import nl.tudelft.trustchain.common.R
import nl.tudelft.trustchain.debug.DebugActivity
import nl.tudelft.trustchain.eurotoken.EuroTokenMainActivity
import nl.tudelft.trustchain.peerchat.PeerChatActivity
import nl.tudelft.trustchain.valuetransfer.ValueTransferMainActivity

enum class AppDefinition(
Expand All @@ -18,12 +17,6 @@ enum class AppDefinition(
val activity: Class<out Activity>,
val disableImageTint: Boolean = false,
) {
PEERCHAT(
R.drawable.ic_chat_black_24dp,
"PeerChat",
R.color.purple,
PeerChatActivity::class.java
),
DEBUG(
R.drawable.ic_bug_report_black_24dp,
"Debug",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,10 @@ import nl.tudelft.trustchain.common.eurotoken.TransactionRepository
import nl.tudelft.trustchain.musicdao.core.dao.CoinCommunity
import nl.tudelft.trustchain.eurotoken.community.EuroTokenCommunity
import nl.tudelft.trustchain.eurotoken.db.TrustStore
import nl.tudelft.trustchain.gossipML.RecommenderCommunity
import nl.tudelft.trustchain.gossipML.db.RecommenderStore
import nl.tudelft.trustchain.peerchat.community.PeerChatCommunity
import nl.tudelft.trustchain.peerchat.db.PeerChatStore
import nl.tudelft.trustchain.valuetransfer.community.PeerChatCommunity
import nl.tudelft.trustchain.valuetransfer.util.PeerChatStore
import nl.tudelft.trustchain.valuetransfer.community.IdentityCommunity
import nl.tudelft.trustchain.valuetransfer.db.IdentityStore
import nl.tudelft.gossipML.sqldelight.Database as MLDatabase

val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "settings")

Expand Down Expand Up @@ -110,7 +107,6 @@ class TrustChainApplication : Application() {
createCoinCommunity(),
createDaoCommunity(),
createMusicCommunity(),
createRecommenderCommunity(),
createIdentityCommunity(),
createFOCCommunity(),
),
Expand Down Expand Up @@ -339,23 +335,6 @@ class TrustChainApplication : Application() {
)
}

@OptIn(DelicateCoroutinesApi::class) // TODO: Verify whether usage is correct.
private fun createRecommenderCommunity(): OverlayConfiguration<RecommenderCommunity> {
val settings = TrustChainSettings()
val musicDriver = AndroidSqliteDriver(Database.Schema, this, "music.db")
val musicStore = TrustChainSQLiteStore(Database(musicDriver))
val driver = AndroidSqliteDriver(MLDatabase.Schema, this, "recommend.db")
val database = MLDatabase(driver)

val recommendStore = RecommenderStore.getInstance(musicStore, database)
recommendStore.essentiaJob = GlobalScope.launch { recommendStore.addAllLocalFeatures() }
val randomWalk = RandomWalk.Factory()
return OverlayConfiguration(
RecommenderCommunity.Factory(recommendStore, settings, musicStore),
listOf(randomWalk)
)
}

private fun createFOCCommunity(): OverlayConfiguration<FOCCommunity> {
val randomWalk = RandomWalk.Factory()
return OverlayConfiguration(
Expand Down
9 changes: 1 addition & 8 deletions app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,10 @@
android:layout_width="match_parent"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="@id/bottomNavigation"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="@navigation/nav_graph_dashboard" />

<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/light_gray"
app:layout_constraintBottom_toBottomOf="parent"
app:menu="@menu/peerchat_navigation_menu" />
</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ buildscript {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

// TODO: Find a way to move this to trustchain-trader (gossipML relies on this too)
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
}
}
Expand Down
1 change: 0 additions & 1 deletion gossipML/.gitignore

This file was deleted.

87 changes: 0 additions & 87 deletions gossipML/README.md

This file was deleted.

Loading

0 comments on commit 1894dcf

Please sign in to comment.