• Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy
Thursday, February 26, 2026
newsaiworld
  • Home
  • Artificial Intelligence
  • ChatGPT
  • Data Science
  • Machine Learning
  • Crypto Coins
  • Contact Us
No Result
View All Result
  • Home
  • Artificial Intelligence
  • ChatGPT
  • Data Science
  • Machine Learning
  • Crypto Coins
  • Contact Us
No Result
View All Result
Morning News
No Result
View All Result
Home Artificial Intelligence

Information Science Meets Politics. Unraveling Congressional Dynamics With… | by Luiz Venosa | Sep, 2024

Admin by Admin
September 28, 2024
in Artificial Intelligence
0
1xck2v X8yhm87y8cgztnxw.jpeg
0
SHARES
0
VIEWS
Share on FacebookShare on Twitter

READ ALSO

Scaling Characteristic Engineering Pipelines with Feast and Ray

Optimizing Token Era in PyTorch Decoder Fashions


Initially, we want information.

I downloaded information on all of the legal guidelines voted on and the way every member of Congress voted from 2023 to 2024 as much as Might 18th. All the information is offered on the Brazilian Congress’s open information portal. I then created two completely different pandas dataframes, one with all of the legal guidelines voted on and one other with how every congress member voted in every vote.

votacoes = pd.concat([pd.read_csv('votacoes-2023.csv', header=0, sep=';'),  pd.read_csv('votacoes-2024.csv', header=0, sep=';')])
votacoes_votos_dep = pd.concat([pd.read_csv('votacoesVotos-2023.csv', sep=';', quoting=1) , pd.read_csv('votacoesVotos-2024.csv', sep=';', on_bad_lines='warn', quoting=1, encoding='utf-8')])

To the votacoes dataframe, I chosen solely the entries with idOrgao of 180, which implies they had been voted in the principle chamber of Congress. So, we now have the information for the votes of most congress members. Then I used this the checklist of the votacoes_Ids to filter the votacoes_votos_dep dataframe.

plen = votacoes[votacoes['idOrgao'] == 180]
votacoes_ids = plen['id'].distinctive()
votacoes_votos_dep = votacoes_votos_dep[votacoes_votos_dep['idVotacao'].isin(votacoes_ids)]

Now, within the votacoes_votos_dep, every vote is a row with the congress member’s identify and the voting session ID to establish who and what the vote refers to. Subsequently, I created a pivot desk so that every row represents a congress member and every column refers to a vote, encoding Sure as 1 and No as 0 and dropping any vote the place greater than 280 deputies didn’t vote.

votacoes_votos_dep['voto_numerico'] = votacoes_votos_dep['voto'].map({'Sim': 1, 'Não':0})
votes_pivot = votacoes_votos_dep.pivot_table(index='deputado_nome', columns='idVotacao', values='voto_numerico').dropna(axis=1, thresh=280)

Earlier than computing the similarity matrix, I crammed all remaining NAs with 0.5 in order to not intervene with the positioning of the congress member. Lastly, we compute the similarity between the vectors of every deputy utilizing cosine similarity and retailer it in a dataframe.

from sklearn.metrics.pairwise import cosine_similarity
similarity_matrix = cosine_similarity(votes_pivot)
similarity_df = pd.DataFrame(similarity_matrix, index=votes_pivot.index, columns=votes_pivot.index)
Similarity Matrix – Picture By the Creator

Now, use the details about the voting similarities between congressmen to construct a community utilizing Networkx. A node will symbolize every member.

import networkx as nx

names = similarity_df.columns
# Create the graph as earlier than
G = nx.Graph()
for i, identify in enumerate(names):
G.add_node(identify)

Then, the perimeters connecting two nodes symbolize a similarity of at the very least 75% of the 2 congressmen’s voting habits. Additionally, to deal with the truth that some congress members have dozens of friends with excessive levels of similarity, I solely chosen the primary 25 congressmen with the very best similarity to be given an edge.

threshold = 0.75
for i in vary(len(similarity_matrix)):
for j in vary(i + 1, len(similarity_matrix)):
if similarity_matrix[i][j] > threshold:
# G.add_edge(names[i], names[j], weight=similarity_matrix[i][j])
counter[names[i]].append((names[j], similarity_matrix[i][j]))
for supply, goal in counter.objects():
selected_targets = sorted(goal, key=lambda x: x[1], reverse=True)[:26]
for goal, weight in selected_targets:
G.add_edge(supply, goal, weight=weight)

To visualise the community, you should determine the place of every node within the aircraft. I made a decision to make use of the spring structure, which makes use of the perimeters as springs holding nodes shut whereas attempting to separate. Including a seed permits for reproducibility since it’s a random course of.

pos = nx.spring_layout(G, ok=0.1,  iterations=50, seed=29)

Lastly, we plot the community utilizing a Go determine and individually add the perimeters and nodes based mostly on their place.


# Create Edges
edge_x = []
edge_y = []
for edge in G.edges():
x0, y0 = pos[edge[0]]
x1, y1 = pos[edge[1]]
edge_x.prolong([x0, x1, None])
edge_y.prolong([y0, y1, None])

# Add edges as a scatter plot
edge_trace = go.Scatter(x=edge_x, y=edge_y, line=dict(width=0.5, colour='#888'), hoverinfo='none', mode='strains')
# Create Nodes
node_x = []
node_y = []
for node in G.nodes():
x, y = pos[node]
node_x.append(x)
node_y.append(y)

# Add nodes as a scatter plot
node_trace = go.Scatter(x=node_x, y=node_y, mode='markers+textual content', hoverinfo='textual content', marker=dict(showscale=True, colorscale='YlGnBu', measurement=10, colour=[], line_width=2))

# Add textual content to the nodes
node_trace.textual content = checklist(G.nodes())

# Create a determine
fig = go.Determine(information=[edge_trace, node_trace],
structure=go.Structure(showlegend=False, hovermode='closest', margin=dict(b=0,l=0,r=0,t=0), xaxis=dict(showgrid=False, zeroline=False, showticklabels=False), yaxis=dict(showgrid=False, zeroline=False, showticklabels=False)))

fig.present()

End result:

Picture by the Creator

Nicely, it’s a great begin. Totally different clusters of congressmen might be seen, which means that it precisely captures the political alignment and alliances in Congress. However it’s a mess, and it’s inconceivable to essentially discern what’s happening.

To enhance the visualization, I made the identify seem solely while you hover over the node. Additionally, I coloured the nodes in accordance with the political events and coalitions obtainable on Congress’s web site and sized them based mostly on what number of edges they’re linked to.

Picture by the Creator

It’s lots higher. We have now three clusters, with some nodes between them and some greater ones in every. Additionally, in every cluster, there’s a majority of a specific colour. Nicely, let’s dissect it.

Tags: CongressionalDataDynamicsLuizMeetsPoliticsScienceSepUnravelingVenosa

Related Posts

Alain pham p qvsf7yodw unsplash.jpg
Artificial Intelligence

Scaling Characteristic Engineering Pipelines with Feast and Ray

February 25, 2026
1 1 1.jpeg
Artificial Intelligence

Optimizing Token Era in PyTorch Decoder Fashions

February 25, 2026
Comp 23 0 00 09 03.jpg
Artificial Intelligence

Is the AI and Knowledge Job Market Lifeless?

February 24, 2026
Image 143.jpg
Artificial Intelligence

Construct Efficient Inner Tooling with Claude Code

February 23, 2026
Lucid origin modern flat vector illustration of ai coding while security shields around an ap 0.jpg
Artificial Intelligence

The Actuality of Vibe Coding: AI Brokers and the Safety Debt Disaster

February 23, 2026
Chatgpt image feb 18 2026 at 08 49 33 pm.jpg
Artificial Intelligence

AI in A number of GPUs: How GPUs Talk

February 22, 2026
Next Post
0ey3ijiwnn5s Vdcv.jpeg

Depth-First Search — Elementary Graph Algorithm | by Robert Kwiatkowski | Sep, 2024

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

POPULAR NEWS

Chainlink Link And Cardano Ada Dominate The Crypto Coin Development Chart.jpg

Chainlink’s Run to $20 Beneficial properties Steam Amid LINK Taking the Helm because the High Creating DeFi Challenge ⋆ ZyCrypto

May 17, 2025
Gemini 2.0 Fash Vs Gpt 4o.webp.webp

Gemini 2.0 Flash vs GPT 4o: Which is Higher?

January 19, 2025
Image 100 1024x683.png

Easy methods to Use LLMs for Highly effective Computerized Evaluations

August 13, 2025
Blog.png

XMN is accessible for buying and selling!

October 10, 2025
0 3.png

College endowments be a part of crypto rush, boosting meme cash like Meme Index

February 10, 2025

EDITOR'S PICK

Statology primer header 5.png

Visualizing Information: A Statology Primer

July 24, 2024
How to implement the right test data management strategy for your organization 1.jpg

Information Privateness Is not Sufficient: Why We Want Efficiency-Grade Check Information Administration

August 30, 2025
Gemini gen cover.jpg

How one can Preserve MCPs Helpful in Agentic Pipelines

January 5, 2026
Top Ai Agent Frameworks Developers .webp.webp

High AI Agent Frameworks Builders Ought to Know in 2025

February 24, 2025

About Us

Welcome to News AI World, your go-to source for the latest in artificial intelligence news and developments. Our mission is to deliver comprehensive and insightful coverage of the rapidly evolving AI landscape, keeping you informed about breakthroughs, trends, and the transformative impact of AI technologies across industries.

Categories

  • Artificial Intelligence
  • ChatGPT
  • Crypto Coins
  • Data Science
  • Machine Learning

Recent Posts

  • Grounded PRD Era with NotebookLM
  • Breaking the Host Reminiscence Bottleneck: How Peer Direct Reworked Gaudi’s Cloud Efficiency
  • Finest Crypto Buying and selling Alerts Telegram Teams to Take part 2026
  • Home
  • About Us
  • Contact Us
  • Disclaimer
  • Privacy Policy

© 2024 Newsaiworld.com. All rights reserved.

No Result
View All Result
  • Home
  • Artificial Intelligence
  • ChatGPT
  • Data Science
  • Machine Learning
  • Crypto Coins
  • Contact Us

© 2024 Newsaiworld.com. All rights reserved.

Are you sure want to unlock this post?
Unlock left : 0
Are you sure want to cancel subscription?