Getting loading error while loading catboost in notebook - catboost

Unable to read catboost into jupyter notebook. Getting an import error.
ImportError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_27572/4101664180.py in
----> 1 import catboost as ctb
~\Anaconda3\Lib\site-packages\catboost_init_.py in
----> 1 from .core import (
2 FeaturesData, EFstrType, EShapCalcType, EFeaturesSelectionAlgorithm, Pool, CatBoost,
3 CatBoostClassifier, CatBoostRegressor, CatBoostRanker, CatBoostError, cv, train, sum_models, _have_equal_features,
4 to_regressor, to_classifier, to_ranker, MultiRegressionCustomMetric, MultiRegressionCustomObjective
5 ) # noqa
~\Anaconda3\Lib\site-packages\catboost\core.py in
41 _typeof = type
42
---> 43 from .plot_helpers import save_plot_file, try_plot_offline
44 from . import _catboost
45 from .metrics import BuiltinMetric
~\Anaconda3\Lib\site-packages\catboost\plot_helpers.py in
1 import warnings
2
----> 3 from . import _catboost
4 fspath = _catboost.fspath
5
ImportError: DLL load failed while importing _catboost: The specified module could not be found.

Related

Cant import a .csv file into jupyter. i get an error

I'm trying to import a .csv file in Jupyter. Ever time I import it i get an error,"name species is not defined". I don't understand why it will not bring down the spreadsheet. !ls brings down " species.csv". I'm on a Mac and i drag the file over to jupyter.
import pandas as pd
!ls
species.csv = pd.read_csv('./species.csv')
species.csv
Output:
NameError Traceback (most recent call last)
Input In [12], in <cell line: 5>()
1 import pandas as pd
3 get_ipython().system('ls')
----> 5 species.csv = pd.read_csv('./species.csv')
7 species.csv
NameError: name 'species' is not defined

Error while setting up roBERTa model in colab notebook

I am getting error while merging vocabulary and merge txt files for tokenizers designed for Tensorflow roBERTa. I attached the error snapshot!![enter image description here][1]
Code:
tokenizer = tokenizers.ByteLevelBPETokenizer(vocab_file='vocab_roberta_base.json',
merges_file='merges_roberta_base.txt', lowercase=True,add_prefix_space=True)
ERROR:
Exception Traceback (most recent call last)
<ipython-input-9-5dab9f2389e4> in <module>()
1 MAX_LEN = 96
----> 2 tokenizer = tokenizers.ByteLevelBPETokenizer(vocab_file='vocab_roberta_base.json',merges_file='merges_roberta_base.txt')
3 sentiment_id = {'positive': 1313, 'negative': 2430, 'neutral': 7974}
/usr/local/lib/python3.6/dist-packages/tokenizers/implementations/byte_level_bpe.py in __init__(self, vocab_file, merges_file, add_prefix_space, lowercase, dropout, unicode_normalizer, continuing_subword_prefix, end_of_word_suffix)
31 dropout=dropout,
32 continuing_subword_prefix=continuing_subword_prefix or "",
---> 33 end_of_word_suffix=end_of_word_suffix or "",
34 )
35 )
Exception: expected ident at line 1 column 2

Hazm: POSTagger(): ArgumentError: argument 2: <class 'TypeError'>: wrong type

I have got an error for running the below code. May you give me some help?
from __future__ import unicode_literals
from hazm import *
tagger = POSTagger(model='resources/postagger.model')
tagger.tag(word_tokenize('ما بسیار کتاب موانیم'))
Error:
---------------------------------------------------------------------------
ArgumentError Traceback (most recent call last)
<ipython-input-16-1d74d781e0c1> in <module>
1 tagger = POSTagger(model='resources/postagger.model')
----> 2 tagger = POSTagger()
3 tagger.tag(word_tokenize('ما بسیار کتاب موانیم'))
~/.local/lib/python3.6/site-packages/hazm/SequenceTagger.py in __init__(self, patterns, **options)
21 def __init__(self, patterns=[], **options):
22 from wapiti import Model
---> 23 self.model = Model(patterns='\n'.join(patterns), **options)
24
25 def train(self, sentences):
~/.local/lib/python3.6/site-packages/wapiti/api.py in __init__(self, patterns, encoding, **options)
283 self._model = _wapiti.api_new_model(
284 ctypes.pointer(self.options),
--> 285 self.patterns
286 )
287
ArgumentError: argument 2: <class 'TypeError'>: wrong type
I am using ubuntu18.04 on windows 10. Also, I put mentioned files in resources file beside of code.
Python 3.6.9
Package of hazm
I have no problem to run Chunker one from this packege!
chunker = Chunker(model='resources/chunker.model')
tagged = tagger.tag(word_tokenize('واقعا ک بعضیا چقد بی درکن و ادعا دارن فقط بنده خدا لابد دسترسی نداره ب دکتری چیزی نگران شد'))
tree2brackets(chunker.parse(tagged))
its because of wapiti package! wapiti does not supporting python 3 and just work with python 2! if you need postagger, you should use another postagger package!

how to upload and read a zip file containing training and testing images data from google colab from my pc

I am new to google colab. I am implementing a pretrained vgg16 and resnet50 model using pytorch, but I am unable to load my file and read it as it returns an error of no directory found
I have uploaded the data through file also I have used to upload it using
from google.colab import files
uploaded = files.upload()
The file got uploaded but when I tried to unzip it because it is a zip file using
!unzip content/cropped_months
then it says
no file found
import torch
import torch.nn as nn
import torch.optim as optim
from torchvision.transforms import *
from torch.optim import lr_scheduler
from torch.autograd import Variable
import numpy as np
import torchvision
from torchvision import datasets, models, transforms
import matplotlib.pyplot as plt
import time
import os
import copy
from google.colab import files
uploaded = files.upload()
!unzip content/cropped_months
data_dir = 'content/cropped_months'
​
#Define transforms for the training data and testing data
train_transforms = transforms.Compose([transforms.RandomRotation(30),transforms.RandomResizedCrop(224),transforms.RandomHorizontalFlip(),transforms.ToTensor(),transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])])
​
test_transforms = transforms.Compose([transforms.Resize(256),transforms.CenterCrop(224),transforms.ToTensor(),transforms.Normalize([0.485, 0.456, 0.406],[0.229, 0.224, 0.225])])
​
#pass transform here-in
train_data = datasets.ImageFolder(data_dir + '/train', transform=train_transforms)
test_data = datasets.ImageFolder(data_dir + '/test', transform=test_transforms)
​
#data loaders
trainloader = torch.utils.data.DataLoader(train_data, batch_size=8, shuffle=True)
testloader = torch.utils.data.DataLoader(test_data, batch_size=8, shuffle=True)
​
print("Classes: ")
class_names = train_data.classes
print(class_names)
first error
unzip: cannot find or open content/cropped_months,
content/cropped_months.zip or content/cropped_months.ZIP.
second error
--------------------------------------------------------------------------- FileNotFoundError Traceback (most recent call
last) in ()
16
17 #pass transform here-in
---> 18 train_data = datasets.ImageFolder(data_dir + '/train', transform=train_transforms)
19 test_data = datasets.ImageFolder(data_dir + '/test', transform=test_transforms)
20
2 frames
/usr/local/lib/python3.6/dist-packages/torchvision/datasets/folder.py
in _find_classes(self, dir)
114 if sys.version_info >= (3, 5):
115 # Faster and available in Python 3.5 and above
--> 116 classes = [d.name for d in os.scandir(dir) if d.is_dir()]
117 else:
118 classes = [d for d in os.listdir(dir) if os.path.isdir(os.path.join(dir, d))]
FileNotFoundError: [Errno 2] No such file or directory:
'content/cropped_months (1)/train'
You are probably trying to access the wrong path. In my notebook, the file was uploaded to the working directory.
Use google.colab.files to upload the zip.
from google.colab import files
files.upload()
Upload your file. Google Colab will display where it was saved:
Saving dummy.zip to dummy.zip
Then just run !unzip:
!unzip dummy.zip
I think you can use PySurvival library is compatible with Torch , here the link :
https://square.github.io/pysurvival/miscellaneous/save_load.html

tensorflow import error in jupyter notebook in deep learning

I am writing a tensorflow program to find dogs vs cats prediction i got a error in this part of the code when i tried to execute this cell in juypter notebook.
2.Below is the code:
import tflearn
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.core import input_data, dropoutfully_connected
from tflearn.layers.estimator import regression
import tensorflow as tf
tf.reset_default_graph()
convnet = input_data(shape=[None, IMG_SIZE, IMG_SIZE, 1],name='input')
convnet = conv_2d(convnet, 32, 5, activation='relu')
convnet = max_pool_2d(convnet, 5)
convnet = conv_2d(convnet, 64, 5, activation='relu')
convnet = max_pool_2d(convnet, 5)
convnet = fully_connected(convnet, 1024, activation='relu')
convnet = dropout(convnet, 0.8)
convnet = fully_connected(convnet, 2, activation='softmax')
convnet = regression(convnet, optimizer='adam', learning_rate=LR, loss='categorical_crossentropy', name='targets')
model = tflearn.DNN(convnet, tensorboard_dir='log')
----- - ---------------------------------------------------------------------
Error for the above code below (can anyone help to resolve this error):
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-6-2ef14dea0c38> in <module>()
----> 1 import tflearn
2 from tflearn.layers.conv import conv_2d, max_pool_2d
3 from tflearn.layers.core import input_data, dropout, fully_connected
4 from tflearn.layers.estimator import regression
5
/home/aravind/anaconda3/lib/python3.6/site-packages/tflearn/__init__.py in <module>()
19
20 # Predefined ops
---> 21 from .layers import normalization
22 from . import metrics
23 from . import activations
/home/aravind/anaconda3/lib/python3.6/site-packages/tflearn/layers/__init__.py in <module>()
8 from .normalization import batch_normalization, local_response_normalization
9 from .estimator import regression
---> 10 from .recurrent import lstm, gru, simple_rnn, bidirectional_rnn, \
11 BasicRNNCell, BasicLSTMCell, GRUCell
12 from .embedding_ops import embedding
/home/aravind/anaconda3/lib/python3.6/site-packages/tflearn/layers/recurrent.py in <module>()
6 import tensorflow as tf
7 from tensorflow.python.ops import array_ops
----> 8 from tensorflow.contrib.rnn.python.ops.core_rnn import static_rnn as _rnn, \
9 static_bidirectional_rnn as _brnn
10 from tensorflow.python.ops.rnn import rnn_cell_impl as _rnn_cell, \
ModuleNotFoundError: No module named 'tensorflow.contrib.rnn.python.ops.core_rnn'