Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the advantages of the Python library pyforest

2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains the "Python library pyforest what are the advantages", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "what are the advantages of Python library pyforest" bar!

An example

See, there is no import at the beginning, and you can still use the common library normally.

Installation

A version above Python3.6 needs to be installed, and then the terminal runs:

Pip install pyforest

Usage

Very simple!

It can be solved with one line of code.

From pyforest import *

If you use Jupyter or IPython, you can even skip this line because pyforest adds itself to the automatic startup.

Also, after completing the script, you can export all import statements in the following ways:

Active_imports ()

Through this instruction, we can see all the libraries involved in the script that have been omitted by me.

Well, you might ask, what if the required library is not in pyforest?

First of all, pyforest supports most popular data science libraries, such as pandas,numpy,matplotlib,seaborn,sklearn,tensorflow, etc., as well as commonly used auxiliary libraries such as os,sys,re,pickle.

# Data Wranglingpd = LazyImport ("import pandas as pd") np = LazyImport ("import numpy as np") dd = LazyImport ("from dask import dataframe as dd") SparkContext = LazyImport ("from pyspark import SparkContext") load_workbook = LazyImport ("from openpyxl import load_workbook") # Data Visualization and Plottingmpl = LazyImport ("import matplotlib as mpl") plt = LazyImport ("import matplotlib.pyplot as plt") sns = LazyImport ("import seaborn as sns") py = LazyImport ("import plotly as py") go = LazyImport ("import plotly.graph_objs as go") px = LazyImport ("import plotly.express as px") dash = LazyImport ("import dash") bokeh = LazyImport ("import bokeh") alt = LazyImport ("import altair as alt") pydot = LazyImport ("import pydot") # statisticsstatistics = LazyImport ("import statistics") # Machine Learningsklearn = LazyImport ("import sklearn") OneHotEncoder = LazyImport ("from sklearn.preprocessing import OneHotEncoder") TSNE = LazyImport ("from sklearn.manifold import TSNE") train_test_split = LazyImport "from sklearn.model_selection import train_test_split" svm = LazyImport ("from sklearn import svm") GradientBoostingClassifier = LazyImport ("from sklearn.ensemble import GradientBoostingClassifier") GradientBoostingRegressor = LazyImport ("from sklearn.ensemble import GradientBoostingRegressor") RandomForestClassifier = LazyImport ("from sklearn.ensemble import RandomForestClassifier") RandomForestRegressor = LazyImport ("from sklearn.ensemble import RandomForestRegressor") TfidfVectorizer = LazyImport ("from sklearn.feature_extraction.text import TfidfVectorizer") # TODO: add all the other most important sklearn objects# TODO: add separate sections within machine learning viz. Classification, Regression, Error Functions Clustering# Deep Learningtf = LazyImport ("import tensorflow as tf") keras = LazyImport ("import keras") # NLPnltk = LazyImport ("import nltk") gensim = LazyImport ("import gensim") spacy = LazyImport ("import spacy") re = LazyImport ("import re") # # Helpersys = LazyImport ("import sys") os = LazyImport ("import os") re = LazyImport ("import re") glob = LazyImport ("import glob") Path = LazyImport ("from pathlib import Path") pickle = LazyImport ("import pickle") import pickle = LazyImport ("import datetime as dt") tqdm = LazyImport ("import tqdm")

Second, it doesn't matter if you don't have it, pyforest supports adding libraries to it. The method of operation is also very simple, find the user_imports.py file of the pyforest library, and then add a statement, such as this:

# # User-specific imports # # You can save your own imports in ~ / .pyforest/user_imports.py# Please note: imports in ~ / .pyforest/user_imports.py take precedence over the# imports above.

So we can add a set of omnipotent import according to our usual use habits, which is awesome.

Some students may also ask, will it slow down when all the libraries are added?

The answer is no, because the program won't really import until you actually use the included library in pyforest, otherwise it won't.

Thank you for reading, the above is the content of "what are the advantages of Python library pyforest". After the study of this article, I believe you have a deeper understanding of what the advantages of Python library pyforest are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report