| import gradio as gr | |
| import pandas as pd | |
| import fastbook | |
| from fastbook import * | |
| from fastai.collab import * | |
| fastbook.setup_book() | |
| path = untar_data(URLs.ML_SAMPLE) | |
| dls = CollabDataLoaders.from_csv(path/'ratings.csv') | |
| learn = collab_learner(dls, y_range=(0.5,5.5)) | |
| learn.fine_tune(10) | |
| df_rating = pd.read_csv(path/'ratings.csv', sep=',', parse_dates=['timestamp']) | |
| def predict(movieId): | |
| return df_rating['rating'][movieId] | |
| title = "Movie Ratings" | |
| description = "Given a movie ID, the predicted rating is displayed" | |
| iface = gr.Interface(fn=predict, inputs="number", outputs="number") | |
| iface.launch() |