UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Issue with Day 27: Project 4 Part 2 .mlmodel

Forums > 100 Days of SwiftUI

Hey all,

I'm having issues with Project 4 Part 2's .mlmodel file. When I import the .mlmodel file that I created in Create ML, the prediction input values don't match what Paul's example on screen shows. My wake and coffee input values according to the .mlmodel are Int64, instead of the Double that Paul's example on screen shows.

Because of that, the calculateBedtime function fails to work, throwing the following message:

Cannot convert value of type 'Double' to expected argument type 'Int64'
Replace 'Double(hour + minute)' with 'Int64(Double(hour + minute))'

I've recreated the file multiple times to try to fix it, but I keep running into the same problem.

Any ideas?

2      

I got the same Int64 values. You should get it to work with:

let prediction = try? model?.prediction(wake: Int64(hour + minute), estimatedSleep: sleepAmount, coffee: Int64(coffeeAmount))

2      

@renny  

I'm having the same issue.

2      

I have the same issue. The following fix seems to work:

Replace the line:

let prediction = try model.prediction(wake: Double(hour + minute), estimatedSleep: sleepAmount, coffee: Double(coffeeAmount))

with:

let prediction = try model.prediction(wake: Int64(hour + minute), estimatedSleep: sleepAmount, coffee: Int64(coffeeAmount))

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.