{'fraction_non_alphanumeric': 0.034906956413138505, 'fraction_numerical': 0.012051954539777695, 'mean_word_length': 4.7504488330341115, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Undergraduate Mathematical Undergraduate of Mathematical Modeling: One + Two Modeling: One + Two Probabilistic Machine Learning Using Bayesian Inference Probabilistic Machine Learning Using Bayesian Inference

Abstract Machine Learning is a branch of AI (Artificial Intelligence) which expands on the idea of a computational system extending its knowledge about set methodical behaviors from the data that is fed to it to essentially develop analytical skills that can help in identifying patterns and making decisions with little to no participation of a real human being. Computer algorithms help in gaining experience to improve the facility over time for use by both consumers and corporations. In today’s technologically advanced world, Machine Learning has given us self-driving cars, speech recognition software, and AI agents like Siri and Google assistant. This project evaluates how the Beta function came to be and how Stirling’s formula is implemented in calculating the magnitude of this function for large input values. The Beta function can then be used to produce a Beta distribution of probabilities to find whether people will actually watch a video they come across on their recommendations feed or search feed and then using Bayesian inference update the prior set predictions.


PROBLEM STATEMENT Show how Bayesian inference is used in Machine Learning which enables corporations like
YouTube to predict how many people will actually watch a video they come across on YouTube's recommendations feed or search feed and how this data develops an intelligent sorting algorithm.

MOTIVATION
Big corporations like YouTube make use of programs and algorithms that can predict the outcome of appreciation of a particular video or post on their sites. The results are probabilities of univariate cases. The Beta function is used for generating a Beta distribution. Once essential data is generated for sampling, an algorithm implements the Bayesian inference to successfully predict the percentage of people that will possibly watch the video. Furthermore, with the help of a binomial distribution, YouTube can even figure out the number of views they will fetch for every possible user that comes across a particular video which can help their sorting algorithm based on Machine Learning to target specific audiences or demonetize videos based on a violation of rules which adds to the experience for the selection algorithm that can potentially restrict future content of such type. Therefore, it is incredibly important and useful for companies to develop Machine Learning algorithms that can improve over time and reduce labor-intensive work for the company and require minimal human intervention. Machine Learning and Artificial Intelligence in itself really interest me so I decided to research more about how it's implemented at a large scale.

MATHEMATICAL DESCRIPTION AND SOLUTION APPROACH
In order to target specific audiences for their future videos and content for maximum efficiency and profit, video streaming companies like YouTube, Netflix, and Hulu gather large amounts of user feedback on some "prior" content. Essentially, they are using the Bayesian inference which comes from Bayes' theorem to model a probability of the event where a specific criterion bounded audience likes their content based on similar content views from the past. To model this probability, they use a probability distribution like Beta or Dirichlet. The Beta distribution is univariate whereas Dirichlet is for multivariate. Though any distribution of probabilities over (0,1) will work. Simply take any function that does not blow up between 0 and 1 everywhere and remains stable, then add it from 0 to 1, and simply split the function with the result. The reason Beta Distribution is special is that it is the prior conjugate in Bayesian inference for the Bernoulli, binomial, negative binomial, and geometric distributions. It is very easy to calculate a posterior using a prior conjugate since you can skip the expensive computational calculation involved in Bayesian inference.
Since the Beta function is related to the Gamma function and it is itself a factorial function generalization. Many complex integrals can be reduced to expressions involving the Beta function.
The notation for the Gamma function is: Undergraduate Journal of Mathematical Modeling: One + Two, Vol. 11, Iss. 1 [2020], Art. 1 If the real part of the complex number z in (1) is positive, then the integral converges absolutely, see, e.g., Davis (1959, pp. 849-869). Equation (1) is known as the Euler integral of the second kind. Using integration by parts, one sees that: It is easy to recognize that in Equation (2): -x z e -x → 0 as x → ∞, Equation (3) is the formal definition of the Gamma Function.
For the purpose of this project, we need the Beta Function as a function of the Gamma Function.
To derive the integral representation of the Beta function, write the product Γ(x)Γ(y) as: Equation (4) leads to a simple derivation of the relationship between the Beta and Gamma functions, see, e.g., Artin (2015).

4
Changing variables by u = f(z,t) = zt and v = g(z,t) = z(1-t) shows that this is: Representing Equation (5) in the standard form we get: Equation (6) is the formal definition of the Beta function and the relationship between Gamma and Beta functions (see, e.g., Artin, 2015). The integral in (6) is known as Euler's integral of the first kind. Now, for generating probability distribution of probabilities we use the Probability density function of Beta Distribution, which is as follows: Equation (7) is the Probability Density Function of Beta Distribution and it is consistent with several authors like (George, 1960;Gerald, 1994;Keeping, 2010;Norman, 1995).
Since the Beta function, like the Gamma function, is based on n! therefore, it is helpful then for cases with large values of n to approximate the value of this function.
In fact, programs written in the Python language or JAVA language implement Stirling's approximation to give an approximation for calculating factorials. It is also useful for approximating the log of a factorial.
There is a quick way to derive Stirling's formula. We can approximate the sum: Equation (8) is consistent with several sources like (Wikipedia-Stirling's approximation, n.d.; Conrad, n.d.) Now, using an integral: ∑ ln j n j=1 ≈ ∫ ln x dx = n•ln nn +1 n 1 2 (ln 1 + ln n) = 1 2 ln n The right-hand side of Equation (10) minus Equation (11) is the approximation by the trapezoid rule of the integral (Conrad, n.d.): and the error in this approximation as suggested in Equation (12)  ln (n!) -1 2 ln n = 1 2 ln 1 +ln 2 +ln 3 + ⋅⋅⋅ + ln(n-1) where B k is a Bernoulli number and R m,n is the remainder in the Euler-Maclaurin formula. Now, we take limits of Equation (13) to find that: Denote this Equation (14) where the Big-O notation is used, combining Equation (14) and Equation (15) from above yields the approximation formula in its logarithmic form: Taking the exponential of both sides and choosing any positive integer m, one obtains a formula involving an unknown quantity e y . For m = 1, the formula is: The quantity e y can be found by taking the limit on both sides as n tends to infinity and using Wallis' product, which shows that e y =√2π.
Therefore, one obtains Stirling's formula from Equation (17) For large values of n Stirling's formula proves to be extremely useful since the usual notation of factorial is defined as: If applied to cases or situations where n is extremely large it would be a tedious and expensive approach since a lot of memory capacity is going to be used up in storing each consecutive result, therefore, the approach in Equation (19) is inefficient for large values of n.
The Gamma function is based on an integral so it is a better approach but since Stirling's formula is an asymptotic approximation, it is the most efficient method because it requires the least computational complexity for execution and from Big-O-notation, it has a decent run-time with sufficient memory use. This way Stirling's formula in Equation (18) can be easily used in Equation (7) to find the Beta Distribution. Beta Distribution gives a probability, so its domain is bounded between 0 and 1.
I believe YouTube exploits the Beta Distribution for generating a probability distribution of probabilities by using feedback from previous content as a sample. They actually make use of the conjugate prior method which can be inferred from the model for Bayes' Theorem in Equation (20) below: Conjugate prior essentially means for some likelihood functions, if you choose a certain prior P(Θ), the posterior P(Θ|data) ends up being in the same distribution as the prior. Such a prior P(Θ) then is called a Conjugate Prior. Θ is the probability of success (most likes or most number of views) and our goal is to pick the Θ that maximizes the posterior probability which is calculated by numerical optimization, such as the Gradient Descent or Newton method. The P(data|Θ) denotes feedback from previous content from the source as a sample distribution.
Since I do not have access to such large scale sample data, for my analysis I am going to assume that if an average music video has about 4,000 interactions on YouTube (people came across this video) and if we know that 800 people watched the video then let α, the number of people that watched the video be 800 and let β, the number of people that didn't watch the video, be 4000-800 = 3,200 in Equation (7). These parametershow big or small α & β arewill determine the shape of the distribution.
Using some Python code and using the algorithm for Beta distribution, we have now acquired the graph of this probability density for the prior distribution: Aerin Kim. (2020). [Graph showing the probability density of about 20% for the selected values]. Towards Data Science.
Retrieved from https://towardsdatascience.com/bayesian-inference-intuition-and-example-148fd8fb95d6 The Probability Density rises to 20% (800 views/4000 interactions) as expected. Four thousand points tends to be a solid prior in this case, judging from the plot. This is the P(Θ) part of Bayes' Theorem.
Now for the Likelihood P(data|Θ) we can assume that we have the same values for the data variable in the form of a binary array, say: data is a binary array [0,1,0,1,...,0,0,0,1].
Since we know the number of views (n) and the number of interactions/visitors (p) and the prior probability P(Θ), we can use the binomial distribution for all possible values of data and a specific value of Θ=0.3 (30%) to predict the number of views. Aerin Kim. (2020). [Graph showing the probability of seeing X successes in n trials for Θ=30%]. Towards Data Science.
Retrieved from https://towardsdatascience.com/bayesian-inference-intuition-and-example-148fd8fb95d6 This is the probability of seeing successes for the data points of data in n trials, assuming a specific parameter Θ=0.3 (30%) which is close to 0.02 (from the graph) so it is a very small probability.
Finally, the posterior function P(Θ|data) is the crux of this approach. YouTube implements Bayesian inference using Bayes' Theorem. Again, the Bayesian inference is used to find Θ that best fits the data. The principle is simple, P(Θ) was the original definition of parameters. Now after acquiring some data we are upgrading a simple P(Θ) to something more informative -P(Θ|data) and it becomes smarter as smarter with more supply of data or experience. P(Θ|data) is still the probability of Θ and so is P(Θ). However, P(Θ|data) is a smarter version of P(Θ).  explains in her article "Bayesian Inference --Intuition and Example" that: Although there are thousands of data points, we can transform them into a single scalar -the probability P(data|θ)by plugging data into the model you want (in this case, the binomial distribution), then measure and multiply P(θ) & P(data|θ) for a particular model.
If you do this for every possible resort you can select between different θ's the highest P(θ)*P(data|θ). We can essentially multiply P(θ) with P(data|θ) by conditioning on θ. The probability in the posterior graph can be observed to have shifted to the prior one. For the prior, the views' probability was 20%. The views' probability from the data points was taken to be 30%. Now, posterior has its value around 0.25%. Since we added more information/data, the range of possible parameters is now smaller/narrower. Therefore, the width of the graph has reduced. The more data you collect, the posterior graph will look more like the Likelihood/sampling distribution graph and less like the prior. In other words, the original pre-distribution becomes less relevant when you get more info.
In general, however, after we determine the posterior, the posterior is the fresh prior before the next data batch is entered. We can update our prior and posterior iteratively in this way. That is how YouTube's algorithm for recommending videos to target audiences learns from experience for the profit of the company. used my own small set of sample data for plotting the probability using the Beta Distribution, However, YouTube -being one of the most successful companies out there -has access to copious amounts of data that helps their Machine Learning algorithm to expand its vision from the experience. Calculating the probability using Bayes' Theorem led me to a probability of about 20% for the number of views for the prior. The number of views' probability was taken to be 30% for the data. Finally, the posterior had a peak around 0.25%.

DISCUSSION
This result demonstrated the use of Bayesian inference as the posterior function learned from the predicted value for the probability and the expected value to shift towards the prior. Furthermore, when this method is repeated for new data, this posterior will become the new prior distribution and then the probability keeps getting updated at the end of each cycle. The endpoint of one cycle is the starting prior for the next. Therefore, more data means better results.
This small example goes on to show that Bayesian inference is an extremely powerful tool for the field of Machine Learning and Artificial Intelligence in general and can result in the advancement of technology effectively. The results of this project align with my initial beliefs about how YouTube uses user data to effectively manipulate content their audience receives upfront, However, it was only after much effort and research did I realize that this approach is used by several companies in today's world. It does make sense to use Bayesian inference in such a manner because while it benefits the companies and corporations with millions of dollars of profit, it is beneficial to the general consumer as they get recommendations on products that they actually are interested in which saves much of their time and effort. So, it is a win-win for both parties. But serious allegations can be charged against the company for data privacy if proof is found for a potential data breach.

CONCLUSION AND RECOMMENDATIONS
This project evaluated how Beta function came to be and how Stirling's formula is implemented in calculating the magnitude of this function. The Beta function was then used to produce Beta distribution for finding the probability of whether people will watch a particular YouTube video and that probability was calculated using a computer algorithm that used the Beta distribution by implementing Stirling's approximation. The result was then used in unison with Bayesian inference to update the system if the prior beliefs (probability data) turned out to be inaccurate or inconsistent with the actual trends and data values.
The findings of this project fit with my original assumption that YouTube is utilizing user data to successfully exploit media censorship, but it was only after a lot of work and study that I discovered that this strategy is being utilized by a variety of businesses in today's world. Using