Of course I stumble upon this just AFTER I struggled with Flask to implement all the stuff Django apparently has built-in. Will try this on the next project, this looks neater.
Hi Dania, I really want to get back to ML apps as soon as possible. I will make this I do this, but it wont be until I get the ecommerce tutorials finished.
Sir ,i am preparing the project is language translation (english to chinese only) using django. i have .h5 model(keras) for that. I dont know how to use that model in django. help me . Initially i practiced only through googletrans and deployed in heroku also. worked well. But now i need to use through .h5 model. guide me please . i would like to show the coding.
@@veryacademy sir, thank you . ..because after watch your video of model, got some ideas and some hope that model for language translation. Thanks again
Hi sir i want to make prediction data by myself but i have problem. How to pickle data i have no idea about wht pickle is..sorry but if you knw pickle's tutorial please let me knw cause i try search on youtube still i dnt understand
Thank you for the comment. Sorry you are finding it hard to get resources on this. It is really simple once you have built a model - making a pickle is just one line of code. Do you know how to make a ML model from data?
@@veryacademy sir im sorry late responding. I know how to make ML at my jupyter notebook and the file is being pickle but i have problem sir the data couldn't predict the user input i have in that sir and at my cmd error it says "sklearn.tree._tree.Tree.__cinit__ value error :buffer dtype mismatch,expected 'size_t' but got long
I presume you mean a database? I think I did a tutorial showing how to save to database. You need to capture the data in the view and save to database. Have a look here ruclips.net/p/PLOLrQ9Pn6caxVPGZj0uU0e1jAg2DWOm7B
Hi Sir, if I want to put a boolean attribute in the input field (to get value from user), what can I use. I used checkbox, but by default it is passing always 'on' in the DB even if the checkbox is unchecked. Please advice.
Hi Vandana, Have a look at BooleanField #### docs.djangoproject.com/en/3.2/ref/forms/fields/ Set the initial booleanField to False #### forms.BooleanField(label="x", initial=False) After you validate/clean_data in the view it should return True or 1 and False which can be also 0
Hello! Could you help me out with this error? KeyError: "None of [Index(['sepal_length', 'sepal_width', 'petal_length', 'petal_width'], dtype='object')] are in the [columns]"
Could be a number of issues. Just from that error I cant really say too much for a solution. stackoverflow.com/questions/51976930/keyerror-none-of-are-in-the-columns-pandas-python
Hello! Sorry for the delay in getting back to you! I have the comments on notification, but still its not coming through straight away. In my rush, I didn't include a requirement.txt file, that may help you. I will test the code today and update the files with a req file. If that isn't working I will try and assist you further.
I was able to replicate your problem. Okay, to solve your project we needed to re-create the pickle file and you are good to go. Problem with a lot of code online is that the tools/packages are updating so quickly. I have updated everything, tested the code - all should be working once more. If you have any tutorial requests or ideas please I would be happy to assist your learning.
# Split into training data and test data X = df[['sepal_length','sepal_width','petal_length','petal_width']] y = df['classification'] when you wrote this, I don't think this is the right explanation: "Split into training data and test data " am i wrong? because you split it to data to check by it, and the result, And train_test_split split the data into training data and test data .
@@timorsulimani1906 i'm having the same problem when submitting the form could please tell me how you solved this error? i tried re-making the pickle file as said and that didn't help
Hi Veryacademy. Nice and clear tutorial. I am not getting anything out of the pickle file, though. I get a "ValueError: unsupported pickle protocol: 5". I am using Python 3.6, all other library versions are the same as the requirements.txt file. I have run a migration. Any ideas?
Hi - you can link to me a GitHub repo if you like in Facebook or here. Either way I will check the repo tonight for you. Its a new one for me that's for sure, but I think an easy one to solve. Here is something that might help community.platformio.org/t/valueerror-unsupported-pickle-protocol-5/10022
Hi Scott did you get it sorted. I couldn’t replicate your error. Only problem I sometimes get is if I use the pickle file that’s included in the repository. Did you build your own pickle file?
In 20:31 line 21 result = model.predict([[sepal_length, sepal_width, petal_length, petal_width]]) is the predict refrencing to sklearns predict or the predict in line 4? This is the first time I'm working with picked file so a bit confused
Hi Bijesh, Line 21 using predict is referencing to sklearn predict. Line 4 will be a view function name for a URL path. It is likely that the predict view is for the landing page of the website
To upload an image in Django forms and pass it to other views, you can follow these steps: Create a Model for Your Image: If you don't have a model for handling images, create one in your models.py file. For example: python Copy code # models.py from django.db import models class Document(models.Model): image = models.ImageField(upload_to='documents/') Create a Form for Image Upload: Build a form in forms.py that includes an ImageField for image uploads. Make sure to set enctype="multipart/form-data" in the HTML form to handle file uploads. python Copy code # forms.py from django import forms from .models import Document class DocumentForm(forms.ModelForm): class Meta: model = Document fields = ['image'] Create a View for Image Upload: In your views, create a view that handles the form submission and saves the uploaded image. python Copy code # views.py from django.shortcuts import render, redirect from .forms import DocumentForm def upload_image(request): if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): form.save() return redirect('success_page') # Redirect to a success page or another view else: form = DocumentForm() return render(request, 'upload_image.html', {'form': form}) Create a Template for Image Upload: Build an HTML template (upload_image.html) that renders the form. html Copy code {% csrf_token %} {{ form.as_p }} Upload Image Create a Success View: Create a view that will be redirected to upon successful image upload. python Copy code # views.py from django.shortcuts import render def success_page(request): return render(request, 'success_page.html') Pass Uploaded Image to Other Views: Once the image is uploaded, you can pass it to other views as needed. For example, you might pass the image URL or other relevant information to another view. python Copy code # views.py from django.shortcuts import render def another_view(request): # Get the uploaded image from the database or session image = Document.objects.last() # Adjust this based on your model structure return render(request, 'another_view.html', {'image': image}) You can then render the image in the another_view.html template as needed. Remember to configure your urls.py to route requests to the appropriate views. Adjust the code snippets based on your project's structure and requirements.
Hello! Sorry for the delay in getting back to you! I have the comments on notification, but still its not coming through straight away. In my rush, I didnt include a requirement.txt file, that may help you. I will test the code today and update the files with a req file. If that isn't working I will try and assist you further.
I was able to replicate your problem. Okay, to solve your project we needed to re-create the pickle file and you are good to go. Problem with a lot of code online is that the tools/packages are updating so quickly. I have updated everything, tested the code - all should be working once more. If you have any tutorial requests or ideas please I would be happy to assist your learning.
Sir can I send the particular dataset for prediction of astroid orbit path using random forest can make the tutorial please do it it is very useful and interesting project sir please you can made it today sir please 🙏🏻🙏🏻...
hey.. than you very much for this.... if i have a one hot encoded model, how should i approach to the prediction.?? Obviously it does not take the input as usual, then how do i onehot encode my user input...? pleaseeeeeeeeeeeee helpppppp
Hey, I don't have a direct answer for you. But you should be reading through the use of OneHotEncoder, LabelBinarizer and LabelEncoder. This could be useful www.ritchieng.com/machinelearning-one-hot-encoding/ and scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html
Hey Kritam, thank you for your message. I have recently updated the repository and tested the code as there was a few issues with a recent API update. See the comments. I have just tested the code again (from a fresh download of the repo) for you and everything is working fine. It is incredibly difficult to answer your question and support you as I would need some context to help understand what it is you have done and how you have done it, your environment details etc. Even then, still difficult. Simple things I guess is, have you run a migration? Change the values in the view.py to static values to see if anything is returning back (this tests to see if the ajax function is working) knowing that you might just need to remake the pickle file again. Think of the process in steps you type something into the form and it is then sent to the view in Django via AJAX - so in the view capture that and test it - so maybe simply add some lines of code in the view to print out what was sent from the form - is that isnt working - now you know where to look for the fault. The next task is the ML part - the data is then tested against the model (using the pickle) file - make sure that the pickle file is in the right path on your computer as it is stated in the view.py file. You could also just then make just print what is returned from the new prediction.
Of course I stumble upon this just AFTER I struggled with Flask to implement all the stuff Django apparently has built-in. Will try this on the next project, this looks neater.
why the heck you don't have million subs i am following you from 6 month and you are the best teacher i have
Hi Neuron, thank you kindly, hey the truth of it is, this is really niche and doesn't include funny cats 👍
this tutorial saved my life. What a great centry that I could take this tutorial in my room
Your voice is amazing!
The video was helpful since learnt calling ML model from Django ...thanks a lot for the video
Glad you found something useful, good luck with your develop!
Thanks a lot sir for such videos
These are far more imp. To many of us than we can say. 😊
Thank you
I like your voice and the way you explain
Thank you so much for such an amazing tutorial. It was very helpful
You're very welcome Mohammad! Have a great day! Any questions, please just ask.
@@veryacademy subscribed to your channel ❤️
Nice tutorial, thanks for sharing. 👍
Thank you too
So you are using the prediction from a Jupiter lab that loads a CSV what about if you want to upload online? and how would you do it?
I have try this, but Its not working in prediction input. I have to insert number and submit but not get dataa, why I do ,help
can you please create a stock forecast wep app using lstm in django full tutorial using csv data ???
Can you please make a tutorial for video capturing web app using Django just like live face detection
Hi Dania, I really want to get back to ML apps as soon as possible. I will make this I do this, but it wont be until I get the ecommerce tutorials finished.
Hi sir can you make a django based ml project on loan prediction
Sir ,i am preparing the project is language translation (english to chinese only) using django. i have .h5 model(keras) for that. I dont know how to use that model in django. help me . Initially i practiced only through googletrans and deployed in heroku also. worked well. But now i need to use through .h5 model. guide me please . i would like to show the coding.
Hey Alphonse, what you ask is a big long essay answer. Sorry I cant help on this one. Wish you all the best on your project - sounds interesting.
@@veryacademy sir, thank you . ..because after watch your video of model, got some ideas and some hope that model for language translation. Thanks again
How can we change the use of html in the frontend into react please
Hi sir i want to make prediction data by myself but i have problem. How to pickle data i have no idea about wht pickle is..sorry but if you knw pickle's tutorial please let me knw cause i try search on youtube still i dnt understand
Thank you for the comment. Sorry you are finding it hard to get resources on this. It is really simple once you have built a model - making a pickle is just one line of code. Do you know how to make a ML model from data?
You can see the line of code at 02:57 on line 28 that pickles the model
@@veryacademy sir im sorry late responding. I know how to make ML at my jupyter notebook and the file is being pickle but i have problem sir the data couldn't predict the user input i have in that sir and at my cmd error it says "sklearn.tree._tree.Tree.__cinit__ value error :buffer dtype mismatch,expected 'size_t' but got long
I got stuck sir :( please help me also thanks a lot for answering my questions
Hi sir, I have machine learning model deployed it with django. İ want to save the result of prediction. How can I handle that?!
I presume you mean a database? I think I did a tutorial showing how to save to database. You need to capture the data in the view and save to database. Have a look here ruclips.net/p/PLOLrQ9Pn6caxVPGZj0uU0e1jAg2DWOm7B
Hi Sir, if I want to put a boolean attribute in the input field (to get value from user), what can I use. I used checkbox, but by default it is passing always 'on' in the DB even if the checkbox is unchecked. Please advice.
Hi Vandana,
Have a look at BooleanField
####
docs.djangoproject.com/en/3.2/ref/forms/fields/
Set the initial booleanField to False
####
forms.BooleanField(label="x", initial=False)
After you validate/clean_data in the view it should return True or 1 and False which can be also 0
@@veryacademy Thanks for your reply Sir, I will implement this.
which machine learning algorithm is used here. kindly someone reply to it
This is just a simple example
Hello! Could you help me out with this error?
KeyError: "None of [Index(['sepal_length', 'sepal_width', 'petal_length', 'petal_width'], dtype='object')] are in the [columns]"
Could be a number of issues. Just from that error I cant really say too much for a solution.
stackoverflow.com/questions/51976930/keyerror-none-of-are-in-the-columns-pandas-python
@@veryacademy Can i send you a screenshot of the code along where the error has taken place. Somewhere other than here?
Screenshots are not useful I am afraid. Best to use services such as stackoverflow - your have potentially hundreds of people look at it
The columns are named different. Read what the columns are named in your file, it could differ
thanks!
i am running into a little problem tho,
'SVC' object has no attribute 'break_ties'
Hello! Sorry for the delay in getting back to you! I have the comments on notification, but still its not coming through straight away. In my rush, I didn't include a requirement.txt file, that may help you. I will test the code today and update the files with a req file. If that isn't working I will try and assist you further.
I was able to replicate your problem. Okay, to solve your project we needed to re-create the pickle file and you are good to go. Problem with a lot of code online is that the tools/packages are updating so quickly. I have updated everything, tested the code - all should be working once more. If you have any tutorial requests or ideas please I would be happy to assist your learning.
@@veryacademy yes it works now, thanks for the requirements.txt file!!
# Split into training data and test data
X = df[['sepal_length','sepal_width','petal_length','petal_width']]
y = df['classification']
when you wrote this,
I don't think this is the right explanation:
"Split into training data and test data
"
am i wrong?
because you split it to data to check by it, and the result,
And train_test_split split the data into training data and test data
.
@@timorsulimani1906 i'm having the same problem when submitting the form could please tell me how you solved this error? i tried re-making the pickle file as said and that didn't help
Hi Veryacademy. Nice and clear tutorial. I am not getting anything out of the pickle file, though. I get a "ValueError: unsupported pickle protocol: 5". I am using Python 3.6, all other library versions are the same as the requirements.txt file. I have run a migration. Any ideas?
Hi - you can link to me a GitHub repo if you like in Facebook or here. Either way I will check the repo tonight for you. Its a new one for me that's for sure, but I think an easy one to solve. Here is something that might help
community.platformio.org/t/valueerror-unsupported-pickle-protocol-5/10022
Hi Scott did you get it sorted. I couldn’t replicate your error. Only problem I sometimes get is if I use the pickle file that’s included in the repository. Did you build your own pickle file?
thanks @@veryacademy. Let me try to re-create the pickle file.
@@veryacademy All good now, thanks! (didnt build the picklte file properly)
Nice one, enjoy!
In 20:31 line 21 result = model.predict([[sepal_length, sepal_width, petal_length, petal_width]])
is the predict refrencing to sklearns predict or the predict in line 4?
This is the first time I'm working with picked file so a bit confused
Hi Bijesh, Line 21 using predict is referencing to sklearn predict. Line 4 will be a view function name for a URL path. It is likely that the predict view is for the landing page of the website
After clicking the submit button , i am not getting the entered values in modal. Can you help mee.
Plis respoj this
how i uploading image in forms how can i pass it to other views .
pls help im building documentaion text extraction
To upload an image in Django forms and pass it to other views, you can follow these steps:
Create a Model for Your Image:
If you don't have a model for handling images, create one in your models.py file. For example:
python
Copy code
# models.py
from django.db import models
class Document(models.Model):
image = models.ImageField(upload_to='documents/')
Create a Form for Image Upload:
Build a form in forms.py that includes an ImageField for image uploads. Make sure to set enctype="multipart/form-data" in the HTML form to handle file uploads.
python
Copy code
# forms.py
from django import forms
from .models import Document
class DocumentForm(forms.ModelForm):
class Meta:
model = Document
fields = ['image']
Create a View for Image Upload:
In your views, create a view that handles the form submission and saves the uploaded image.
python
Copy code
# views.py
from django.shortcuts import render, redirect
from .forms import DocumentForm
def upload_image(request):
if request.method == 'POST':
form = DocumentForm(request.POST, request.FILES)
if form.is_valid():
form.save()
return redirect('success_page') # Redirect to a success page or another view
else:
form = DocumentForm()
return render(request, 'upload_image.html', {'form': form})
Create a Template for Image Upload:
Build an HTML template (upload_image.html) that renders the form.
html
Copy code
{% csrf_token %}
{{ form.as_p }}
Upload Image
Create a Success View:
Create a view that will be redirected to upon successful image upload.
python
Copy code
# views.py
from django.shortcuts import render
def success_page(request):
return render(request, 'success_page.html')
Pass Uploaded Image to Other Views:
Once the image is uploaded, you can pass it to other views as needed. For example, you might pass the image URL or other relevant information to another view.
python
Copy code
# views.py
from django.shortcuts import render
def another_view(request):
# Get the uploaded image from the database or session
image = Document.objects.last() # Adjust this based on your model structure
return render(request, 'another_view.html', {'image': image})
You can then render the image in the another_view.html template as needed.
Remember to configure your urls.py to route requests to the appropriate views. Adjust the code snippets based on your project's structure and requirements.
Prediction is not working.
Means when displaying result page output is not shown
Hello! Sorry for the delay in getting back to you! I have the comments on notification, but still its not coming through straight away. In my rush, I didnt include a requirement.txt file, that may help you. I will test the code today and update the files with a req file. If that isn't working I will try and assist you further.
I was able to replicate your problem. Okay, to solve your project we needed to re-create the pickle file and you are good to go. Problem with a lot of code online is that the tools/packages are updating so quickly. I have updated everything, tested the code - all should be working once more. If you have any tutorial requests or ideas please I would be happy to assist your learning.
I need project on prediction of astroid orbit path using random forest algorithm video please can you send it
Yeah I just happen to have made it today! 😂
@@veryacademyplease can you send me the tutorial please 🙏🏻🙏🏻🙏🏻....
Sir can I send the particular dataset for prediction of astroid orbit path using random forest can make the tutorial please do it it is very useful and interesting project sir please you can made it today sir please 🙏🏻🙏🏻...
amazing
hey.. than you very much for this.... if i have a one hot encoded model, how should i approach to the prediction.?? Obviously it does not take the input as usual, then how do i onehot encode my user input...? pleaseeeeeeeeeeeee helpppppp
Hey, I don't have a direct answer for you. But you should be reading through the use of OneHotEncoder, LabelBinarizer and LabelEncoder. This could be useful www.ritchieng.com/machinelearning-one-hot-encoding/ and scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html
@@veryacademy actually i had. i think i have to handle the request to convert but it is such a long process. Anyways thank you for the suggestion 💚🌺
How about stackoverflow.com/questions/41496248/predicting-from-scikitlearn-randomforestclassification-with-categorical-data
When I get a moment I will see if I can do an example for you.
@@veryacademy that will be really greatful.. thankyou sooo much💚🌺💚🌺
After clicking the submit button , i am not getting the entered values in modal. Please provide a solution.
Hey Kritam, thank you for your message. I have recently updated the repository and tested the code as there was a few issues with a recent API update. See the comments. I have just tested the code again (from a fresh download of the repo) for you and everything is working fine. It is incredibly difficult to answer your question and support you as I would need some context to help understand what it is you have done and how you have done it, your environment details etc. Even then, still difficult. Simple things I guess is, have you run a migration? Change the values in the view.py to static values to see if anything is returning back (this tests to see if the ajax function is working) knowing that you might just need to remake the pickle file again. Think of the process in steps you type something into the form and it is then sent to the view in Django via AJAX - so in the view capture that and test it - so maybe simply add some lines of code in the view to print out what was sent from the form - is that isnt working - now you know where to look for the fault. The next task is the ML part - the data is then tested against the model (using the pickle) file - make sure that the pickle file is in the right path on your computer as it is stated in the view.py file. You could also just then make just print what is returned from the new prediction.
Hey did you find a solution about it? I really need help
Request classification with Flask
Ok, I will do the same project with flask - is that what you are asking?
@@veryacademy yes sir but i want to use naive bayes multiclass algorithm
@@veryacademy good luck your channel 👍
Okay, so to confirm a flask api with naive bayes classification example
Without explaining anything you are doing the work. Pretty ridiculous. The commentary should include Why you do something when u do something