DaskLGBMClassifier.fit() error: 'Future' object has no attribute 'get_params' - python

I'm trying LGBM's Dask API and when I fit DaskLGBMClassifier I get the following error:
'Future' object has no attribute 'get_params'
I tried to deug it working on the original code. The variable model that you can see in the error reference that Colab should be an instance of the class LGBMModel, which seems to have the method get_params().
Why does it say that get_params is an attribute? What is a 'Future' object?
this is the image of the error image of error , this the model=_train, this the _train function, this the LGBMModel adn finally the get param function.

Related

Pymongo error while trying to call distinct on a collection

I'm getting this weird error. I am following the documentation closely and don't understand what I am doing wrong. I pasted an minimal example to replicate the error. Any tip to this fix?
Error message:
TypeError: 'Collection' object is not callable. If you meant to call the 'dictinct' method on a 'Collection' object it is failing because no such method exists.
Code:
import pymongo
client = pymongo.MongoClient('mongodb://localhost:27017')
detached = client['realestate'].detached
print(detached.dictinct('key_facts-build_year'))
You have a typo; the method is distinct() (not dictinct())

Attribute Error: 'Embedding' object has no attribute 'embeddings' - TensorFlow & Keras

Okay so I have a keras model that I fully ran and then saved the weights with this line:
model.save_weights("rho_beta_true_tf", save_format="tf")
Then in another file I build just the model and then I load the weights from the model I ran above using this line:
model_build.load_weights("rho_beta_true_tf")
When I then go to call some of the attributes everything displays correctly except when I try to run this line:
model_build.stimuli.embeddings
or
model_build.stimuli.embeddings.numpy()[0]
I get an attribute error saying:
AttributeError: 'Embedding' object has no attribute 'embeddings'
This line is supposed to return a tensor and if I call any other attributes so far it works so I am not sure if it just can't find the tensors or if the problem is something else. Could someone please help me figure out how to solve this attribute Error?
Try using .get_weights():
model_build.stimuli.get_weights()
Turns out that because I had saved the weights in tf format I had to follow this step in the tensor flow documentation:
For user-defined classes which inherit from tf.keras.Model, Layer instances must be assigned to object attributes, typically in the constructor.
So then the line
build_model.stimuli.embedding(put the directory path to your custom embedding layer here)
worked!

I am running the code below in python and getting the error 'AttributeError: 'QgridWidget' object has no attribute 'to_excel''

I am trying to use to excel function using the code below. I am getting the error df.to_excel('dataset1.xlsx')
Below is the code.
df=qgrid.show_grid(data)
df.to_excel('dataset1.xlsx')
qgrid.show_grid() returns a QgridWidget instance. You can access the underlying dataframe using the df attribute:
grid = qgrid.show_grid(data)
grid.df.to_excel('dataset1.xlsx')

'dict' object is not callable error - when I'm not using any 'dict's in networkx

I'm using Python to work with networkx and draw some graphs.
I ran into a problem raising:
TypeError: 'dict' object is not callable
on this line of code:
set_node_color(num, list(Graph.node()))
I searched to find that this error is raised when I'm using a variable name dict.
The problem is, I'm not using any variables with the name dict, nor am I using any dictionary types anywhere in the code.
In case it's necessary, printing the type of Graph gives <class 'networkx.classes.digraph.Digraph'>.
I also tried printing the type for Graph.node() only to receive the same error, telling me 'dict' object is not callable.
So I suspect Graph.node() to be a dict type variable, but using (Graph.node()).items() raises the same TypeError.
Any help or advices would be nice. Thanks.
Maybe Graph.node is a dict object, so Graph.node() is not callable.

AttributeError: 'tuple' object has no attribute 'shape'

So I have been writing a code to standardize the elements of a matrix and the function I used is as follows:
def preprocess(Data):
if stdn ==True:
st=np.empty((Data.shape[0],Data.shape[1]))
for i in xrange(0,Data.shape[0]):
st[i,0]=Data[i,0]
for i in xrange(1,Data.shape[1]):
st[:,i]=((Data[:,i]-np.min(Data[:,i]))/(np.ptp(Data[:,i])))
np.random.shuffle(st)
return st
else:
return Data
It works very well outside the class but when used inside of it it gives me this error:
AttributeError: 'tuple' object has no attribute 'shape'
Any idea on how I can fix it??
P.S. This is a KNN classification code
According to the error you posted, Data is of type tuple and there is no attribute shape defined for data. You could try casting Data when you call your preprocess function, e.g.:
preprocess(numpy.array(Data))

Categories