GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

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 try! Swift Tokyo.

SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!

Get your ticket here

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.