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      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

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.