Kaggle competition: COVID19 Global Forecasting (Week 1)
model.evaluate(dig_img, dig_labels )<predict_on_test>
data_train = pd.read_csv("/kaggle/input/covid19-global-forecasting-week-1/train.csv" )
pred_dig = model.predict(dig_img)
 dig_df['pred'] = np.argmax(pred_dig, axis=1 )<feature_engineering>
data_train["Date"] = data_train["Date"].apply(lambda x: datetime.strptime(x,'%Y-%m-%d'))
data_train["Date"] = data_train["Date"].apply(lambda x: x.timestamp())
 data_train["Date"] = data_train["Date"].astype(int )
dig_df['correct'] = dig_df['label'] - dig_df['pred']
errors = dig_df[dig_df['correct'] != 0]
error_list = errors.index
print('Number of errors is ', len(errors))
print('The indices are ', error_list )<predict_on_test>
data_train = data_train.drop(['Province/State'],axis=1)
 data_train = data_train.dropna()
data_train.isnull().sum()
predictions = model.predict(test_img)
 print(predictions.shape )<prepare_output>
data_test = pd.read_csv("/kaggle/input/covid19-global-forecasting-week-1/test.csv")
 data_test["Date"] = data_test["Date"].apply(lambda x: datetime.strptime(x,'%Y-%m-%d'))
data_test["Date"] = data_test["Date"].apply(lambda x: x.timestamp())
 data_test["Date"] = data_test["Date"].astype(int)
 data_test.isnull().sum()
predicted_labels = np.argmax(predictions, axis=1 )<save_to_csv>
data_test.drop('Province/State', axis = 1, inplace = True)
 data_test.head()
submission = pd.read_csv('.. /input/Kannada-MNIST/sample_submission.csv')
 submission['label'] = predicted_labels
submission.to_csv('submission.csv', index=False )<import_modules>
X = data_train[['Lat', 'Long', 'Date']]
Y1 = data_train[['ConfirmedCases']]
Y2 = data_train[['Fatalities']]
X_test = data_test[['Lat', 'Long', 'Date']]
from fastai import *
from fastai.vision import *<define_variables>
model = RandomForestClassifier(bootstrap=True,max_depth=None, max_features='auto', max_leaf_nodes=None,
n_estimators=150, random_state=None, n_jobs=1, verbose=0)
 model.fit(X,Y1)
 pred1 = model.predict(X_test)
 pred1 = pd.DataFrame(pred1)
 pred1.columns = ["ConfirmedCases_prediction"]
DATAPATH = Path('/kaggle/input/Kannada-MNIST' )<data_type_conversions>
model = RandomForestClassifier(bootstrap=True,max_depth=None, max_features='auto', max_leaf_nodes=None,
n_estimators=150, random_state=None, n_jobs=1, verbose=0)
 model.fit(X,Y2)
 pred2 = model.predict(X_test)
 pred2 = pd.DataFrame(pred2)
 pred2.columns = ["Death_prediction"]
def get_data_labels(csv, label):
fileraw = pd.read_csv(csv)
 labels = fileraw[label].to_numpy()
data = fileraw.drop([label],axis=1 ).to_numpy(dtype=np.float32 ).reshape(( fileraw.shape[0],28,28))
data = np.expand_dims(data, axis=1)
 return data, labels<define_variables>
data_submission = pd.read_csv("/kaggle/input/covid19-global-forecasting-week-1/submission.csv")
 data_submission.columns
sub_new = data_submission[["ForecastId"]]
train_data, train_labels = get_data_labels(DATAPATH/'train.csv','label')
 test_data, test_labels = get_data_labels(DATAPATH/'test.csv','id')
 other_data, other_labels = get_data_labels(DATAPATH/'Dig-MNIST.csv','label' )<train_model>
concat = pd.concat([pred1,pred2,sub_new],axis=1)
 concat.head()
concat.columns = ['ConfirmedCases', 'Fatalities', 'ForecastId']
concat = concat[['ForecastId','ConfirmedCases', 'Fatalities']]
plt.title(f'Training label: {train_labels[6]}')
 plt.imshow(train_data[6,0])
<define_variables>
concat["ConfirmedCases"] = concat["ConfirmedCases"].astype(int)
 concat["Fatalities"] = concat["Fatalities"].astype(int )
np.random.seed(42)
 ran_10_pct_idx =(np.random.random_sample(train_labels.shape)) <.001
print(np.random.random_sample(train_labels.shape)< 0.01)
 train_90_labels = train_labels[np.invert(ran_10_pct_idx)]
train_90_data = train_data[np.invert(ran_10_pct_idx)]
valid_10_labels = train_labels[ran_10_pct_idx]
valid_10_data = train_data[ran_10_pct_idx]<create_dataframe>
concat.to_csv("submission.csv",index=False )