Some beginners questions

Hello i’m new to Julia. I have a couple of questions.

  1. Is there a command to start a new project like cargo init (rust). So that it generates some files (Project.toml maybe?). If there is no such command maybe there is a template/skeleton i can use

  2. I would like to do logistic regression. In python there are a few packages that are often discussed and the go-to packages for most situations like pandas and scikit. Are there also such packages in julia? I’m not sure what i should be using.

Thanks for the help :slight_smile:

1 Like

Welcome!

  1. Latest Version of “How to create packages”
  2. Maybe you find something here:
    Anyone developing multinomial logistic regression?

Its recommended (even by the latest version of the Pkg docs) to use PkgTemplates to create your new project, rather than the minimal built in pkg> generate command.
Because that will setup all the good things like the files required for CI and docs for you.

4 Likes

Edited 1.

From GitHub - JuliaCI/PkgTemplates.jl: Create new Julia packages, the easy way

NOTICE: This version is not yet released

The current stable release is 0.6, you can find that version here.
PkgTemplates has undergone large internal changes (see #61 especially), and at present the user-facing API is still catching up.
Do not fear, while right now it looks very different (e.g. in the dev docs), it will not be incredibly breaking. But right now if you do use master it will be.

I am not sure if this should be a first step for a newcomer.
Anyways he/she can now decide on his/her own.

There is also

which is considerably simpler (and of course not as flexible).

Note that I linked to: https://github.com/invenia/PkgTemplates.jl/tree/v0.6.3
the tagged release v0.6.3.
For exactly that reason. :slight_smile:

1 Like

Do people have default stuff in their start up for PkgTemplates/PkgSkeleton so they don’t have to put in all the fields everytime? I create a lot of packages locally when I get an idea in a really boring meeting but then I have to go back and build up the package properly. I have a lot of really boring meetings so this is a frequent problem.

I am not sure I fully understand the question — PkgSkeleton just needs a path, and it will infer everything else from the environment. Actually, making things customizable is an outstanding feature request :wink:

(personally, I do isometric exercises during meetings).

This is more of a question to those who responded than it is to the OP, but what about simply calling activate . from the package REPL? I still use this when I’m just creating a new folder for tinkering around.

For the OP, this is done by pressing the ] key in the REPL. You should then see a prompt that looks like this (v1.3) pkg>. From there, you would type activate . and you’ll end up with both a Project.toml and Manifest.toml.

This per se will not create a Project.toml file (at least when I test in 1.3, 1.4).

Also, even though a Project.toml will be generated once you add packages, template generators take care of a lot of other things, including recommended configurations for CI, coverage, documentation setup and deployment, etc.

You can do all of this yourself, but there is little point in that, as it can be fully automated.

This per se will not create a Project.toml file (at least when I test in 1.3, 1.4).

You’re right @tamas_papp, I just realized you don’t get the Project.toml until after you’ve added packages. Nonetheless, I think it could still be a decent option for a first-timer and for creating a new project that you may not intend to do anything with (other than experiment/learn).

Using PkgTemplates and similar options is actually something I avoided for a little while when I was first starting out because it just seemed a little bit intimidating. Once you do it, of course, you realize it’s no big deal so there’s really no reason not to go ahead and get in the habit from the start.

That being said, I think there is something worth exploring here for Julia. The OP mentions calling cargo init in Rust and for me, my first language being JavaScript/Node.js, calling npm init from the terminal was always the first thing I did when starting a new project. It doesn’t seem that there is an equivalent in Julia (maybe there shouldn’t be, I don’t know enough to decide).

I am not sure if you are aware of pkg> generate?

I used to keep them in a unsaved tab in sublime text. Then one day I closed it and lost them :joy:
For Invenia’s official ones, we have a small julia package which basically just defines them as constants, for different use cases.
I think bigger Github orgs like JuliaDiff should do the same thing.


I think it would be cool to have a PackageTemplatesCookBook repo,
where people just dump their templates,
and then can steal ideas from each other.

For logistic regression, the easiest approach is probably to use the GLM (Generalized Linear Models) package:

using DataFrames, GLM
data = DataFrame(X=[1,2,2], Y=[1,0,1])
logit = glm(@formula(Y ~ X), data, Binomial()) # uses logit link function by default

Docs for GLM: https://juliastats.org/GLM.jl/stable/manual/

1 Like