Tensorflow Wide & Deep Example Not Working - python

I am trying to get the Wide & Deep tutorial working but the following line keeps giving me issues when copying and pasting the code from github and the website.
df_train["income_bracket"].apply(lambda x: ">50K" in x)).astype(int)
I get the below error
TypeError: argument of type 'float' is not iterable
I am not too familar with lamda functions but I think it is making a dummy variable so I tried that using
for i in range(len(df_train)):
if df_train.loc[i,'income_bracket']=='>50k':
df_train.loc[i,LABEL_COLUMN] =1
else:
df_train.loc[i,LABEL_COLUMN] =0
But got the error
TypeError: Expected binary or unicode string, got nan
How do I get this tutorial working?
EDIT:
first line of data and headers

lambda function is quite useful and simple. It won't create dummy variables.
I've noticed that you import the original data into a CSV file. Try not do that and just use the original downloading data that shown in tutorial code. I have successfully tried in this way.
But I also got the same problem when I change to other data sets for training. So I still hope someone can solve this problem in a deeper way

It's the issue of the data, or the code of TensorFlow. We have submit the issue about that in https://github.com/tensorflow/tensorflow/issues/4293
You can download the files manually and remove the broken lines. Then run with this command.
python ./wide_n_deep_tutorial.py --train_data /home/data/train_data --test_data /home/data/test_data

Related

How do you fix an attribute error when using "fillpdfs.write_fillable_pdf"?

I am trying to fill out the rest of a partially filled out pdf form, however, when I try to update some of the values in the form using "fillpdfs", I receive a Attribute Error stating: 'NoneType' object has no attribute 'update'. Any help in understanding this issue would be fantastic! I have attached a full screen shot of the error.
I have tried uninstalling and reinstalling the modules however this did not work. I have also tried changing the names of the pdf files themselves.
There are a few possible causes for this error:
The write_fillable_pdf function might not be defined. Make sure that you have correctly imported the fillpdf library and that you are using the correct function name.
The write_fillable_pdf function might be expecting certain arguments, and you are not providing them. Make sure that you are passing the correct number and type of arguments to the function.
The write_fillable_pdf function might be trying to access an attribute or property that does not exist. Make sure that you are providing the correct data to the function and that the data you are using has the required attributes.
To troubleshoot this error further, you can try the following:
Check the documentation for the fillpdf library to make sure you are using the correct function name and arguments.
Check the stack trace of the error to see which line of code is causing the issue. This can help you identify which part of your code is causing the problem.
Print out the values of the arguments that you are passing to the write_fillable_pdf function to make sure they are correct.
Add some debug statements to your code to print out the value of any attributes that the write_fillable_pdf function is trying to access.

Error Pegasus package: TypeError: highly_variable_features() got an unexpected keyword argument 'consider_batch'

I am using Pagesus package to analyze my single cell RNA sequencing data. I have encountered the following error using the Pegasus package for single cell analysis. The function that is giving me the error seems to be:
highly_variable_features(data, consider_batch=True)
and the error is
TypeError: highly_variable_features() got an unexpected keyword argument 'consider_batch'. after executing
I am very novice with using python and this package. I haven't been able to find any explanation when looking through Github and Pegasus package tutorials.
I appreciate your advice on this
Regards,
the pagesus docs for this function: highly_variable_features do not mention keyword/parameter you passed in and thats how you getting that error.
Please look at this docs:
https://pegasus.readthedocs.io/en/stable/api/pegasus.highly_variable_features.html?highlight=highly_variable_features
You should read docs more carefully, and try to learn basics Errors in Python and where they come from. This will help in the future to solve errors like this.

"HTTPError: HTTP Error 404: Not Found" while using translation function in TextBlob

When I try to use translate function in TextBlob library in jupyter notebook, I get:
HTTPError: HTTP Error 404: Not Found
I have posted my code and screenshot of error message for reference here. This code worked well 5-6 days ago when I ran exactly the same code first time but after that whenever I run this code it gives me the same error message. I have been trying to run this code since last 4-5 days but it never worked again.
My code:
from textblob import TextBlob
en_blob = TextBlob('Simplilearn is one of the world’s leading certification training providers.')
en_blob.translate(to='es')
I am new to stackoverflow and asking my first question on this plateform so please pardon me if I my question is not following rules of this platform.
Textblob library uses Google API for translation functionality in the backend. Google has made some changes in the its API recently. Due to this reason TextBlob's translation feature has stopped working. I noticed that by making some minor changes in translate.py file (in your folder where all TextBlob files are located) as mentioned below, we can get rid of this error:
original code:
url = "http://translate.google.com/translate_a/t?client=webapp&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"
change above code in translate.py to following:
url = "http://translate.google.com/translate_a/t?client=te&format=html&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"
I have just tried this. It did not work for me the first times.
I restarted the Anaconda Prompt, restarted IPython. And re-ran my snippets and the problem go away after the fix. I am using Windows 10, I don't use virtual environment, the two files that were changed are:
C:\Users\behai\anaconda3\pkgs\textblob-0.15.3-py_0\site-packages\textblob\translate.py
C:\Users\behai\anaconda3\Lib\site-packages\textblob\translate.py
And I have also found that I have to do tab-indentation for the newline.
Added on 02/01/2021:
I did not do anything much at all. I applied the suggestion by Mr. Manish ( green tick above ). I had this 404 problem in the Anaconda environment. After applied the change above, I just restarted the "Anaconda Prompt (anaconda3)", and it worked.
This is the change as suggested above, in:
C:\Users\behai\anaconda3\Lib\site-packages\textblob\translate.py
# url = "http://translate.google.com/translate_a/t?client=webapp&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"
url = "http://translate.google.com/translate_a/t?client=te&format=html&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&ssel=0&tsel=0&kc=1"
The file below get auto-updated:
C:\Users\behai\anaconda3\pkgs\textblob-0.15.3-py_0\site-packages\textblob\translate.py
It's fixed at https://github.com/sloria/TextBlob/pull/398
You should use a tag version with that fix.
# requirements/txt
textblob # git+https://github.com/sloria/TextBlob#0.17.1#=textBlob

Using Tenor API in Python for printing gifs

So, I am trying to print out gifs by using Tenor API.
I want it to only print one gif link but it prints out everything any Idea how to fix this?
Thank you.
https://i.stack.imgur.com/xf084.png
Sadly, I can not tell you the exact problem you are having, I replicated your code and used the official API Docs here
From what I can tell, this is one GIF just in a lot of different formats.
You can filter them like so:
print(top_8gifs['weburl'])
or
print(top_8gifs['results'][0])
EDIT: Looking at your .png (please embed it as code in the future) this should work for you, if you want the url:
print(top_8gifs[0]['url'])
A Python dict you can select using the key (like gifs['weburl'])
A Python list you have to select by index so gifs[0]
Using these techniques you can gather the data you need from that output.

3D Graphics in Kivy

I have question related to example which is presented on Kivy documentation website:
https://kivy.org/doc/stable/examples/gen__3Drendering__main__py.html#
How to use another OBJ file output using these code samples?
In addition, I was trying to do that by changing monkey.obj into another file downloaded from site:
https://free3d.com/3d-model/planet-earth-99065.html
Unfortunately, it does not work.
Changing the references to monkey.obj to point to something else is fine. Whatever your problem is, it isn't with your intentions.

Categories

Resources