here is a post about linear regression, the first step of machine learning. we'll be using python to predict divorce cases for mauritius, my country
What Is Linear Regression
regression just means prediction.
read more on those two dev.to articles
Our Data
we'll be downloading our csv from here . the first one. i renamed it divorce.csv
Opening Up Jupyter
let us import our libs
import pandas as pd
import matplotlib.pyplot as plt
from sklearn import linear_model
# psst inspect sklearn to see what other models there are
let's have a look at our data
df = pd.read_csv('<path-to-file>/divorce.csv')
df
gives us
we'll be predicting the column Number of cases disposed of which Divorce pronounced
but let us have a look at our data
plt.scatter(df['Year'], df['Number of cases disposed of which Divorce pronounced'])
we get
let us train our model
reg = linear_model.LinearRegression()
reg.fit(df[['Year']], df['Number of cases disposed of which Divorce pronounced'])
and predict for the year 2017
reg.predict([[2017]])# it was 1,921
we get
array([ 2140.22222222])
Getting m And c
since linear regression is just a straight line (really that whole machine learning world is just some maths), we can get the coefficient (our m) and the intercept (our c)
coefficient is given by
reg.coef_
outputs
array([ 57.79118774])
and intercept by
reg.intercept_
outputs
-114424.60344827584
Building Our Own Predictor Function
we can now build a simple function to predict without passing by ml
def devdotto_predict(year_):
# m * x + c
return 57.79118774 * year_ + -114424.60344827584
and use it
devdotto_predict(2017)
we get
2140.222223304154
compare above
Conclusion
machine learning is super easy if you understand the concept!
cover img credit : Photo by Xavier Coiffic On Unsplash
real pic of mauritius
Top comments (3)
The Florida Child Support Calculator is a valuable tool designed to help parents estimate the amount of child support that may be required under Florida law. This calculator provides a clear and structured method for determining child support obligations, taking into account various essential factors such as each parent’s income, the number of children, healthcare and childcare expenses, and the time each parent spends with the children. By inputting accurate financial and custodial information how far behind in child support before a warrant is issued in florida, the tool can generate a reliable estimate that aligns with the Florida Child Support Guidelines, giving parents a better understanding of their legal responsibilities and rights.
Predicting divorces in Mauritius using linear regression means analyzing past data to find trends and factors affecting divorce rates. This machine learning method helps forecast future divorces based on things like the economy and social changes. Although focused on Mauritius, studying divorcio en Florida can provide useful insights since both places may share similar social patterns, improving the prediction model’s accuracy.
The Simplest It Can Get!