Having written to professors before, there is indeed a specific way of going about it. Some of this is just general advice on politeness, so maybe this is better moved to another community?
Mark Hubbard also has a very good letter, so I suggest you look over both of ours to understand how to be polite in this context.
In general, I would write the letter like so:
Dear Dr. X,
I am Mr. Y from the Q department of Z-University. I am working on a P-subject project that requires big data analysis. If possible, I would like to ask you some questions regarding big data analysis.
Thank you very much for taking the time to read this email. I await your reply.
Firstly, does the person you're writing to have a Ph.D? If so, they should be addressed as Dr. X, rather than Mr. This is because having a doctorate is considered prestigious and important to not ignore. If they don't have a doctorate, then I would default to calling them Professor X, because professorship is also prestigious.
Secondly, you should indicate your department and the subject of the project you're working on. This way the professor knows what sort of questions you'll be asking.
Since you're being formal, instead of asking whether you can ask a question, you should frame your request using a word like would or could.
If possible, I would like to ask you some questions.
If possible, could I ask you some questions?
These are conditionals and indicate that you are uncertain that you will be allowed to ask questions. This is polite because you are not assuming Dr. X will answer the questions, but are hoping he can.
Thirdly, you should thank them for reading the email and indicate that you wish to hear from them (politely). This shows you respect them, but also that you would like to hear from them regarding whether you can ask questions.
Fourthly, you should close off you letter with Sincerely. Literally, sincerely means in "in a sincere or genuine way", but in English it's used as a formal way of closing letters.