# HW1
## Question 1
### Q: Error when installing PyCaret on the local machine
I highly recommend using Colab or Kaggle when executing the lab or doing homework! If you want to install it on your local machine, you may follow the instruction [here](https://pycaret.gitbook.io/docs/get-started/installation#environment):
```bash
# create a conda environment
conda create --name yourenvname python=3.8
# activate conda environment
conda activate yourenvname
# install pycaret
pip install pycaret
# create notebook kernel
python -m ipykernel install --user --name yourenvname --display-name "display-name"
```
### Q: After executing pip install --pre pycaret[full]. You may get the following error

Please restart the environment as follows:

### Q: I can not get the ames.csv data!
Please upload the related files in https://phonchi.github.io/nsysu-math608/assignments/01_assignment to Colab or Kaggle. You can put the files on google drive and use `gdown` or directly drag them into Colab or Kaggle.
```python
!gdown --fuzzy your_sharable_link
```
Remember that the working directory is `/content/` on Colab and is `/kaggle/working/`, `/kaggle/input/` on Kaggle, respectively.
## Question 3
### Q: How to construct the client for Bigquery?
1. The first approach is to follow the instruction [here](https://cloud.google.com/bigquery/docs/quickstarts/quickstart-client-libraries) to get the credential in JSON format. Upload the JSON file to Colab and use the following code to construct the client. (Note that you should replace `"lunar-pact-378812-7a28b789bde2.json"` with your own JSON file's name)
```python=
from google.oauth2 import service_account
from google.cloud import bigquery
key_path = "lunar-pact-378812-7a28b789bde2.json"
credentials = service_account.Credentials.from_service_account_file(
key_path
)
client = bigquery.Client(credentials=credentials, project=credentials.project_id,)
```
2. The second approach is to follow the first two steps described [here](https://cloud.google.com/bigquery/docs/quickstarts/quickstart-client-libraries) and use the following code: (Note that you need to replace `'lunar-pact-378812'` with your project ID)
```python=
from google.colab import auth
from google.cloud import bigquery
from google.colab import data_table
project = 'lunar-pact-378812' # Project ID inserted based on the query results selected to explore
location = 'US' # Location inserted based on the query results selected to explore
client = bigquery.Client(project=project, location=location)
data_table.enable_dataframe_formatter()
auth.authenticate_user()
```
3. The third approach is to use Kaggle directly. Firstly, remember to turn on the internet:

> You will need to verify your phone number if this is the first time you register kaggle. Firstly, click profile icon on top right corner of your page --> Click Account --> click Account tab --> scroll down to Phone Verification --> click Not verified link --> enter your mobile phone number --> enter the verification code sent to your mobile phone and you're done!
Then, use the following code:
```python=
from google.cloud import bigquery
client = bigquery.Client()
```