Skip to content

Instantly share code, notes, and snippets.

View ChristopherDaigle's full-sized avatar
:atom:
Teaching Machines

Christopher Daigle ChristopherDaigle

:atom:
Teaching Machines
View GitHub Profile
from sklearn.linear_model import LinearRegression, Ridge
from sklearn.model_selection import train_test_split
X = df_final.drop(['vote_average', 'release_date'], axis=1)
y = df_final['vote_average']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
lm_model = LinearRegression(normalize=True)
r_model = Ridge(normalize=True)
from sklearn.linear_model import LogisticRegression, LogisticRegressionCV
from sklearn.ensemble import AdaBoostClassifier, RandomForestClassifier
from sklearn.ensemble import GradientBoostingClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import fbeta_score, accuracy_score
models = {'log_model': LogisticRegression(random_state=0),
'log_cv_model': LogisticRegressionCV(),
'ab_model':AdaBoostClassifier(random_state=0),
'rf_model': RandomForestClassifier(random_state=0),
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler(feature_range=(0, 1))
numerical = ['orig_title_len', 'overview_len', 'tagline_len', 'title_len',
'popularity', 'runtime', 'vote_average', 'vote_count']
df_impute_log_minmax = pd.DataFrame(data = df_1_impute_fill).copy()
df_impute_log_minmax[numerical] = scaler.fit_transform(df_1_impute_fill[numerical])
# Preserve final df transformation:
df_impute_transformed = df_impute_log_minmax
from sklearn.impute import KNNImputer
imputer = KNNImputer(n_neighbors=int(round(np.sqrt(df_1.shape[0]))))
df_1.reset_index(inplace = True, drop = True)
impute_df = df_1.drop(columns='release_date')
impute_df_filled = imputer.fit_transform(X=impute_df)
imputed_cols = list(df_1.drop(columns='release_date').columns)
df_impute = pd.DataFrame(data=impute_df_filled, columns=imputed_cols)
from sklearn.linear_model import LinearRegression, Ridge
from sklearn.model_selection import train_test_split
X = df_final.drop(['revenue', 'release_date'], axis=1)
y = df_final['revenue']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
lm_model = LinearRegression(normalize=True)
r_model = Ridge(normalize=True)
from sklearn.linear_model import LinearRegression, Ridge
from sklearn.model_selection import train_test_split
X = df_1.drop(['revenue', 'above_ave_rev_yr', 'original_language', 'original_title', 'overview', 'release_date', 'status', 'tagline', 'title'], axis=1)
y = df_1['revenue']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
lm_model = LinearRegression(normalize=True)
r_model = Ridge(normalize=True)
@ChristopherDaigle
ChristopherDaigle / yahoo_finance.py
Created October 6, 2019 20:30 — forked from scrapehero/yahoo_finance.py
Python 3 code to extract stock market data from yahoo finance
from lxml import html
import requests
from time import sleep
import json
import argparse
from collections import OrderedDict
from time import sleep
def parse(ticker):
url = "http://finance.yahoo.com/quote/%s?p=%s"%(ticker,ticker)
@ChristopherDaigle
ChristopherDaigle / KMeans.ipynb
Last active February 21, 2019 20:15
MediumPostTest
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ChristopherDaigle
ChristopherDaigle / lastexport.py
Created April 17, 2016 23:36 — forked from bitmorse/lastexport.py
lastfm scrobble exporter (from https://gitorious.org/fmthings/lasttolibre/blobs/master/lastexport.py // changed the script to try more often on failure )
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of