TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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 Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your 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.