Skip to content

Commit 7b804eb

Browse files
committed
Minor improvements
1 parent f050eb7 commit 7b804eb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

docs/src/getting_started/linear_regression.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The following page contains a step-by-step walkthrough of the linear regression algorithm in `Julia` using `Flux`! We will start by creating a simple linear regression model for dummy data and then move on to a real dataset. The first part would involve writing some parts of the model on our own, which will later be replaced by `Flux`.
44

55
## A simple linear regression model
6-
Let us start by building a simple linear regression model. This model would be trained on the data points of the form `(x₁, y₁), (x₂, y₂), ... , (xₙ, yₙ)`. In the real world, these `x`s denote a feature, and the `y`s denote a label; hence, our data would have `n` data points, each point mapping a single feature to a single label.
6+
Let us start by building a simple linear regression model. This model would be trained on the data points of the form `(x₁, y₁), (x₂, y₂), ... , (xₙ, yₙ)`. In the real world, these `x`s can have multiple features, and the `y`s denote a label. In our example, each `x` has a single feature; hence, our data would have `n` data points, each point mapping a single feature to a single label.
77

88
Importing the required `Julia` packages -
99

@@ -13,7 +13,7 @@ julia> using Flux
1313
julia> using Plots
1414
```
1515
### Generating a dataset
16-
The data usually comes from the real world, which we will be exploring in the last part of this tutorial, but we don't want to jump straight to the relatively harder part. Here we will generate the `x`s of our data points and map them to the respective `y`s using a simple function. Remember, each `x` is a feature, and each `y` is the corresponding label. Combining all the `x`s and `y`s would create the complete dataset.
16+
The data usually comes from the real world, which we will be exploring in the last part of this tutorial, but we don't want to jump straight to the relatively harder part. Here we will generate the `x`s of our data points and map them to the respective `y`s using a simple function. Remember, here each `x` is equivalent to a feature, and each `y` is the corresponding label. Combining all the `x`s and `y`s would create the complete dataset.
1717

1818
```jldoctest linear_regression_simple
1919
julia> x = hcat(collect(Float32, -3:0.1:3)...);
@@ -120,14 +120,14 @@ julia> flux_model = Dense(1 => 1)
120120
Dense(1 => 1) # 2 parameters
121121
```
122122

123-
A [`Dense(1 => 1)`](@ref Dense) layer denotes a layer of one neuron with one output and one input. This layer is exactly same as the mathematical model defined by us above! Under the hood, `Flux` too calculates the output using the same expression! But, we don't have to initialize the parameters ourselves this time, instead `Flux` does it for us.
123+
A [`Dense(1 => 1)`](@ref Dense) layer denotes a layer of one neuron with one input (one feature) and one output. This layer is exactly same as the mathematical model defined by us above! Under the hood, `Flux` too calculates the output using the same expression! But, we don't have to initialize the parameters ourselves this time, instead `Flux` does it for us.
124124

125125
```jldoctest linear_regression_simple; filter = r"[+-]?([0-9]*[.])?[0-9]+"
126126
julia> flux_model.weight, flux_model.bias
127127
(Float32[1.0764818], Float32[0.0])
128128
```
129129

130-
Now we can check if our model is acting right -
130+
Now we can check if our model is acting right. We can pass the complete data in one go, with each `x` having exactly one feature (one input) -
131131

132132
```jldoctest linear_regression_simple; filter = r"[+-]?([0-9]*[.])?[0-9]+"
133133
julia> flux_model(x) |> size
@@ -268,7 +268,7 @@ julia> using MLDatasets: BostonHousing
268268
```
269269

270270
### Data
271-
Let's start by initializing our dataset. We will be using the [`BostonHousing`](https://juliaml.github.io/MLDatasets.jl/stable/datasets/misc/#MLDatasets.BostonHousing) dataset consisting of `506` data points. Each of these data points has `13` features and a corresponding label, the house's price.
271+
Let's start by initializing our dataset. We will be using the [`BostonHousing`](https://juliaml.github.io/MLDatasets.jl/stable/datasets/misc/#MLDatasets.BostonHousing) dataset consisting of `506` data points. Each of these data points has `13` features and a corresponding label, the house's price. The `x`s are still mapped to a single `y`, but now, a single `x` data point has 13 features.
272272

273273
```julia linear_regression_complex
274274
julia> dataset = BostonHousing()

0 commit comments

Comments
 (0)