Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'networkx' has no attribute 'from_numpy_matrix'

A is co occurrence dataframe. Why it shown AttributeError: module 'networkx' has no attribute 'from_numpy_matrix'

import numpy as np
import networkx as nx
import matplotlib
A=np.matrix(coocc)
G=nx.from_numpy_matrix(A)
like image 375
Pranab Avatar asked Dec 22 '25 11:12

Pranab


2 Answers

It was updated to nx.from_numpy_array(A)

like image 148
ImanB Avatar answered Dec 23 '25 23:12

ImanB


In networkx 3.0 the changelog shows the following "Remove to_numpy_matrix & from_numpy_matrix (#5746)" https://networkx.org/documentation/stable/release/release_3.0.html

You have to downgrade networkx or use G=nx.from_numpy_array(A) instead. https://networkx.org/documentation/stable/reference/readwrite/matrix_market.html

like image 20
tetris programming Avatar answered Dec 24 '25 00:12

tetris programming



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!