# Flux score worse than Keras regression... am I doing something wrong?

**URL:** <https://discourse.julialang.org/t/flux-score-worse-than-keras-regression-am-i-doing-something-wrong/61850>\
**Category:** New to Julia\
**Created:** [May 26, 2021, 11:27am UTC](https://discourse.julialang.org/t/flux-score-worse-than-keras-regression-am-i-doing-something-wrong/61850 "2021-05-26T11:27:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shawngiese](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@shawngiese](https://discourse.julialang.org/u/shawngiese)\
**Post date:** [May 26, 2021, 11:27am UTC](https://discourse.julialang.org/t/flux-score-worse-than-keras-regression-am-i-doing-something-wrong/61850/1 "2021-05-26T11:27:42Z")

</div>

Hi, I am learning how to work with Keras and Python but I want to try using Julia too. One of the early tests I made was using Keras to make a regression to predict a number. Does anyone have suggestions on what I could try (or what I could read) to get better results with Flux?  
Julia 1.6.1  
Flux 0.12.3  
Dataset from [UCI Machine Learning Repository: Bike Sharing Dataset Data Set](https://archive.ics.uci.edu/ml/datasets/bike+sharing+dataset)

The Keras example…

```julia
model = Sequential()
model.add(Dense(13, input_dim=13, activation='relu'))
model.add(Dense(1, activation='linear'))
model.compile(loss='mean_squared_error', optimizer = 'adam', metrics = ['mse', 'mae'])
estimator= model.fit(x, y, epochs=500, verbose=1)
print("mse: ", estimator.history['mse'][-1], " mae: ", estimator.history['mae'][-1])

```

Which gives me results like mse: 0.0518 - mae: 0.1762

When I try with Flux…

```julia
model = Chain(
  Dense(13,13, relu),
  Dense(13,1, identity)
  )

loss(x, y) = Flux.Losses.mse(model(x), y)
theParameters = Flux.params(model)
optimiser = ADAM()

epochs = 500
@time for i = 1:epochs # using for loop instead of epochs macro to avoid log spam
    Flux.train!(loss, theParameters, [(training,y)], optimiser)
end
print("mse: ", loss_mse[epochs]," mae: ",loss_mae[epochs])

```

I get results like  
mse: 6.883073257723706e6 mae: 2129.58720440448

I prepare the data for Flux as…

```julia
myData = CSV.read("Bike-Sharing-Dataset/day.csv", DataFrame; header = true)
x = myData[:,3:15]
y = myData[:,16]
xmat = convert(Matrix, x)
training = transpose(xmat)

```

---

<div class="post-metadata">

**Author:** ![shawngiese](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@shawngiese](https://discourse.julialang.org/u/shawngiese)\
**Post date:** [May 29, 2021, 7:36pm UTC](https://discourse.julialang.org/t/flux-score-worse-than-keras-regression-am-i-doing-something-wrong/61850/2 "2021-05-29T19:36:38Z")

</div>

I’m guessing it is my data format.
