File size: 10,237 Bytes
b467d9f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
from datasets import load_dataset
import gradio as gr
import pandas as pd

dataset = load_dataset(
    "praisethefool/dca-distroid_digest-issue_44",
    keep_default_na=False)

df = pd.DataFrame(dataset['train'])

for x in df.columns:

  if 'fields' in x:

    y = x.replace('fields.', '')

    y = y.lower()

    df.rename({x:y}, axis = 'columns', inplace=True)
  else:
    y = x.lower()

    df.rename({x:y}, axis = 'columns', inplace=True)

description = """
# Overview
This Gradio demo was developed to show how end-users could be empowered to create their own personalized feeds by customizing algorithmic recommendation systems.

In this demo, I focused on how readers of the Distroid Digest could personalize the [Distroid Digest](https://distroid.substack.com/) to fit their needs by customizing the Distroid Curator Algorithm (DCA),
the (planned) curation algorithm used by curators for curating Works collected in the Distroid Catalogue Knowledge Graph (DCKG) into the Distroid Digest newsletter issues.

The DCA’s objective is to produce a ranked feed of items (here being Works in the DCKG) that increase understanding of frontier information.
More specifically, increasing understanding of how to diagnose and improve the human-technology relationship.

We assume that items with higher scores have the potential to provide readers with a greater understanding of frontier information than items with a lower score.

For DCA Version 0.1 (V0.1), Works are rated based on the following six quality signals:

1. ELI5: "The ability to explain complex topics in lay-man's terms",

2. Implications: "The real, imagined, or theorized positive, neutral, or negative outcomes (or impacts) of frontier information (or discoveries, technologies, and cultures) on society, environment, economy, or in other areas." ,

3. Idea Machine Intersectionality: "The number of idea machines the work is classified under.",

4. Novelty: "New knowledge that moves the knowledge frontier.",

5. Informative: "The content improved my understanding of a topic.", and

6. Evergreen: "Knowledge that is applicable regardless of time or location".

# Dataset

I used the Works curated in [Distroid Digest Issue 44](https://distroid.substack.com/p/digest-issue-44-how-bluesky-works) for this demo.

# Objective Function

In this demo, the objective function is a weighted sum formula, where weights
between zero and twenty (0-20) are applied to the ratings of each signal.

# Functionality

1. Users can customize the feed by setting the weights from zero to twenty (0-20) for each marker described above.
2. Users can set a minimum DCA score for Works to be added to their feed.

# Tips & Tricks
If you think a signal should not be included in your feed, you can set that marker's weight to zero (0).

# Learn more

You can read more about the early work on the DCA [here](https://ledgerback.pubpub.org/pub/9ibht7wp/release/8).

For background information on recommender systems, please read [Recommender Systems 101](https://kgi.georgetown.edu/wp-content/uploads/2025/02/Recommender-Systems-101.pdf).

# Related Work
Related work on creating alternative feeds and newsletters can be found below:

1. [Fedi-Feed](https://foryoufeed.vercel.app/login)
2. [News Minimalist](https://www.newsminimalist.com/)
3. [Building a Social Media Algorithm That Actually Promotes Societal Values](https://hai.stanford.edu/news/building-social-media-algorithm-actually-promotes-societal-values)
4. [PDN Pro-Social with Smitha Milli: Ranking by User Value](https://www.youtube.com/watch?v=6ltsAT5RUrI)

# Outputs

1. DCA Objective Function: The current objective function after the parameters are set.
2. DCA Scores: A table of Works sorted by their DCA score in the Score column. Also includes the Work's title and url.
3. Scores per Signal: A table showing the scores for each signal after setting the weights.

# Caveats

1. The Works are pre-rated, so you cannot edit the ratings per marker.
2. The Weights and Minimum Score ranges are pre-set.
3. In the Scores per Signal tab, Idea Machine Interserctionality has been shortened to 'imi'.
"""

def grad_wg_int(
    w_nov, #Novelty Wgt
    w_eve, #Evergreen,
    w_inf, #Informative,
    w_imi, #Implications
    w_eli, #ELI5
    w_imp, #Implications
    min_score
  ):

  muse = []

  weights = {
      "w_nov": w_nov,
      "w_eve": w_eve,
      "w_inf": w_inf,
      "w_imi": w_imi,
      "w_eli": w_eli,
      "w_imp": w_imp,
  }

  dc_algo_mk = zip(df['novelty'],
                  df['evergreen'],
                  df['informative'],
                  df['idea machine intersectionality'],
                  df['eli5'],
                  df['implications'],
                  df['title'],
                  df['url'],
                  )

  for m_nov, m_eve, m_inf, m_imi, m_eli, m_imp, title, url in dc_algo_mk:

    score_nov = weights['w_nov'] * int(m_nov)

    score_eve = weights['w_eve'] * int(m_eve)

    score_inf = weights['w_inf'] * int(m_inf)

    score_imi = weights['w_imi'] * int(m_imi)

    score_eli = weights['w_eli'] * int(m_eli)

    score_imp = weights['w_imp'] * int(m_imp)


    # need to save the weight and score for each marker into
    # a table with key included
    rank_sum = (score_nov +
                score_eve +
                score_inf +
                score_imi +
                score_eli +
                score_imp)
    
    rank_sum = round(float(rank_sum), 2)


    score_rank = {
        "Score": rank_sum,
        "Title": title,
        'URL': url,
    }

    muse.append(score_rank)

  tug = pd.DataFrame(muse)

  tug = tug.query(f"Score >= {min_score}")

  tug.sort_values('Score', ascending=False, inplace=True)

  return tug

def grad_wg_int_scr(
    w_nov, #Novelty Wgt
    w_eve, #Evergreen,
    w_inf, #Informative,
    w_imi, #Idea Machine Intersectionality
    w_eli, #ELI5
    w_imp, #Implications
  ):

  weights = {
      "w_nov": w_nov,
      "w_eve": w_eve,
      "w_inf": w_inf,
      "w_imi": w_imi,
      "w_eli": w_eli,
      "w_imp": w_imp,
  }

  df_ = df.copy()

  df_['novelty'] = df['novelty'] * weights['w_nov']

  df_['evergreen'] = weights['w_eve'] * df['evergreen']

  df_['informative'] = weights['w_inf'] * df['informative']

  df_['idea machine intersectionality'] = df['idea machine intersectionality'] * weights['w_imi']

  df_['eli5'] = df['eli5'] * weights['w_eli']

  df_['implications'] = df['implications'] * weights['w_imp']
 
  df_.rename({'idea machine intersectionality': 'imi'}, axis='columns', inplace=True)
  
  df_.drop(['url', 'likeable'], axis='columns', inplace=True)

  df_ = df_.round(1)

  return df_

def grad_wg_int_form(
    w_nov, #Novelty Wgt
    w_eve, #Evergreen,
    w_inf, #Informative,
    w_imi, #Implications
    w_eli, #ELI5
    w_imp, #Implications

  ):

  weights = {
      "w_nov": w_nov,
      "w_eve": w_eve,
      "w_inf": w_inf,
      "w_imi": w_imi,
      "w_eli": w_eli,
      "w_imp": w_imp,
  }

  formula_a = f"""
  ({weights['w_nov']} * Novelty) + ({weights['w_eve']} * Evergreen) + \n\n
  ({weights['w_inf']} * Informative) + ({weights['w_eli']} * ELI5) + \n\n
  ({weights['w_imp']} * Implications) + ({weights['w_imi']} * Idea Machine Intersectionality)
  """

  return formula_a

with gr.Blocks(fill_width=True) as demo:

    gr.Markdown('# Welcome to the DCA Personalized Feed Demo')

    with gr.Row():

      with gr.Accordion():

        gr.Markdown(description)

    with gr.Row():

      with gr.Sidebar():

        gr.Markdown("### Customize")

        tune_eli = gr.Slider(0.00, 20.00, value=1, label="ELI5 Weight", info="Choose between 0 and 20")
        
        tune_evg = gr.Slider(0.00, 20.00, value=1, label="Evergreen Weight", info="Choose between 0 and 20")
        
        tune_inf = gr.Slider(0.00, 20.00, value=1, label="Informative Weight", info="Choose between 0 and 20")
        
        tune_imp = gr.Slider(0.00, 20.00, value=1, label="Implications Weight", info="Choose between 0 and 20")
        
        tune_nov = gr.Slider(0.00, 20.00, value=1, label="Novelty Weight", info="Choose between 0 and 20")
        
        tune_imi = gr.Slider(0.00, 20.00, value=1, label="Idea Machine Intersectionality Weight", info="Choose between 0 and 20")

        tune_min = gr.Slider(0.00, 50.00, value=1, label="Minimum DCA Score", info="Choose between 0 and 50")

        text_button = gr.Button(value="Set Parameters")

        clear_button = gr.ClearButton(value="Clear Parameters")

      with gr.Column(scale=3):

        form_plot = gr.Label(label="DCA Objective Function")

        text_button.click(grad_wg_int_form,
                        inputs=[
                            tune_nov,
                            tune_evg,
                            tune_inf,
                            tune_eli,
                            tune_imi,
                            tune_imp,
                        ],
                        outputs=[form_plot])

        with gr.Tab("Scores per Signal"):

          output_df = gr.DataFrame(
              wrap = True,
              show_search='filter',
              show_copy_button = True,
              show_fullscreen_button=True )


          text_button.click(
              grad_wg_int_scr,
              inputs=[
                tune_nov,
                tune_evg,
                tune_inf,
                tune_eli,
                tune_imi,
                tune_imp,
              ],
              outputs=[output_df])


        with gr.Tab("Feed"):


          output_df = gr.DataFrame(
              wrap = True,
              show_search='filter',
              show_copy_button = True,
              show_fullscreen_button=True )


          text_button.click(
              grad_wg_int,
              inputs=[
                tune_nov,
                tune_evg,
                tune_inf,
                tune_eli,
                tune_imi,
                tune_imp,
                tune_min,
              ],
              outputs=[output_df])

          clear_button.add([
              tune_eli,
              tune_evg,
              tune_inf,
              tune_imp,
              tune_nov,
              tune_imi,
              tune_min,
          ])


if __name__ == "__main__":
    demo.launch()