Skip to content

Instantly share code, notes, and snippets.

@curiousily
curiousily / linear-regression-in-tensorflow.js
Created June 20, 2018 17:45
Create a Simple Linear Regression model in TensorFlow.js that given some number from the Fibonacci sequence predicts the next one while only running in the browser!
// What is a Tensor?
const myFirstTensor = tf.scalar(42)
console.log(myFirstTensor)
myFirstTensor.print()
const oneDimTensor = tf.tensor1d([1, 2, 3])
oneDimTensor.print()
def create_dataset(X, y, time_steps=1):
Xs, ys = [], []
for i in range(len(X) - time_steps):
v = X.iloc[i:(i + time_steps)].values
Xs.append(v)
ys.append(y.iloc[i + time_steps])
return np.array(Xs), np.array(ys)
cfg.SOLVER.IMS_PER_BATCH = 4
cfg.SOLVER.BASE_LR = 0.001
cfg.SOLVER.WARMUP_ITERS = 1000
cfg.SOLVER.MAX_ITER = 1500
cfg.SOLVER.STEPS = (1000, 1500)
cfg.SOLVER.GAMMA = 0.05
app_reviews_df = pd.DataFrame(app_reviews)
app_reviews_df.to_csv('reviews.csv', index=None, header=True)
len(app_reviews)
{
"appId": "com.anydo",
"at": "2020-04-05 22:25:57",
"content": "Update: After getting a response from the developer I would change my rating to 0 stars if possible. These guys hide behind confusing and opaque terms and refuse to budge at all. I'm so annoyed that my money has been lost to them! Really terrible customer experience. Original: Be very careful when signing up for a free trial of this app. If you happen to go over they automatically charge you for a full years subscription and refuse to refund. Terrible customer experience and the app is just OK.",
"repliedAt": "2020-04-07 14:09:03",
"replyContent": "Our policy and TOS are completely transparent and can be found in the Help Center and our main page. In addition, a payment can only be made upon the user's authorization via the app and Google Play. We provide users with a full 7 days trial to test the app with an additional 48 hours for a refund, along with priority support for all issues.",
"reviewCreatedVersion": "4.17.0.3",
"score":
print_json(app_reviews[0])
app_reviews = []
for ap in tqdm(app_packages):
for score in list(range(1, 6)):
for sort_order in [Sort.MOST_RELEVANT, Sort.NEWEST]:
rvs, _ = reviews(
ap,
lang='en',
country='us',
sort=sort_order,
app_infos_df = pd.DataFrame(app_infos)
app_infos_df.to_csv('apps.csv', index=None, header=True)
def format_title(title):
sep_index = title.find(':') if title.find(':') != -1 else title.find('-')
if sep_index != -1:
title = title[:sep_index]
return title[:10]
fig, axs = plt.subplots(2, len(app_infos) // 2, figsize=(14, 5))
for i, ax in enumerate(axs.flat):
ai = app_infos[i]